I have two models: Director, and Film.
I want to create a web query form so that a user can search something like “All films from director ‘Steven Spielberg’ between 1990 and 1998”.
Just curious what the best and simplest way to do this would be?
Thanks,
OK the simplest solution is something like that.
I make some assumptions about the structure of your models, so
adjust accordingly.
Let’s say this is our models.py
Our naive views.py
Please keep in mind that I deliberately omit many sanity checks.
Our search_results.html template
Also read this on creating datetime objects from string
Edit: Oh I forgot about the urls.py and the actual form 🙂
in your url.py add something like this inside the urlpatterns.
Now the actual search form must be something like this:
You can generate it through a django form if you wish.
Anyway this is not going to get you far I guess. If you are doing
anything serious you might take a look into haystack