Posts

Showing posts with the label Django

[Level 2] How to create Django project and apps by command mode.

How to create a Django project and apps by command mode, please follow the below commands: # django-admin.py startproject myProject # cd ./myProject # django-admin.py startapp myApp1 # cd ./myApp1 # python manage.py runserver [0.0.0.0:]8888 Wish this helps. regards, Stanley Huang

[Level 3] South for Django 1.2

in south project: http://south.aeracode.org/docs/databaseapi.html#database-specific-issues South automatically exposes the correct set of database API operations as south.db.db ; it detects which database backend you’re using from your Django settings file. It’s usually imported using: from south.db import db If you’re using multiple database support (Django 1.2 and higher), there’s a corresponding south.db.dbs dictionary which contains a DatabaseOperations object (the object which has the methods defined above) for each database alias in your configuration file: from south.db import dbs dbs [ 'users' ] . create_table ( ... ) You can tell which backend you’re talking to inside of a migration by examining db.backend_name - it will be one of postgres , mysql , sqlite3 , pyodbc or oracle . It should worth to try~ Wish this helps. regards, Stanley Huang

[level 3] Customize Django Data Type Field.

I cannot fine char data type in Django 1.2 beta 1 . So I try to build up my own data type field. My sample code as following: from django.db import models # Create your models here. from django.db.models import * #from django.db import connection #from django.db.models.fields.subclassing import LegacyConnection #from django.db.models.query_utils import QueryWrapper #from django.conf import settings #from django import forms #from django.core import exceptions, validators #from django.utils.datastructures import DictWrapper #from django.utils.functional import curry #from django.utils.itercompat import tee #from django.utils.text import capfirst from django.utils.translation import ugettext_lazy as _ #from django.utils.encoding import smart_unicode, force_unicode, smart_str #from django.utils import datetime_safe # Create your models here. # This is a much more flexible example. class myCharField(Field):     def __init__(self, *args, **kwargs): ...

[Level 1] Install Django on CentOS 5.4

Just following the steps to install Django on CentOS 5.4 # yum install subversion # cd $APACHE_HOME # mkdir django-src # cd django-src # svn co http://code.djangoproject.com/svn/django/trunk/ # cd trunk # python setup.py install Wish this helps. regards, Stanley Huang