On Monday, 12 September 2016 14:36:23 UTC+1, ashish...@finoit.co.in wrote: > > I've configured user's username field in following way > > username = models.CharField( > _('username'), > max_length=30, > unique=True, > help_text=_('Required. 30 characters or fewer. Letters, digits > and @/./+/-/_ only.'), > validators=[ > validators.RegexValidator( > r'^[\w.+-]+$', > _('Enter a valid username. This value may contain only ' > 'letters, numbers ' 'and ./+/-/_ characters.') > ), > ], > error_messages={ > 'unique': _("A user with that username already exists."), > }, > ) > > I'm getting error in admin panel but not in django-shell. > > > Though django raises an error for maximum length in shell. > > Is it a bug? Or am I missing something. >
This has nothing to do with being in the shell. Validators aren't run on save, and that is the case everywhere, as noted explicitly in the validators documentation: https://docs.djangoproject.com/en/1.10/ref/validators/#how-validators-are-run -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9fa63938-11d8-40ca-b3b5-d531aa295c9c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.