On Sat, Aug 8, 2009 at 8:37 PM, Chao Xu<coodysk...@gmail.com> wrote:
>
> I want't to add search in admin site and followed the instructions of
> official guide of The Django admin site. But nothing on admin site
> changed, nor errors appeared after I changed my code.
>
> following is my code, please help me. Thank you in advance!
>
> entity.models.py code ===================
> from django.db import models
> from django.contrib.auth.models import User
> import datetime
>
> class University(models.Model):
>    name = models.CharField(max_length=100)
>    abbreviation = models.CharField(unique=True, max_length=50)
>
>
> entity.admin.py code ====================
> from entity.models import *
> from django.contrib import admin
>
> class UniversityAdmin(admin.ModelAdmin):
>    list_display = ('name', 'abbreviation')
>    search_fields = ['name']
>
> admin.site.register(University)
>
> >
>

Your problem is you registered your Model with the admin without
telling it about your custom ModelAdmin class, so it used the default
one.  The last line should be.

admin.site.register(University, UniversityAdmin)

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to