#django

/

      • geekodour08 joined the channel
      • lavalamp joined the channel
      • geekodour08 has quit
      • RCStef has quit
      • geekodour08 joined the channel
      • geekodour08 has quit
      • fikka joined the channel
      • geekodour08 joined the channel
      • geekodour08 has quit
      • geekodour08 joined the channel
      • geekodour08 has quit
      • geekodour08 joined the channel
      • fikka has quit
      • geekodour08 has quit
      • pythonfox joined the channel
      • jrist joined the channel
      • Kangermu joined the channel
      • fikka joined the channel
      • geekodour08 joined the channel
      • geekodour08 has quit
      • geekodour08 joined the channel
      • fikka has quit
      • joshua-s has quit
      • bparker
        how do you raise a ValidationError on a form _only_ if the form is to be used for the creation of a new model object?
      • raising it in a model's save_form or save_model doesn't work properly (Interval Server Error unless DEBUG is on)
      • Xard joined the channel
      • GinFuyou
        You can probably check form.instance.pk
      • bparker
        when though? surely that won't be valid in a clean_field() method on a ModelForm class ?
      • koniiiik
        Why not?
      • bparker
        because it would have already been saved?
      • defeating the whole point of cleaning
      • koniiiik
        …no? Saving happens after validation.
      • bparker
        then how do you get a pk from database without saving?
      • koniiiik
        That's the point.
      • bparker
        huh?
      • koniiiik
        If .pk is None, that means you are creating a new instance.
      • fikka joined the channel
      • bparker
        oh
      • I see
      • koniiiik
        :)
      • jtiai
        Though, if you don't want to validate, why do you have field in the first place?
      • briian
        anyone authenticate with ldap? I have to learn how to do django authentication + ldap authentication, the main production environment would be ldap and the test environment would be essentially just type yoru username to identify yourself and that lets you log into the webpage. should i do this with the authentication array in settings.py and put ldap first so if that fails then it falls to the secondary authentication? also in my user table i can remove passwo
      • koniiiik
        Yeah, a better solution would probably be to have two ModelForms, one for creation, another for updates.
      • czart_ joined the channel
      • They can have the same base with most of their functionality.
      • jtiai
        Well one is enough if you want to toy with fields in __init__...
      • koniiiik
        Or that.
      • jtiai
        But, explicit is better than implicit...
      • dodobas has quit
      • czart has quit
      • bparker
        alright, about my previous question
      • 14:44 < bparker> is there a way to make custom auth backends work with the password reset mechanism? it seems to just call get_user_model() which only returns `User` and hence would be incorrect in my cast
      • anyone have an idea there?
      • case*
      • fikka has quit
      • inad922 has quit
      • DodgeThis has quit
      • jtiai
        bparker: You need to somehow distinguish which is your user credentials source.
      • graphene joined the channel
      • koniiiik
        bparker: Hang on, are you using a custom user model without setting it up as the user model implementation?
      • Or is it that your user model is not storing the credentials?
      • Either way, time to wrap it up for the day, have a good one, everyone.
      • lavalamp has quit
      • wildlander joined the channel
      • mitaka has quit
      • fikka joined the channel
      • toomanytims joined the channel
      • fission6 joined the channel
      • bparker
        jtiai: koniiiik I have:
      • AUTHENTICATION_BACKENDS = ('territoryapp.views.RepBackend', 'territoryapp.views.CustomerBackend', 'django.contrib.auth.backends.ModelBackend',)
      • the first two correspond to different user models, while the default one at the end is used for the admin, but not any user-facing sites
      • inad922 joined the channel
      • so in the case of someone with a 'Rep' or 'Customer' account wanting to reset their password, I need some way for it to find the correct instance of their account from either of those models
      • the usernames between the two models cannot be the same
      • Wooble joined the channel
      • at first I tried overriding PasswordResetView so I could pass it a (also overridden) PasswordResetForm to lookup the correct user, but then the issue became the token generation... which uses only the username's pk, which doesn't really work when you've got multiple tables to look at
      • so I'd have to also override all the token generation stuff and modify that
      • which is probably not a great idea
      • masterrex joined the channel
      • jil
        in ModelForm how do I pass all fields ?
      • bparker
        pass it where? to what?
      • jil
        I tried fields = * ; field = __all__ ; and fields = None
      • class meta: .. fields = ..
      • bparker
        they're all included by default
      • fikka has quit
      • pythonfox
        ya just model = Model_name_here should work
      • lavalamp joined the channel
      • bparker
        or you can do class Meta: model = Foo exclude = []
      • if you want to be explicit
      • fikka joined the channel
      • jil
        I don't get it. because I have to set the field attrirbute of the Meta class and I get a compilation error
      • django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form DeroulantForm needs updating.
      • ok, with the exclud = [] will be ok. Thank you
      • yes
      • pythonfox
        hmm i wonder why fields = '__all__' wouldnt work
      • jil
        because I didn't put the quotes. I see that now
      • pythonfox
        o
      • jil
        thankyou
      • lavalamp has quit
      • lavalamp joined the channel
      • its harder to code easily... that to code hardly..
      • so much time spent trying to do something so simple as a select form....
      • jaddison has quit
      • jtiai
        jil: Evetually it gets easier :)
      • jil
        help me please... I just want to transform a Dummy models.Model class with one var foo = models.CharField(... choices = ((..,..), ..)) to a form using ModelForm
      • jtiai
        Well paste your current code to dpaste.de and let's continue with that.
      • azulakina joined the channel
      • jil
      • it's a new app, a new project and I still need to migrate
      • jtiai
        Well that will work.
      • It's though suggested that you put choices constatns within class they're used and not in top level.
      • also to be noted that when you do __all__ you may accidentally expose fields that you do not want to be editable to be exposed (even they are not visible in the form, it allows malicious users to send them in input data)
      • lavalamp has quit
      • bhoman joined the channel
      • ryanhiebert joined the channel
      • jil
        ok, I got that jtiai... but for now I'de like to pass this simple test and i have a error trace https://dpaste.de/D9h2 for that simple code
      • I'm about to restart (again) from scratch... because this time I code what I wanted before doing the migration. maybe that's the problem
      • jtiai
      • There is a typo.
      • Haudegen joined the channel
      • ryanhiebert
        Is there a way to control the order of fields selected in a subquery? For good, but annoying to explain, reasons, I really need them in a specific order, and just using `values` is putting them in a different order than I specify.
      • jil
        un homme à la mer ! aio !
      • need to fixe my flycheck.. thank you jtiai.
      • I going to rest.. I cannot swimm no more
      • jil has left the channel
      • jtiai
        ryanhiebert: values no, but values_list should provide values in same order as entered.
      • of course I think it depends on your python version what values gives to you.
      • ryanhiebert
        OK, I guess I better say why. I'm using the subquery to construct a PostgreSQL `ROW` for comparision like `ROW(1, 2, 3) < ROW(select a, b, c from xyz where id=1)`
      • jtiai
        I think that one requires you to resort to raw sql...
      • ryanhiebert
        But in the subquery it's doing it in a different order than I'm specifying for the order of the ROW.
      • That's a huge bummer. There are several other things that I had to work through, and I thought I'd finally figured out a way to avoid the raw SQL.
      • jaddison joined the channel
      • kyern has quit
      • jessamynsmith joined the channel
      • kyern joined the channel
      • briian
        if i remove columns from the auth_user table will it bork the user model?
      • want to drop password
      • jtiai
        It will.
      • You need to remove that field from the model and use the migrations.
      • audioburn
        jtiai, will subclassing AbstractUser to create a new AUTH_USER_MODEL have the same effect as creating a new model (e.g. UserProfile) with a OneToOne Relationship with django.contrib.auth.models.User? With the only difference being in name? (User vs UserProfile)
      • briian
        jtiai: yeah i meant with a migration
      • jtiai
        audioburn: No.
      • audioburn
        jtiai, what is the difference?
      • jtiai
        audioburn: AbstractUser is abstract. It doesn't have a table of it's own.
      • audioburn
        ah
      • jtiai
        audioburn: When you inherit abstract model to non abstract (concrete) model, all fields, managers, etc. are copied over to concrete model.
      • ciaala joined the channel
      • Leeds has quit
      • Kangermu has quit
      • invk07 joined the channel