python - In Django, correctly making a queryset with multiple categories, multiple tags and search? -


I have a list of data in this data model for many-to-many categories of categories and a keyword model There are fields. The name and description of the data model is. The data can contain several categories and keywords.

At the front end, the user can select several categories to filter the data or search ... if the data shown should be with any data, any of the selected categories Also, if the 'A' and 'Test Data 2' category 'B' is in 'Test Data 1', if the user chooses to watch 'A' and 'B', then both of the data will display fragments. Searching for keywords related to search title, description, and data means that if a class is selected, it will search what data is omitted after categories are asked.

I'I am not an expert in jigs ... I am trying to prepare the best way to do this. I do not want to resort to using something like Haystack, because my data is actually very simple I have found that the filter on the object is basically giving me more in the underlying SQL, which works for categories Not ideal for. It seems I need some kind or ... The category selection on the front part is done with a form and therefore the data that comes back is basically a list of the selected categories ['A', 'B', 'C'] ... Is there no way Is that I can leave it as a search in the Django and give any one of these or any of these categories?

Many thanks!

Not sure what you mean here you can try something with these lines: Import from / p>

  django.db.models q query = 'fun' books = Fun.objects.filter (Q (categories__id__in = [1,2,3]), Q (name__icontains = query) | \ Q (description__icontains = query) | \ Q (keywords__title__icontains = query))  


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -