Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Wednesday, January 29, 2014

Django Static files tutorial
1. Create a Django project and app, Edit settings.py 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 settings.py file with the value
"/home/notroot/django_tut/staticfiles/sfiles"
5. edit section in STATIC_ROOT in settings.py file with the value "/home/notroot/django_tut/staticfiles/files"
6. set the value for the variable in settings.py 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 settings.py.
9. Add a view in the views.py and update urls.py file
10. In the project root folder run the command "python manage.py 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

http://127.0.0.1:8000/staticfiles/
  
12 Download the tutorial from the github
Note: This is compatible with django 1.5.4

Tuesday, December 3, 2013

Django Helloworld tutorial
1. Install django from pip or apt-get/yum 2. Install mysql, python-mysqldb pacakge from apt-get/yum 3. Create database in mysql using steps mentioned in the url creating-database 4. Creating mysql user and granting database permissions to the created user using the steps mentioned in the url adding-users 5. Edit helloworld/settings.py for database settings [ Database(mysql), Database name, Database user, Database user password] 6. Run server in the helloworld directory python manage.py runserver
7. Open the url http:/127.0.0.1:8000/helloworld


8.Source Code can be downloaded from the github
https://github.com/Jadatravu/Tutorials/tree/master/django_tutorials/helloworld
Note: This tutorial is compatible with django 1.5.4, python 2.7.4