Django.fun

Django model default value in response

I want to have a default value in my django model response value

Sample model query

myModel.objects.filter().values("username", "user_gender")

I want to have a default value in response

It must be like

Select username, user_gender, 'delhi' as country from mytable

Please let me know if any suggestions

You can add additional value to queryset using Value expression:

from django.db.models import CharField, Value

myModel.objects.filter().values("username", "user_gender", default_city=Value('delhi', output_field=CharField()))

You can find more details about values() method here.