Skip to content

testdrivenio/django-static-media-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static and Media Files in Django

Example repo for the Working with Static and Media Files in Django article.

Getting Started

  1. Clone down the repo

  2. Create and activate a virtual environment

  3. Install the dependencies:

    $ pip install -r requirements.txt
  4. Apply the migrations:

    $ python manage.py migrate

Development Example

$ python manage.py runserver

Production Example

  1. Set DEBUG to False in the settings.py file

  2. Then, collect the static files and run Gunicorn:

    $ python manage.py collectstatic
    $ gunicorn core.wsgi:application -w 1

This uses WhiteNoise to serve up the static files, so you'll need to add Nginx in order to handle media files appropriately.