Showing posts with label django. Show all posts
Showing posts with label django. Show all posts

Saturday, May 5, 2012

[Django] Add CSS files

I can't find any tutorial that specifically tells what how to add CSS files on Django project so after a long adventure and a lot of readings and trial and errors here how I did it:

1. open your settings.py and locate the MEDIA_ROOT and MEDIA_URL
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'

If you're wondering what is os.path.join and PROJECT_ROOT then I'll explain it.

On top of the file (settings.py) add the following code:
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))

so based on the codes above, os.path.join and PROJECT_ROOT gets the current path where your project was located in your drive/server/etc.

The "media" is simple the folder where your css files will be saved.

moving on...

[Django] Create a Super User manually

Whenever the database was first sync, it will prompt if you want to create a super user but what if somewhere in the future you want to create another super user without creating one from the admin view?

Using the terminal, go to your project folder then use the following code:
python manage.py createsuperuser

After that code, you will be prompted to enter your username, email and password.

You now have created a super user account manually and using the terminal!

Wednesday, April 18, 2012

[Django] Know Your Django Version

There are cases where you want to know what version of Django was installed in your machine.
Here's how to know such:
import django
django.VERSION
note that VERSION are all in capital letters

Result:
(1, 4, 0, 'final', 0)


By the way, in case you want to know what's the latest version
import django
django.get_version()

Result:
'1.4'
Related Posts Plugin for WordPress, Blogger...