There's no requirement that you use views.py, or any of the file names that
are created using 'django-admin.py', and you can create as many others as
you like. You can run an entire Django project from a single file if you
were so inclined. All of the file name references are just for convention
and ease of entry into learning Django.

You can break them out using separate files in the same directory, maybe
having a separate base.py (or use a name that makes sense), and then using
relative import statements like 'from .base import <class or function>'.

Alternatively, you can have python package folders that contain your code,
and those don't even need to be in the same folder, just somewhere along
your python path.

There's no right answer, it really comes down to what makes the most
logical sense to you and how your code is broken up inside of your views.py
file and how easily you can separate and organize the different portions of
code (monolithic class definitions vs. heavy sub-classing, etc.).

Do some googling for python project layout. These might be good resources
for ideas:

http://blog.apps.chicagotribune.com/2010/03/08/advanced-django-project-layout/

https://github.com/pydanny/cookiecutter-django/blob/master/README.rst

-James
On May 12, 2015 4:06 PM, "Karim" <lemieli...@gmail.com> wrote:

> Hello everyone! I have a huge views.py about 1200 lines. I would like to
> split it in different files moving some classes. Do you have any suggestion
> on how handle the import/dependencies in the project?
>
> Thanks
>
> --
> Karim N. Gorjux
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACeuRGUbeDHZ8B_4xhqdCu59vBLMGB4G1EFT60MQoh79sRRynA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACeuRGUbeDHZ8B_4xhqdCu59vBLMGB4G1EFT60MQoh79sRRynA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUEvu08kxYQRTnSP6vyHU68vpWgV-ZGYFCNQdCt0cW2dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to