1

I don't understand when to make a new app or if I just gonna keep filling the models.py, views.py etc in the Django project. I made a Django project containing a "Question app".

I am going to administrate questions and users will be able to report, browse and add questions as well.

Do I make one app for the administrating page and one for the public or how? I am on python chat...

LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
  • 2
    have you read http://stackoverflow.com/a/4879205/1114171 or http://www.b-list.org/weblog/2006/sep/10/django-tips-laying-out-application/ – T I Feb 05 '12 at 13:14

1 Answers1

0

If you ask yourself the question "What does my app do?" and you can't answer with a single sentence, then you need to split it up into parts.

Generally however you will want to keep the management interface and the public interface in the same "app" however you can namespace them separately.

-- questions/
 |-- models.py # holds common models, imports models from backend/models.py
 |-- admin.py # admin interface'
 |-- frontend/
 | |-- urls.py
 | |-- views.py
 | `-- ...
 `-- backend/
   |-- urls.py
   |-- views.py
   `-- models.py # holds specialist models. set Meta: app_label = 'questions.backend'

A guiding principle of Aspect Oriented Programming is separation of concerns. This means you should try to keep your modules as small and focused as possible. They should do one thing and one thing only. Remember, the root models.py can import any number of models from child modules and they will be picked up by django as part of the app, so don't feel the need to store them all in the same place.

Thomas
  • 11,757
  • 4
  • 41
  • 57