Search code examples
pythondjangodjango-viewsdjango-urls

Simple Django Project Structure


I have built the virtual environment and root directory for my django project, which will be a simple website for a event venue. The site will simply have a few different tabs on the navigation bar which shows the user some of the venue specifics which include pricing, a photo gallery, and the venue's history.

My problem is that there is so much conflicting information on the web concerning "The best practice for project structure".

Should I create an app for the home page and each of the pages that follow, or just create a core app that houses the majority of the project? If this is the case, is this project a good example? --> https://github.com/justdjango/django-ecommerce

Does anyone know of a simple project that I can reference?

Again this is a pretty simple project with only a few urls and no forms.

I would greatly appreciate anyone who has taken the time to read through this and help me.


Solution

  • in my opinion you just need one app let's call it web since it is used for website only. The steps I follow in creation of a simple project after creating repository and database and make it running is:

    1. Create static, media and templates folders
    2. python manage.py startapp web
    3. Add web in INSTALLED_APPS in settings.py file
    4. Put html files in templates folder and other folders(js,css,images,fonts..) in static folder
    5. Set URL to the new app in project_name > urls.py
    6. Create view for index page in web.views
    7. Create url to the view just created in web.urls
    8. Change every links of images, js and css files in index.html to static url as to use in python. {% load static %} is must
    9. The page will be loaded in localhost now.
    10. create other views and set urls in web app to other pages like about,contact and so on
    11. Create a list of models You will need and define them in web.models
    12. pass them to admin page by using web.admin
    13. Make it dynamic by passing data from models to templates.

    hope you get it right