My personal webspace

A webspace for innovation, free thinking, and procrastination

These are just patterns which I’ve observed while working on various Django projects; they are not all-inclusive, and not actually rules, but all the same.

Regarding Templates

Your base template should define a ‘content’ block; this is where most of the page content goes. It should also have ‘breadcrumbs’, ’title’, ’extrajs’, and ’extrastyle’ blocks. The last of those goes in the section of the page, and is where apps can put references to stylesheets.

When working on an app, make sure templates and static files are placed in directories named after the app. For example, django_teams would store it’s templates in ‘$WORK_DIR/django_teams/templates/django_teams/’. This allows us to avoid overriding each others templates.

Regarding settings.py

Define a variable called “project_root” at the top of the file; use this to locate the template, static, and other directories. Newer Django apps put this in by default when using django-admin.py.

Import from local_settings.py, if available. This allows the server to override settings (such as SECRET_KEY) for production. Do NOT put this file in version control, or at least not public version control.

The End

That’s all that I can think of right now, tune back in later for more!


Content © 2022 Charles Hathaway