Hi,
I want to filter the dropdownlists that are automatically used to select
a foreign-key in forms (in my views).
Normally that could easily be done with "class Meta" in the Modelform.
Thing is i want to filter by an attribute of the current
userspecificly the groups that the user is as
As an option, you can pass a request.user to form's __init__ method from
your view. Example:
class YourForm(forms.ModelForm):
def __init__(self, user, *args, **kwargs):
self.user = user
super(YourForm, self).__init__(*args, **kwargs)
# here you can modify any self.field
Completely off topic but, what exactly does an "XSLT Developer" do?
On Thu, Apr 21, 2011 at 3:10 PM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:
> Hi,
>
>
>
> I want to filter the dropdownlists that are automatically used to select a
> foreign-key in forms (in my views).
>
> N
I have set the choices list in the view:
choices =
SomeModel.objects.filter(user=request.user).values_list('id','label')
Then, after the form is instantiated, modify the choices attribute of
the ChoiceField:
form = SomeOtherModelForm()
form.fields['model_dropdown'].choices = choices
so developing with Python ^^
Von: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] Im Auftrag von Cal Leeming
[Simplicity Media Ltd]
Gesendet: Donnerstag, 21. April 2011 19:02
An: django-users@googlegroups.com
Betreff: Re: filtering drop downs according to logged in user
Compl
se 25, 1030 Wien
mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573
Fax: +43 (1) 534 52 - 146
-Ursprüngliche Nachricht-
Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im
Auftrag von Dan Gentry
Gesendet: Donnerstag, 21. April 2011 21:05
An: Djan
-users@googlegroups.com [mailto:django-users@googlegroups.com] Im
Auftrag von Szabo, Patrick (LNG-VIE)
Gesendet: Freitag, 22. April 2011 09:10
An: django-users@googlegroups.com
Betreff: AW: filtering drop downs according to logged in user
Hi,
I like that idea.
I have a problem with implementing it
On Apr 21, 7:10 pm, "Szabo, Patrick \(LNG-VIE\)"
wrote:
> Hi,
>
> I want to filter the dropdownlists that are automatically used to select
> a foreign-key in forms (in my views).
>
> Normally that could easily be done with "class Meta" in the Modelform.
>
> Thing is i want to filter by an attrib
test
On Apr 21, 7:10 pm, "Szabo, Patrick \(LNG-VIE\)"
wrote:
> Hi,
>
> I want to filter the dropdownlists that are automatically used to select
> a foreign-key in forms (in my views).
>
> Normally that could easily be done with "class Meta" in the Modelform.
>
> Thing is i want to filter by an at
9 matches
Mail list logo