How to create form??

25 views
Skip to first unread message

Ansari Sabir

unread,
Sep 23, 2018, 11:52:00 AM9/23/18
to Django users
How to create a form that collect information (like first name, last name, email address, contact number, gender) and admin can see that information in the /admin/ in django.

Jani Tiainen

unread,
Sep 23, 2018, 12:09:21 PM9/23/18
to django...@googlegroups.com
Hi.

If you have done the official tutorial, part 4 is all about this exact problem.


su 23. syysk. 2018 klo 18.51 Ansari Sabir <ansa...@gmail.com> kirjoitti:
How to create a form that collect information (like first name, last name, email address, contact number, gender) and admin can see that information in the /admin/ in django.

--
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/71966989-c435-4d68-968b-6f36bdf4b34f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mateusz

unread,
Sep 23, 2018, 12:31:03 PM9/23/18
to Django users
This may not seem simple, but it is.
1) You need a model with all the fields (docs),
2) Register that model to be visible on admin page (docs),
3) Create a forms.py file inside your app folder and form class inside that file (docs),
4) Create a simple template, it needs to have specific name or that name must be specified in a view from point 4 (same docs page as in 3),
5) Handle the form in views.py by adding a class-based FormView (docs),
6) Add the specific url to urls.py.

For more info about template creation visit: https://simpleisbetterthancomplex.com/article/2017/08/19/how-to-render-django-form-manually.html
Reply all
Reply to author
Forward
0 new messages