Search This Blog

Monday, September 21, 2009

Django, Admin Interface

add 'django.contrib.admin to INSTALLED_APPS in settings.py

run python manage.py syncdb (because you've installed a new application to update the db)

in the urls.py, uncomment the lines for admin, and uncomment the url pattern for admin

then you can go to /admin/ and log in

To tell the admin to use your model, create an admin.py in your my_model directory
from mysite.my_model.models import your_model_method
from django.contrib import admin

admin.site.register(your_model_method)


Then restart your server.

You can customize your model with your "to string" like method. In your admin.py under your model,

class ideaAdmin(admin.ModelAdmin):
list_display = ('title', 'description')

admin.site.register(idea, ideaAdmin)


----------------------
you can easily change the "django" in the admin interface. just make an "admin" directory in your "template" directory,
and then copy the base_site.html from django/contrib/admin/templates/admin to your admin directory.

read more:
http://docs.djangoproject.com/en/1.0/intro/tutorial02/

No comments: