Monday, April 8, 2019

Re: Custom forms in Django admin?

Hi Kevin


Staying within the admin, you can create your own form class (forms.ModelForm) and specify it in the ModelAdmin declaration. See also django modelforms.

As you can see from the docs there is a lot you can do. I recommend leaving Admin to do most of the work. I do, however, use my own ModelForm instead of the default ModelAdmin form to override the `clean()` method (modelforms (validation)). With a custom form, I can do a more comprehensive validation of the user's input. 

hope this helps

-erik

 



On Monday, April 8, 2019 at 4:26:12 AM UTC-5, Kevin Olbrich wrote:
Hi!

Is it possible to add a form to the Django admin?
Models are no problem but I have a slightly more complex requirement (still less than a full view with templates, etc.).

Kind regards
Kevin

--
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+unsubscribe@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/eafd3583-b151-4a29-9546-c2ebcde2a8d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment