glegroups.com] On
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:51 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?
Am 04.04.19 um 16:23 schrieb Matthew Pava:
> If you need a default year in your template context, put it there.
>
>
Am 04.04.19 um 16:23 schrieb Matthew Pava:
> If you need a default year in your template context, put it there.
>
> def get_context_data(self, request, *args, **kwargs):
> context = super().get_context_data(request, *args, **kwargs)
> context['default_year'] = 2019
> return context
>
Am 04.04.19 um 16:24 schrieb Matthew Pava:
> And, since you really don't want constants littering your code, you probably
> want something like this:
> context['default_year'] = timezone.now().year
Sure, thanks, but the year was only used to keep the example code minimal and
the focus on how to
Sent: Thursday, April 4, 2019 9:12 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?
To elaborate on this further:
Searching the web for this yields numerous hits, e.g.
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
construct:
{{ year or default_year }}
-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:12 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?
To el
To elaborate on this further:
Searching the web for this yields numerous hits, e.g.
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
mentions some ways to address this, but I've not come across a fully
satisfactory solution.
Another approach might be thi
Hello,
Am 03.04.19 um 21:28 schrieb Mohammad Etemaddar:
> Set default value:
> year = forms.ChoiceField(required=False, choices=[(j, j) for j in range(2018,
> 2021)], default=2019)
Thanks for your reply, but unfortunately, `default` is a keyword for model
fields only, not for form fields:
TypeE
On Tuesday, April 2, 2019 at 2:12:50 PM UTC-7, Carsten Fuchs wrote:
>
> Dear Django group,
>
> I would like to show users a form that they can use to customize the view,
> for example a ChoiceField from which the year of the report can be chosen.
> It seems straightforward to use a forms.Form
Set default value:
year = forms.ChoiceField(required=False, choices=[(j, j) for j in range(2018,
2021)], default=2019)
You do not need clean_year any more I think.
On Wednesday, April 3, 2019 at 1:42:50 AM UTC+4:30, Carsten Fuchs wrote:
> Dear Django group,
>
> I would like to show users a form
9 matches
Mail list logo