Tuesday, August 30, 2022

Re: What do you do with large project and forms?

You need to work with model forms, but not forms, in your templates implement crispy forms  to avoid over coding

On Wed, Aug 31, 2022, 03:03 Mike Dewhirst <miked@dewhirst.com.au> wrote:
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)



-------- Original message --------
From: Julio Cojom <jul.alejandro5@gmail.com>
Date: 31/8/22 03:42 (GMT+10:00)
Subject: What do you do with large project and forms?

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+unsubscribe@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.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/630ea50d.620a0220.480de.4507SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJkmis2wo7HzxxPPxPO3A9JgOcsrktpb0OGPRX4O0DwFA%2B3Q5w%40mail.gmail.com.

No comments:

Post a Comment