django-admin.py startproject mysite
chmod +x manage.py
./manage.py runserver
http://127.0.0.1:8000
control + c (quits the development web server)
- - - - - - - - - - - - - - - - - - - - - - - - - - -
cd mysite/mysite
notepad/nano mysite/mysite/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mysite.db'
...
TIME_ZONE = 'UTC'
...
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
- - - - - - - - - - - - - - - - - - - - - - - - - - -
notepad/nano mysite/mysite/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)
- - - - - - - - - - - - - - - - - - - - - - - - - - -
cd ..
./manage.py syncdb (if necessary creates the sqlite file and database tables)
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no):
yes , Enter the username, email, and password of the super user of the database
(django already includes a built in user database)
./manage.py runserver
http://127.0.0.1:8000 => Page not found (404) (ONLY ^admin URL is enabled)
http://127.0.0.1:8000/admin (login with your super user and password)
control + c (quits the development web server)
- - - - - - - - - - - - - - - - - - - - - - - - - - -
./manage.py startapp blog
cd blog
notepad/nano blog/models.py
from django.db import models
class Post( models.Model ):
title = models.CharField( max_length = 100 )
body = models.TextField()
created = models.DateTimeField()
def __unicode__( self ):
return self.title
# pip install django-taggit
- - - - - - - - - - - - - - - - - - - - - - - - - - -
notepad/nano blog/admin.py # creating this file to register with Django Admin
from django.contrib import admin
from blog.models import Post
admin.site.register( Post )
- - - - - - - - - - - - - - - - - - - - - - - - - - -