Implementing filters in django for e-commerce website - django

I am implementing an e-commerce website using django. The product catalog will be big (hundreds of products). I would like to know how I should implement product filters in search.
E.g. let's say I put up about 30 products initially. The user might want to filter the search based on some product attributes like color, size, category, etc.
Is there any feature in django that enables building such features? If not, how should I go about it? Is querying the database everytime the user picks an attribute, the only approach?
Thanks.

I think you are looking for a faceted search.
Haystack should be the django app you are looking for.
Furthermore you could take a look at django-filter

Related

Advanced search in Django

I am working on a social blogging site using Django and I need to create an advanced search bar with filters like location and authors. I do have a basic one working as of now. Can someone help me with the concept on how to add filters to it. couldn't find much related stuff with django. Thanks
Assuming you want to retrieve data from a database, using the Django ORM, you can use the filter method of the Queryset class.
That said, we can't help you more without a context, how you expect the filters to behave, the models behind the scene, or anything more than "how to conceive an advanced search in Django"...

Filtering with elastic-search and django

I've configured elastic search within my django project. The next step is to apply some filtering options of those searches. The content of each search is Cars, so I'd like to be able to filter on Model, Price, Petrol/Diesel etc.
Any thoughts on how to achieve this?
Thanks,
EDIT: I'm using Haystack.

How do I add custom entities to Typo3 CMS?

In my project I need to add a lot of custom entities to Typo3 CMS.
Eg. I need to have Buildings, Building Companies, Architects, Certifications, and so on.
What is the common approach for doing this?
Should I develop a new extension?
How can I then have a custom backend for managing these entities? Eg. in the Buildings admin page I want to be able to add a new Building also associating one or more Architects to it. Is it feasible? How?
Can I create a custom backend field for looking up Architects in the Buildings admin page? (eg. something like StackOverflow tags system, a token input field which looks up for items in Architects table in real-time while editing a Building)
To map a business model into Typo3 I prefer to build an extension for that.
On the one hand you have the maximum flexibility by programming in PHP with the help of the Typo3 framework and on the other hand most of the backend management pages come in easy when using the standard MVC + TCA structure of Typo3 Extbase extensions (if it is your first try with Extbase you might want to have an Extbase book at hand).
You can have a look at the Typo3 TCA page to see which standard backend field types are available - there are shown a lot of example configurations. As in your case you might want to use a select field with property "size" > 1 and property "maxitems" > 1 to describe the relation between buildings and architects. As for the architects filter feature you might also want to add the property "enableMultiSelectFilterTextfield" as shown in this example.

How to make a dropdown menu to search in different models in django

I am new to django and I made a search engine , I want to add a dropdown menu in the template where user can choose the model to search in. What to write in the template and what to write in views.py is there is any need for forms.py ????
thanks for help
There are 2 solutions.
You can hardcode your models and filter statements on them directly into your Django view. This is ok if queries are not complex and there is not a lot of models.
Or you need an abstraction - a search layer over your Django models. There is a lot of different search engines: solr, sphinx, elastic search. In your case this can be for example Sphinx Search with django-sphnix plugin - it can aggregate different data sources and make them available for search.

how to build a gmail style search in django?

I want to build a gmail style search app for my site with configurable operators and entities. For example, gmail lets you type from: and then searches your email records by the from attribute. I want to do the same, but with e.g. ticket milestones or product descriptions, etc.
Any suggestions on how to get started? Should I try to leverage an existing project like django-haystack? Or should I try rolling my own, using more basic django features?
This would be fairly easy to implement in haystack - SearchQuerySets have a filter method much the same as django's querysets which you could use to filter on your custom parameters. Have a look at the searchqueryset docs for more.
To actually build the app, I'd write a custom SearchForm which parses parameter:value parts out of the query value, uses them to filter or search on the relevant attribute, and then uses any remaining keywords to search as per normal on the filtered searchqueryset (using SearchQuerySet.auto_query)