How to quickly start a django project in rails way

Situation:

You want to create a scaffold,
Project’s name is “another”, with a application ‘blogs’ in it,
‘blogs’ application has a model named Post, which has
a string field named ‘title’,
a text field named ‘body’,
a boolean field named ‘is_public’.
You also want a api binded with the Post model.
The application should have full CRUD function(Create, Remove, Update, Detail)

Preparing:

requirement.txt:

Django==1.5.1
Markdown==2.3.1
PIL==1.1.7
PyYAML==3.10
South==0.8.1
defusedxml==0.4.1
django-filter==0.6
-e git://github.com/fortable1999/django-generate-scaffold.git#egg=django_generate_scaffold
django-oauth-plus==2.1.2
django-oauth2-provider==0.2.6
djangorestframework==2.3.6
gunicorn==17.5
httplib2==0.8
oauth2==1.5.211
shortuuid==0.3
wsgiref==0.1.2

save above lines into a requirement.txt file,
then:

pip install -r requirement.txt

Howto:

1. Start a Django project from zero:

django-admin.py startproject another
cd another/

2. Edit setting.py:

vim another/settings.py

Fix here:

'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'dev.db',

uncomment this:

'django.contrib.admin',

add these lines into APPS_INSTALLED:

'generate_scaffold',
'rest_framework',
'south',
'blogs',

add there lines to setting.py:

REST_FRAMEWORK = {
    # Use hyperlinked styles by default.
    # Only used if the `serializer_class` attribute is not set on a view.
    'DEFAULT_MODEL_SERIALIZER_CLASS':
    'rest_framework.serializers.HyperlinkedModelSerializer',
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
        'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
    ]
}

3. Create a empty application:

django-admin.py startapp blogs

6. open a url pattern to application:

vim another/urls.py

uncomment these lines:

from django.contrib import admin
admin.autodiscover()
url(r'^admin/', include(admin.site.urls)),

add there new url pattern:

url(r'^', include('blogs.urls')),

4. create scaffold:

python manage.py generatescaffold blogs Post title:string body:text is_public:bool

5. edit application’s sub urls.py:

vim blogs/urls.py

add there lines after import part:

from django.conf.urls import include
from rest_framework import viewsets, routers
from models import Post
class PostViewSet(viewsets.ModelViewSet): 
    model = Post 
router = routers.DefaultRouter() 
router.register(r'posts', PostViewSet)

then add this into urlpatters:

url(r'api/', include(router.urls)),

6. prepare development envionment database:

python manage.py syncdb
python manage.py schemamigration --initial blogs
python manage.py migrate blogs

7. testing project:

python manage.py runserver

Project done!

References:

Django Rest Framework: http://django-rest-framework.org/
Django generate scaffold: https://github.com/fortable1999/django-generate-scaffold