mailman_73
mailman_73

Reputation: 798

What is a right way of creating apps into django project? (doubts about file location)

I have doubts about a right file location into a django project.

Prologue

Let's imaging, I'm going to create an ecommerce web app "consumer-to-consumer". One user can sell something and other one can buy it. Even though the app is big, assume that it contains a detail page of the product and a page with list of products. A user can add, delete, update images of his product. The app helps him resize images, put some filters and effects. Moreover, a user can add comment about any product, review, image, seller, and he can send comments to support e.t.c. If a user have a lot of products the app automatically create a XML feed which will be sent to another "consumer-to-consumer" websites to increase shows of the user's ads and increase sales.

Development

Firstly, I start project and than start app "products". The question is: should I create an own app for comment or images or a xml feed? Or should I put all code into products/forms.py and products/views.py of "product".

The first variant is:

project
  products
    views.py
    models.py
    forms.py
    ...

The second one is:

project
  products
    templates
    views.py
    models.py
    forms.py
    ...
  comments
    templates
    views.py
    ...
  xml_feed
    templates
    views.py
    ...

Question What is the best approach to it? What rules do you use to understand that this stuff is for one app and this isn't?

Upvotes: 0

Views: 118

Answers (1)

augustomen
augustomen

Reputation: 9759

A Django apps is usually a self-contained group of configurations, classes, views, templates and urls (all optional, of course), although it always has dependencies. They may be inserted or removed from a project at will.

Given that definition, it makes sense to question: Does the next implementation refer to a functionality of my current app? Or is it a complete new thing?

As a helper, think of the Django administration site: Is it logical to put your new models inside the same group (app)? Or should it be a new set of models?

Three Django apps: Auth, Examples and Sites

Upvotes: 1

Related Questions