Single place for validation

14 views
Skip to first unread message

Harsh Gundecha

unread,
May 27, 2019, 10:20:48 AM5/27/19
to Django users
hello,
i am currently learning django and i have query as following
is it that we have  to put validators in both the model definition and form validation to apply validation to both admin and user site ?
i tired on reusing a form class assuming that the validator there would apply on both user and admin site but it didnt happen.


in short,
i would like to define validation at one place and get them applied on both user and admin site

Thank you
Regards, Harsh

Chetan Ganji

unread,
May 27, 2019, 10:54:35 AM5/27/19
to django...@googlegroups.com
If you have customized the forms for the user facing website,
you have to specify the same forms in the class extended by admin.ModelAdmin. 

Below answer is what you are looking for.

 
Regards,
Chetan Ganji
+91-900-483-4183


--
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...@googlegroups.com.
To post to this group, send email to django...@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/8a5280cf-d52b-4a7d-8e21-0d18a741f02a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexis Roda

unread,
May 27, 2019, 4:26:06 PM5/27/19
to django...@googlegroups.com
Hi,
an approach that comes to mind would be defining validation in the model and using model forms[1] for the user site.


HTH


Missatge de Harsh Gundecha <harsh.g...@gmail.com> del dia dl., 27 de maig 2019 a les 16:20:
--

Harsh Gundecha

unread,
Jun 3, 2019, 6:30:03 AM6/3/19
to Django users
yes i did the same, and got it working
Thank you 


On Tuesday, May 28, 2019 at 1:56:06 AM UTC+5:30, Alexis wrote:
Hi,
an approach that comes to mind would be defining validation in the model and using model forms[1] for the user site.


HTH


Missatge de Harsh Gundecha <harsh....@gmail.com> del dia dl., 27 de maig 2019 a les 16:20:
hello,
i am currently learning django and i have query as following
is it that we have  to put validators in both the model definition and form validation to apply validation to both admin and user site ?
i tired on reusing a form class assuming that the validator there would apply on both user and admin site but it didnt happen.


in short,
i would like to define validation at one place and get them applied on both user and admin site

Thank you
Regards, Harsh

--
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...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages