Yeah, i know i'm a little messys with all that but thanks for the tipp. 

Could it be that you're Mail reader did something to the indentation because i 
am calling return inside the function or am i understanding you wrong ?!


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-----Ursprüngliche Nachricht-----

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Andre Terra
Gesendet: Montag, 04. Juli 2011 16:00
An: django-users@googlegroups.com
Betreff: Re: change values in "select list"

Don't take it personally, but while we're at it, I should tell you
that Classes have CamelCase names and functions are
lowercase_with_underscores. Try not to mix both unless you have an
incredibly compelling reason (which is not the case here).

For what it's worth, it will do you good to name everything in
English, even if it's not your native language. Python's keywords are
in English (if, while, for, class, return, break...) and sticking to
one language makes the code easier to maintain (you might have a
developer on your team who doesn't speak German) and readable for
those of us who can only speak a language or two.


Cheers,
Andre Terra

On 7/4/11, Andre Terra <andrete...@gmail.com> wrote:
> Hi, Patrick.
>
> Here are a couple of hints that will hopefully guide you in the right
> direction.
>
> It seems you are calling return from your class definition, when it is
> actually supposed to be used in a function.
>
> What happened to the label_from_instance function? Where it is supposed to
> go?
>
> I'll leave it to you to put two and two together. Consider it homework =)
>
>
> Cheers,
> André Terra
>
> On 7/4/11, Szabo, Patrick (LNG-VIE) <patrick.sz...@lexisnexis.at> wrote:
>> Okay i think i'm close but i can't figure it out.
>> I did this:
>>
>> class ReportingForm_ProduktField(ModelChoiceField):
>>     def label_from_instance(self, obj):
>>         return "My Object #%i" % obj.id
>>
>>
>> class ReportingForm_Produkt(ModelForm):
>>     Produkt = ReportingForm_ProduktField(Produkte.objects.all())
>>     class Meta:
>>         model = Buchung
>>
>> I've also tried this:
>>
>> class ReportingForm_Produkt(ModelForm):
>>     Produkt = forms.ModelChoiceField(ReportingForm_ProduktField,
>> Produkte.objects.all())
>>     class Meta:
>>         model = Buchung
>>
>> Could you plz tell me if i'm even close to the solution or maybe even
>> give
>> me a hint on what I'm doing wrong
>>
>> Sry but this is rly urgent
>>
>>
>> . . . . . . . . . . . . . . . . . . . . . . . . . .
>> Patrick Szabo
>>  XSLT Developer
>> LexisNexis
>> Marxergasse 25, 1030 Wien
>>
>> mailto:patrick.sz...@lexisnexis.at
>> Tel.: 00431 534521573
>> Fax: +43 (1) 534 52 - 146
>>
>>
>> -----Ursprüngliche Nachricht-----
>>
>> Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
>> Im
>> Auftrag von Tom Evans
>> Gesendet: Montag, 04. Juli 2011 13:10
>> An: django-users@googlegroups.com
>> Betreff: Re: change values in "select list"
>>
>> On Mon, Jul 4, 2011 at 11:46 AM, Szabo, Patrick (LNG-VIE)
>> <patrick.sz...@lexisnexis.at> wrote:
>>> I was afraid somethig like that would come.
>>> I did read the doc but i don't really understand it :-(
>>> Could you plz make it a little clearer for me  ?!
>>>
>>
>> You are using a model form. The model form has a model selection in
>> it. You want the select to have different labels.
>>
>> Labels on a model selection field come from the __unicode__ method of
>> the model, or from the label_from_instance of the model field class.
>>
>> Model forms allow you to specify the classes to use for each model
>> attribute.
>>
>> Hence:
>>
>> Define a new class derived from ModelChoiceField (not called
>> ModelChoiceField).
>> Add a label_from_instance method to the new class
>> Configure your ModelForm to use this new field instead of
>> ModelChoiceField
>>
>> All of this is explained in the docs. Read the docs.
>>
>> Tom
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
> --
> Sent from my mobile device
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to