what you want to modify? On Thu, Jan 9, 2020 at 7:07 PM Wesley Montcho <wesleymont...@gmail.com> wrote:
> Hello > Thanks for helping me > I want to ask you something else, Should I create serializer.py or it is > some file I can modify > > Le jeu. 9 janv. 2020 à 13:59, Suraj Thapa FC <surajthap...@gmail.com> a > écrit : > >> Use try catch and send whatever response you want to send >> >> On Wed, 8 Jan 2020, 10:36 pm Soumen Khatua, <soumenkhatua...@gmail.com> >> wrote: >> >>> >>> *seriazlizers.py* >>> >>> >>> >>> >>> >>> >>> * email = >>> serializers.EmailField(required=True,validators=[UniqueValidator(queryset=User.objects.all())]) >>> phone_number = serializers.CharField(required = >>> True,validators=[UniqueValidator(queryset=User.objects.all())]) password >>> = serializers.CharField(write_only=True,required=True, >>> help_text='Leave empty if no change needed', >>> style={'input_type': 'password', 'placeholder': >>> 'Password'}* >>> * ) * >>> >>> *models.py* >>> >>> >>> >>> >>> >>> >>> >>> >>> * email = models.EmailField(_('email address'), unique=True) >>> phone_number = models.CharField(max_length=10,unique = True, >>> blank=False,default = uuid.uuid4().hex[:8]) >>> first_name = models.CharField(_('first name'), max_length=30) last_name >>> = models.CharField(_('last name'), max_length=30, blank=True) is_active >>> = models.BooleanField(_('active'), default=True) is_staff = >>> models.BooleanField(_('staff status'),default=False) date_joined = >>> models.DateTimeField(_('date joined'), default=timezone.now)* >>> >>> >>> I already did that but I want to raise validation error that email >>> should be unique and password should be alphanumeric character in json >>> format? >>> >>> On Wed, Jan 8, 2020 at 9:44 PM Suraj Thapa FC <surajthap...@gmail.com> >>> wrote: >>> >>>> For email you can set email field in model as unique=True and the >>>> password should be stored in hash.. >>>> >>>> On Wed, 8 Jan 2020, 9:37 pm Soumen Khatua, <soumenkhatua...@gmail.com> >>>> wrote: >>>> >>>>> Hi Folk, >>>>> >>>>> What is the process to validate fields in django rest framework? >>>>> like email and phone number should be unique and password should be >>>>> alphanumeric character only. >>>>> >>>>> Where i need to write the logic inside serializers or views part and >>>>> how i can do that? >>>>> >>>>> Thank you in advance >>>>> >>>>> Regards, >>>>> Soumen >>>>> >>>>> >>>>> -- >>>>> 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 view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/django-users/CAPUw6Wb7_45-r165wg10M-w%2B6V6zOheCnEC3_chbJ-GEHRGQLA%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/django-users/CAPUw6Wb7_45-r165wg10M-w%2B6V6zOheCnEC3_chbJ-GEHRGQLA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>>> 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 view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/CAPjsHcFKnaczwY-%3DKWqbPWrUuecv6YYWR19qPwSWmZpSYG%2BW0w%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/django-users/CAPjsHcFKnaczwY-%3DKWqbPWrUuecv6YYWR19qPwSWmZpSYG%2BW0w%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> 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 view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/CAPUw6WbDFeAtOxksdOijTOidX%3DW8gzCs38fN_nXMSK%3DLFxA1cg%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CAPUw6WbDFeAtOxksdOijTOidX%3DW8gzCs38fN_nXMSK%3DLFxA1cg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> 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 view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAPjsHcHcs2ogHe6bHJt44_0saVPsR1fgug0RrQ%3D%3DEQYJRJzwHQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAPjsHcHcs2ogHe6bHJt44_0saVPsR1fgug0RrQ%3D%3DEQYJRJzwHQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAGRNXvQ4mbVee3z6e4KWVfjqYojsBL24cg3Dqx%2BHRSRZsJOaBA%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAGRNXvQ4mbVee3z6e4KWVfjqYojsBL24cg3Dqx%2BHRSRZsJOaBA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WagNeCOMdnU0BBXRvrQv_CTsoQMCGK5GGojmAuQseuZ9Q%40mail.gmail.com.