Where would I put that code? Is there a way to do it when the Admin form is 
initialized?

On Monday, April 24, 2017 at 5:31:18 PM UTC-5, Todor Velichkov wrote:
>
> I think a simple redirect can fix your problem.
>
> Something like this:
>
> if 'lang' not in request.GET:
>     q = request.GET.copy()
>     q.setdefault('lang', 'en')
>     return redirect('%s?%s' % (request.path, q.urlencode()))
>
>
>
>
> On Monday, April 24, 2017 at 7:12:18 PM UTC+3, Nate Granatir wrote:
>>
>> In my app I have admin filters for a field called "language" - language 
>> is a field in several of my models - and I've created them custom, 
>> inheriting from SimpleListFilter, so that I can apply a default of English 
>> when none has yet been specified. This works almost perfectly - the only 
>> problem is that if I do it this way, by altering the queryset in the admin 
>> filter when the user has not selected an option, the parameter is not 
>> displayed to the user in the GET paramaters of the URL, which I worry is 
>> confusing to the user. 
>>
>> Is there any way to solve this problem? Essentially I want to apply a 
>> default admin filter and have that filter appear in the URL as if it were 
>> chosen by the user. I am open to alternative solutions if anyone has done 
>> something like this before, even if it means a solution other than using a 
>> custom admin filter (e.g. some way of applying default GET parameters 
>> before the request is passed to the admin page.)
>>
>> Thanks.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64824070-5d41-4ec6-8ac4-8713b686233a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to