SemanticUI
SemanticUI

Reputation: 937

How to structure a very small Django Project?

It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project.

Upvotes: 1

Views: 473

Answers (3)

knbk
knbk

Reputation: 53669

If you only have static views, you can use the following setup:

  • A settings file
  • urls.py
  • templates/ folder
  • wsgi.py

You can use a TemplateView to direct any url to the appropriate (static) template:

from django.views.generic import TemplateView

urlpatterns = [
    url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'),
    ...
]

Then point the ROOT_URLCONF setting to your urls.py, and add the templates/ folder to your TEMPLATES setting. Add any other required settings such as SECRET_KEY or ALLOWED_HOSTS, and configure your wsgi.py.

Upvotes: 3

Michael Yousrie
Michael Yousrie

Reputation: 1142

Frankly I won't use Django in that case, I would use Flask for such small projects. it's easy to learn and setup a small website.

PS: I use Flask in small and large apps!

Upvotes: 1

outoftime
outoftime

Reputation: 765

meaning it's really static

Use nginx to serve static files. Do not use django. You will setup project structure when it will be required.

Upvotes: 3

Related Questions