N
N
NotProblem2014-12-11 20:06:14
Django
NotProblem, 2014-12-11 20:06:14

What is the correct way to search through Django models?

Good afternoon, dear residents!)
How to organize a search by models in a view:

class Group(models.Model):
    name = models.CharField(u'Название', max_length=255)
    def __unicode__(self):
        return self.name

class Direction(models.Model):
    ...
    group = models.ForeignKey(Group )

class items(models.Model):
    code = models.CharField(verbose_name=u'Код', max_length=10)
    name = models.CharField(u'Название', max_length=255)
    direction = models.ForeignKey(Direction)
    color = models.ManyToManyField(ColorObjects)

All three models are associated with ForeignKey, and the last items is still associated with ManyToManyField with ColorObjects
The filtering process itself will be by ColorObjects, that is, an ajax request will come with an id (ColorObjects) array, as a result it should display all three models, and be passed to the template where the loop will be a tree is built taking into account the filter by ColorObjects

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2014-12-11
@FireGM

Something like django-ajax-selects?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question