testdrivenio / django-static-media-files

Working with Static and Media Files in Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Working with Static and Media Files in Django

License:MIT License


Languages

Language:Python 86.9%Language:HTML 12.0%Language:CSS 1.1%