Wednesday, January 29, 2014

Django Static files tutorial
1. Create a Django project and app, Edit for database settings
2. Place the static files "files1.txt", "files2.txt" in the directory for example "/home/notroot/django_tut/staticfiles/sfiles"
3. create the directory files in the path for example "/home/notroot/django_tut/staticfiles/"
4. edit section  STATICFILES_DIRS in file with the value
5. edit section in STATIC_ROOT in file with the value "/home/notroot/django_tut/staticfiles/files"
6. set the value for the variable in STATIC_URL = '/static/'
7. write a template in the template dir for example index.html
{% load staticfiles %}
  <a href="{% static 'files1.txt' %}">link1</a>
  <a href="{% static 'files2.txt' %}">link2</a>
8. update the TEMPLATE_DIRS option in the
9. Add a view in the and update file
10. In the project root folder run the command "python collectstatic"
out put would be

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes

0 static files copied, 73 unmodified.
11. run the server, access the url from the browser
12 Download the tutorial from the github
Note: This is compatible with django 1.5.4