Django on Ubuntu
Django | The Web framework for perfectionists with deadlines
Settings it up:
sudo apt-get install django
Check out the options of the command django-admin
Start s project
hemanth@ubuntu:~/django$ django-admin startproject mysite
hemanth@ubuntu:~/django$ cd mysite
hemanth@ubuntu:~/django$ ls
__init__.py manage.py settings.py urls.py
This is the basis of the application
manage.py => application we use to RUN certain commands.
setting.py => The default settings file called, settings.py
urls.py => It allows us to describe via a regex where to direct http requests.
Startapp
hemanth@ubuntu:~/django/mystie$ ./manage.py startapp myblog
hemanth@ubuntu:~/django/mystie$ cd myblog ; ls
__init__.py models.py tests.py views.py
__init__.py => runs when the app is loaded.
models.py => This is where we describe our database structure.
views.py => This is how we describe how our data is shown to the user.
Unlock admin panel
In urls.py [ uncommenting ]:
# from django.contrib import admin
# admin.autodiscover()
(remove the #)
and also from the #(r'^admin/',include(admin.site.urls)),
In settings.py [ INSTALLED_APPS should have 'django.contrib.admin'] :
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
)
SyncDB [ Create's if not present ]:
P.S : The settings.py must have DB detials, for the easy of it let it be sqllite3
DATABASE_ENGINE = 'sqlite3'
hemanth@ubuntu:~/django/mysite$ ./manage.py syncdb
Start Server
hemanth@ubuntu:~/mystie$ ./manage.py runserver
Validating models...
0 errors found
Django version 1.2 alpha 1 SVN-12205, using settings 'mystie.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Got to http://127.0.0.1:8000/admin
P.S : For people in <3 with Drupal have look at pinax
Recent blog posts
- watir-webdriver web inspector
- gem list to gemfile
- Packing ruby2.0 on debian.
- Made it into The Guinness Book!
- to_h in ruby 2.0
- Filter elements by pattern jQuery.
- Better HTML password fields for mobile ?
- Grayscale image when user offline
- nth-child CSS pseudo-class Christmas colors
- EventEmitter in nodejs