Skip to content

Traviskn/django_starter_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Readme

WARNING: The last time I worked with this template was in September 2015, some things may be out of date

This is a cookiecutter template for Django 1.8 and Python 3.4. I use it for many of my personal projects.

Features

  • 12 factor app style configuration with python-dotenv and dj-database-url. Modular settings and requirements easily handle differences between development and production.

  • Fully functioning local registration and authentication using Django built-in views.

  • Pre-configured social authentication for Facebook, Twitter, and Google using python-social-auth.

  • Modern password hashing with bcrypt.

  • A custom user model, which can be easily further customized.

  • Simplified production ready static file serving with whitenoise.

  • Modern front-end tooling with Webpack.

  • ES 2015 and beyond with Babel.

  • Tomorrow's CSS today with cssnext, powered by PostCSS, the next generation CSS transformer.

  • Nicely styled pages with Bootstrap.

  • Efficient database connection pooling with django-postgrespool.

  • Pre-configured file storage for user uploaded media with Amazon S3 and django-storages

  • Procfile for Heroku deployment.

Setup

  1. Get Python version 3.4 and setup a virtual environment for your project.

  2. Get cookiecutter, run it on this template, then follow the prompts.

$ pip install cookiecutter
$ cookiecutter https://github.com/Traviskn/django_starter_template.git
  1. Install your new Django project's development requirements:
  • Install the required python packages:
$ pip install -r requirements/development.txt
  • Get Node and install the required JavaScript libraries:
$ npm install
  1. Create a .env file and fill out the required environment variables. You probably shouldn't track it in version control, so I've added it to the .gitignore for you already.
  • You will need to configure your database and put its access url in the .env file. If you're on a Mac, I highly recommend postgres.app.
  • You need to head over to the developer consoles for Facebook, Twitter, and Google to register your app then get tokens and secrets for each provider that you can put into your .env file. You can enter some dummy values for now if you'd rather do this later.
  • Here's an example .env file you might use for development:
DJANGO_SETTINGS_MODULE=mysite.settings.development
DATABASE_URL=postgres://username:password@host:port/dbname
TWITTER_KEY=PutYourKeyHere
TWITTER_SECRET=PutYourSecretHere
FACEBOOK_KEY=key
FACEBOOK_SECRET=secret
GOOGLE_KEY=key
GOOGLE_SECRET=secret
  1. Take a look at accounts/models.py and make any customizations you need to the User model.

  2. Make migrations then run migrations.

  3. You will need to run both the Django development server and the Webpack development server. Open up two terminal windows and enter these commands:

# in the first terminal window
$ python3 manage.py runserver
# in the second terminal window
$ npm run dev
  1. Now if you head to localhost:8000 in your browser you should be able to see a nice "Hello World!". You should also be able to sign up for an account and log in and out. Try editing the javascript or css files and your changes should appear in the browser without a refresh.

  2. For deployment you will need to build the static assets with the following command before running collectstatic:

$ npm run build

About

An opinionated starter template for django projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published