It seems you shouldn't use null but rather an empty string: https://docs.djangoproject.com/en/dev/ref/models/fields/#null
> Avoid using > null<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null> > on > string-based fields such as > CharField<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.CharField> > and > TextField<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.TextField> > unless > you have an excellent reason. If a string-based field has null=True, that > means it has two possible values for “no data”: NULL, and the empty > string. In most cases, it’s redundant to have two possible values for “no > data;” Django convention is to use the empty string, not NULL. On Tuesday, August 7, 2012 11:08:50 AM UTC-4, Demian Brecht wrote: > > In an authentication backend I'm currently writing, I've supplied a custom > User model that extends the contrib.auth User model. I have the need to > allow email addresses to be NULL. > > A little context: I'm writing an OAuth2 wrapper for an OAuth2 client I > relatively recently wrote (yes, I know that there are other clients already > written out there, but I'm writing this one due to being quite partial to > my module ;)). Some OAuth2 providers don't provide user e-mail addresses, > regardless of scope params. All providers however, provide some form of a > user ID. As you can't simply use field hiding in Django models, I figure > that I can achieve this by one of the following two methods: > > 1. Copy/paste the entire model, changing the attribute of the one field. > 2. User._meta.fields[4].null = true > > #2, even though seemingly hacky at best seems to be the lesser of the two > evils as it at least keeps things DRY (and is potentially far less > maintenance down the road). > > My question is, is there another method of achieving this that I'm not > seeing? Preferably one that *isn't* hacky? > > Thanks, > Demian > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/jJNvP6ETRAsJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.