Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin's filter_horizontal (& filter_vertical) not working

I'm trying to use ModelAdmin.filter_horizontal and ModelAdmin.filter_vertical for ManyToMany field instead of select multiple box but all I get is:

My model:


class Title(models.Model):
    #...
    production_companies = models.ManyToManyField(Company, verbose_name="компании-производители")
    #...

My admin:


class TitleAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("original_name",)}
    filter_horizontal = ("production_companies",)
    radio_fields = {"state": admin.HORIZONTAL}
    #...

The javascripts are loading OK, I really don't get what happens. Django 1.1.1 stable.

like image 516
negus Avatar asked May 05 '10 12:05

negus


People also ask

How do I access my Django admin page?

To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).

Where is Django admin template?

To view the default admin template you can access it in the django/contrib/admin/templates/admin folder.

What is Django admin password?

Run 'python manage.py migrate' to apply them. Username (leave blank to use 'chatru'): admin Email address: [email protected] Password: Password (again): The password is too similar to the username.


1 Answers

I finally got the solution. The problem was with the field's verbose name - it was str instead of unicode. Moving to unicode helped.

Thanks :-)

like image 195
negus Avatar answered Oct 23 '22 09:10

negus