How to modify Django admin filter’s title

You will need to have a custom filter class, but you can actually implement a custom filter class factory that you can use everywhere you just need a filter with a custom title: from django.contrib import admin def custom_titled_filter(title): class Wrapper(admin.FieldListFilter): def __new__(cls, *args, **kwargs): instance = admin.FieldListFilter.create(*args, **kwargs) instance.title = title return instance return … Read more

ImportError: No module named django_filters

My pip version was old, really old. 1.5.6 When I installed my virtual environment it just worked, so I didn’t question. Lesson learned! Here is what I did in case it helps someone else… In the virtual environment, I installed pip as described in the docs: https://pip.pypa.io/en/stable/installing.html python get-pip.py This upgraded me to pip 6.1.1 … Read more

How to use “AND” in a Django filter?

For thoroughness sake, let’s just mention the Q object method: from django.db.models import Q criterion1 = Q(question__contains=”software”) criterion2 = Q(question__contains=”java”) q = Question.objects.filter(criterion1 & criterion2) Note the other answers here are simpler and better adapted for your use case, but if anyone with a similar but slightly more complex problem (such as needing “not” or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)