This is meant as a base template for new Django projects which uses poetry to manage its 3rd party packages. The project comes preconfigured for those packages:
[packages]
django = "*"
django-secrets = "*"
django-undeletable = "*"
django-extensions = "*"
dj-static = "*"
django-compressor = "*"
django-axes = "*"
sentry-sdk = "*"
pypugjs = "*"
django-post-office = "*"
uwsgidecorators = "*"
requests = "*"
pendulum = "*"
djangorestframework = "*"
[dev-packages]
black = "*"
django-debug-toolbar = "*"
django-livereload-server = "*"
"flake8" = "*"
fabric = "*"
ipdb = "*"
djdt-flamegraph = "*"
Furthermore, this project template includes a hello world with PUG templates, SASS styles and VueJS showing off a minimal reactive page featuring chuck norris facts which made me click reload a few dozen times while coding this example app. :P
Here is a list of what's installed for the frontend:
- VueJS - the base JS framework
- sentry - error reporting for the frontend
- lodash - the missing javascript functions
- axios - AJAX calls
- Buefy - VueJs UI framework mirroring all Bulma features including Material Design Icons
This is only recommended as long as you only want to spice up your pages with a lil reactivity, tho.
In case you want to build a more complex frontend, please consider using the Django rest framework and
and start building a dedicated frontend with vue ui
(more detailed instructions here).
For smaller projects it has proven to be more efficient to have the frontend checked in as a subfolder in the
backend repo so that you always have the matching backend and frontend code together without messing with
version conflicts
Contrary to Django the project has a flat settings hierarchy so you can do the following:
- Alice and Bob set an environment var pointing to their own settings like "settings.bob"
- When starting a new project they just have to copy setting/dev.py and change it to their liking
- When switching and working on multiple projects, everybody can have their own setting checked into the project and automatically using em without the need to remember to activate "<project_name>.settings.whatever" (influenced by the really cool TwoScoops of Django)
Django-secrets will keep your secrets really secret and help you with your deployment so that you only need to initialize your secret environment variables. Also works super easy with i.e. Travis CI.
All assets and templates are stored in their top level folders .. yes i know it's not portable that way, but most of the time I don't build portable apps. I create projects that are meant to be running at customers and never see the public light, and thus they shall be clean without the need to remember which assets are hidden in which sub folders. The styles.sass in compiled on the fly and thanks to the wonderful livereload-server changes will be visible right away in your browser (as well as code changes to python files).
Once the settings file is fed with the needed credentials all errors (python and javascript) will be caught by Sentry.io for error handling.
misc/setup_repo.sh will setup the current repo with a flake8 commit hook to always commit clean code only. :D
wsgi.py is patched with the awesome dj-static lib, so you don't necessarily need to remember to serve static files separately unless you really want to.
The project template features a ready to use fabfile which will grant you some basic tasks like:
- fab deploy which will push your content and restart uwsgi
- fab migrate which will push updates, updating packages, migrating the DB, compressing files, collecting static files and finally restart the server for you.
Hope i didn't forget any gem inside .. have fun with this project template!
django-admin.py startproject \
--template=https://github.com/kakulukia/django-default-project/zipball/master \
<new project name here>
cd <repeat the new project name>
poetry install
PS: You need poetry to install this projects requirements.
You can pip install poetry
if you don't have it already. I really tried pipenv, but it let me down so many times now.