Hello everyone,
I'm a Django user for some years now, and I find myself tweaking the app 
structure after `./manage.py startapp foo`.

I try to modularize the code and keep things separated. For example I don't 
like form classes in `views.py`, or very long `tests.py` files (and after 
also the Django code is organized like this).

Sometimes, especially when developing an app/project in more than one or 
two people, some bad habits can kick in, like:
* I'll just declare this little form class in `views.py`, because a 
separate file only for this is too much
* I need another form class, but there is also the previous form class here 
in `views.py`, no reason to create a `forms.py` file and have some form 
classes here and some there
* Now `views.py` is a big file and the effort to refactor can be too 
overwhelming now, also because we have to ship the code (for 
murphy-law-esque reasons you'll think that you HAVE to refactor in the 
worst moment. Hence you WON'T refactor.)

And the entropy tends to rise and rise.

The same can go for a single `tests.py` file.

So I forked django and did a slightly different (cleaner, I think) 
app_template, and filed a ticket in the bug tracker.

The ticket: https://code.djangoproject.com/ticket/28307
The branch on my forked project: 
https://github.com/mcagl/django/tree/mcagl/better-startapp-template

It was then that I was directed to raise the question here in the 
developer's mailing list, so I'm trying to recap the proposals here (and I 
hope to have done everything correctly):

* New files: `forms.py`, `middleware.py`, `mixins.py`, `urls.py` to 
encourage the developer (that can be a newbie) to start with a separation 
of things that will pay in the long run (and to reinforce the architecture 
of Django itself in the developer's mind)
* Refactoring `tests.py` in a `tests` module, also to encourage modularity.

I was made aware of the `startapp` option to make it use a custom template, 
but I think that a cleaner template used by default by Django can be a 
benefit to instill what I think are good habits in the Django developer 
community.

What do you think about this proposal?

Kind regards,
Mark

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/0da65cd4-0496-4ec5-99b5-3d94e887dcb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to