Aug 022009

Django model : DB
1. Each model : a single database table
2. each attribute of the model : a column in the database table
3. attribute name : the column’s name
4. type of field (e.g., CharField) : database column type (e.g., varchar)
5. instance of model : row in the database table

Posted by weboom at 4:39 am Tagged with: , , , ,
Aug 022009

If you want to use Django’s database layer, i.e., model,
you need to create a Django app.

Posted by weboom at 4:34 am Tagged with: ,
Jul 252009

1. constants or list of choices
2. full list of fields
3. Meta class
4. __unicode__() method
5. save()
6. get_absolute_url()
7. any additional custom methods

Posted by weboom at 2:44 pm Tagged with: ,
Jul 022009

After you created your models, you need to tell django to use it.
To let django know that, you need to add your model name at INSTALLED_APPS in settings.py.
e.g.,
———
INSTALLED_APPS = (
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.sites’,
‘django.contrib.admin’,
‘myblogsite.myblogapp’,
)

Posted by weboom at 3:48 pm Tagged with: , ,
Jul 022009

Model
maps to a single database table.
Model
is about your data.
Model contains
1. fields
2. methods
Model is similar to the concept of class in other object-oriented programming.

Posted by weboom at 7:30 am Tagged with: , , , ,
Jun 262009

After you generate a model, if you register the model at admin site,
admin can create data based on your model design (even if you haven’t built the input page yet.)
————
e.g.,
from django.contrib import admin
from yourapp.models import Post
class PostAdmin(admin.ModelAdmin):
prepopulated_fields = {’slug’: (’title’,)}
admin.site.register(Post, PostAdmin)

Posted by weboom at 10:42 pm Tagged with: , , ,
Switch to our mobile site
Top Footer