3 ms·
I agree it's a bit clunky, but... Making REQUIRED_FIELDS figure itself out from introspection means we all risk getting hurt by unanticipated edge cases. I wo
by pydanny 14y ago
I agree it's a bit clunky, but...
Making REQUIRED_FIELDS figure itself out from introspection means we all risk getting hurt by unanticipated edge cases.
I would rather deal with a small bit of clunk than magical code touching my user model.
- hcarvalhoalves 14y agoThe point is: what does REQUIRED_FIELDS do? Model validation? Form validation? Can you put a blank=True field on REQUIRED_FIELDS? Can you not put a blank=False on REQUIRED_FIELDS? It's duplicating behavior in two different places, and it's not entirely clear what it does, or what overrides what. This is much worse than introspection, because you'll have to patch Django to fix any inconsistencies instead of just changing your model definition / inheriting forms accordingly.
- pydanny 14y agoSee https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.CustomUser.User.REQUIRED_FIELDS https://docs.djangoproject.com/en/dev/topics/auth/#django.co... The quick version is that it's not duplicating behavior, the documentation is simply still undergoing work. We'll try and make it a bit more clear in the days to come. The long version is that during user creation sometimes you have fields that for whatever reason are not required by the database but are required for the user to enter in. This is because user creation is often more complex than it seems on the surface, and there is already existing django.contrib.auth.views that need this sort of configuration. REQUIRED_FIELDS gives you the control to force the user to enter data while not not altering the database. Is it ideal? Not really. But having dealt with user creation through email, OAuth, OpenID, LDAP, SOAP, and worse, having this as a configurable setting is better than an auto-magic introspection. Finally, I'll return to the documentation issue. I'm officially duly noting that the documentation on this feature needs work. I've opened ticket #19402 to address this issue. See https://code.djangoproject.com/ticket/19402 https://code.djangoproject.com/ticket/19402
- ProblemFactory 14y ago> The long version is that during user creation sometimes you have fields that for whatever reason are not required by the database but are required for the user to enter in. This is because user creation is often more complex than it seems on the surface, and there is already existing django.contrib.auth.views that need this sort of configuration. REQUIRED_FIELDS gives you the control to force the user to enter data while not not altering the database. Could you please explain this further? Is REQUIRED_FIELDS intended for use cases where some users are created by import/migration, but others by sign-up forms (with more requirements)? From grepping the 1.5beta1 source code, it appears that the only place where REQUIRED_FIELDS is actually read is in contrib/auth/management/commands/createsuperuser.py.
- pydanny 14y agoRather than get into a huge discussion here, I'm going to spend my time working the ticket I mentioned. This isn't production ready code/documentation, it's a BETA release. Your issue has been noted and we are digging in. :-)