WebFaction
Community site: login faq
0
1

Would like to ask how to achieve dynamic filtering in Admin. I know how to use django-smart-selects in admin but it works I guess only for FK not for many-to-many models.

I would like to achieve when I create an ART in the admin and select category it would filter only those artists which belong to that category & additionally when I select artist while creating Art it would filter those collections that belong to that Artist.

I can make Artists & Collections to work with django-smart-selects but artists & categories not because they are many-to-many.

Please help. Thanks

models.py

class Category(models.Model):
    title = models.CharField(max_length=200)
    title_url = models.SlugField(max_length=200)

    def __unicode__(self):
        return self.title

class Artist(models.Model):
    category = models.ManyToManyField(Category)
    title = models.CharField(max_length=200)
    title_url = models.SlugField(max_length=200)

    def __unicode__(self):
        return self.title

class Collection(models.Model):
    artist = models.ForeignKey(Artist)
    title = models.CharField(max_length=200)
    title_url = models.SlugField(max_length=200)

    def __unicode__(self):
        return self.title

class Art(models.Model):
    category = models.ForeignKey(Category)
    artist = models.ForeignKey(Artist)
    collection = models.ForeignKey(Collection)
    title = models.CharField(max_length=200)
    title_url = models.SlugField(max_length=200)

    def __unicode__(self):
        return self.title

asked 10 Apr '13, 15:16

rentgeeen
4721319
accept rate: 0%

edited 10 Apr '13, 15:20


The admin uses the ModelAdmin class to extend it. You will have to write your custom view code within it or read the section on Overriding Admin Templates and write custom views and admin code.

permanent link

answered 10 Apr '13, 17:31

johns
5.4k312
accept rate: 23%

I would like to use dropdown filtering (live filtering) while in admin just like django smart selects: https://github.com/digi604/django-smart-selects

but I am using many to many field that plugin doesnt support that. So I am looking for that kind of solution, I know I have to edit admin templates but my question if there is solution already or something, because for that that kind of purpose I need to use ajax jquery etc...

(10 Apr '13, 17:40) rentgeeen
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×30
×15
×8
×7

question asked: 10 Apr '13, 15:16

question was seen: 4,299 times

last updated: 10 Apr '13, 17:40

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM