Search code examples
djangomodels

how to search in django models if some fields are not required


so in my models i've got blank=True fields. I also have search in this model, but if some fields are blank=True user can not fill this fields. And what should I do if some fields are empty?

For example I have model with name and surname(blank=True). If surname not fill in search form i should make one filter, but if surname is fill I should make FILTER with surname?


Solution

  • Well, I have a really ridicules situation. In my model I make some fields blank=True and forgot to do makemigrations! So don't forget to make migrations