What do you do with large project and forms?

22 views
Skip to first unread message

Julio Cojom

unread,
Aug 30, 2022, 1:42:31 PM8/30/22
to django...@googlegroups.com
I have a large project and forms.py per app is bigger than I thought with 3k+ lines in each file, I'm looking for options to make a good scalation structure, does anyone have experience with this? What do you do to organize your forms in your projects?

Danish Nagori

unread,
Aug 30, 2022, 2:43:16 PM8/30/22
to django...@googlegroups.com
Yes

On Tue, 30 Aug 2022, 10:41 pm Julio Cojom, <jul.ale...@gmail.com> wrote:
I have a large project and forms.py per app is bigger than I thought with 3k+ lines in each file, I'm looking for options to make a good scalation structure, does anyone have experience with this? What do you do to organize your forms in your projects?

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHRQUHnd2zdPeaOmw2VzWhP2y1xN%3Dv2Z%2BQ%2B%2BsSw1B10AuxEnjA%40mail.gmail.com.

Mike Dewhirst

unread,
Aug 30, 2022, 8:03:16 PM8/30/22
to django...@googlegroups.com
1. Create a forms directory
2. Create ../forms/__init__.py
3. Move your forms.py into the forms directory
4. In ./__init__.py write from .forms import (
  FormThis,
  FormThat,
  EtcForm,
)

This gives you unchanged forms calling from wherever ... from appname.forms import etc

5. When all that is working split your 3k forms.py into appropriately named smaller files each containing the form class or classes you prefer and adjust the ./__init__.py imports accordingly

You might encounter occasional circular imports but you should get the hang of it soon enough.

Cheers

Mike



--
(Unsigned mail from my phone)

--

Paul serubombwe

unread,
Aug 31, 2022, 1:33:42 AM8/31/22
to Django users
You need to work with model forms, but not forms, in your templates implement crispy forms  to avoid over coding

subin

unread,
Sep 1, 2022, 3:01:48 PM9/1/22
to django...@googlegroups.com

subin

unread,
Sep 1, 2022, 3:03:48 PM9/1/22
to django...@googlegroups.com
Hi there! We just wanted to let you know we received your message and will be in touch before our offices close at

subin

unread,
Sep 1, 2022, 3:04:27 PM9/1/22
to django...@googlegroups.com
Hello! We’re currently getting more texts than usual. We’ve received your message and will respond as soon as we can. Thank you for your patience.

subin

unread,
Sep 1, 2022, 3:05:46 PM9/1/22
to django...@googlegroups.com
Please let me know if that is acceptable with you.Please let me know if that sounds okay.Please let me know if that sounds okay.Please let me know if that sounds okay.

On Tue, Aug 30, 2022 at 6:42 PM Julio Cojom <jul.ale...@gmail.com> wrote:
I have a large project and forms.py per app is bigger than I thought with 3k+ lines in each file, I'm looking for options to make a good scalation structure, does anyone have experience with this? What do you do to organize your forms in your projects?

--
Reply all
Reply to author
Forward
0 new messages