A django project skeleton for easy setup on a LAMP server! Under development...
- Ready project skeleton for development.
- Logging/Debugging custom implemented.
- For Python 3.+
- Based on Django 1.8 project structure.
- Better Security with 12-Factor recommendations.
- Ready for a MySQL database!
This uses Django's admin startproject function to fetch the code from this Git: Note: by default the --template argument expects .py file types, use the --extension argument to also add README, html code and so forth to your project. Remove these if you don't want the README in your code (ideally you would though for completeness).
django-admin startproject --template=https://github.com/albert118/django-skeleton/archive/master.zip --extension=py,md,html,env my_proj
Changemy_proj
to whatever name you want! This will also change the relevant documentation and variable names within the settings files.cd my_proj
Then, copy the sample.local.env file (call it local.env)cp my_proj/settings/local.sample.env my_proj/settings/local.env
. If you have any issues, just delete and go back to the sample one.- Setup a MySQL server, see number 3. If you're new to MySQL or need a refresher then read the bits before.
- Setup a user for Django to use when making migrations. Consider at this point whether there will be a remote or a local access to the database. Make sure a client is running before doing this!
mysql -u root -p //Windows
./mysql -u root -p //Mac OS X
Create a new user called "djangoadmin", which can login from localhost (or your IP, or add a wildcard (%) for any - although this is less secure!), with password "your_password":mysql> create user 'djangoadmin'@'localhost' identified by 'your_password';
- Now give your djangoadmin account permissions. Django will need at least
CREATE, DELETE, INSERT, SELECT, UPDATE.
DROP is also reccomended if you plan on ever squashing your migrations (i.e. it's advised to avoid a headache later!).mysql> grant CREATE, DELETE, INSERT, SELECT, UPDATE, DROP on *.* to 'djangoadmin'@'localhost';
Check that the user has been added.mysql> SELECT host, user FROM mysql.user;
mysql> quit
- Then edit your local.env file with the appropriate settings for your database (login details, source port, etc...). MySQL runs default on port 3306. Check your server's ip with ip addrr (unix esque) or ipconfig (Windows).
- Now cd back over to your project directory, so you can use manage.py:
python manage.py migrate
to create your initial migrations. - Now add all of your code & you're good to go!
Take a look at the docs for more information. Also checkout: Python Django
This project currently borrows heavily from the Edge project. Partially for the structure, but also for the logging and settings configuration.