Hi,
On Jan 20, 5:49 pm, Janne Kuuskeri wrote:
> > You can use a custom ModelChoiceField and override itslabel_from_instance()
> > method:
>
> > class SizeOptionChoiceField(ModelChoiceField):
> > deflabel_from_instance(self, obj):
> > return obj.code
>
> Sorry, I'm a bit late to the
> You can use a custom ModelChoiceField and override itslabel_from_instance()
> method:
>
> class SizeOptionChoiceField(ModelChoiceField):
> deflabel_from_instance(self, obj):
> return obj.code
Sorry, I'm a bit late to the game but i just ran into this thread and
wanted to ask that
Gents,
I cannot thank you enough for all your help. The community here is
great and makes a n00b like me feel welcome.
Happy New Year!
Best regards,
Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Google Ap
I initially implemented using __str__ (without much thought). Then in
some cases, started seeing unicode decode errors in template views if
a user inputs international characters. Switching to __unicode__
resolved this category of issues.
That was the practical difference, for me, between __st
> > your suggestions to override methods worked a treat. Overriding at the
> > Model level suits me very well as it gives me flexibility. One final
> > question (I hope): what is the difference in overriding the
> > __unicode__ and __str__ methods?
>
> Unless you're actually dealing with Unicode t
On Mon, Dec 29, 2008 at 12:24 AM, Martynas Brijunas wrote:
>> Nice one! The alternative is to define a __str__ method on your
>> SizeOption class, since that is what is used to render the options in
>> the default label_from_instance implementation.
Oops. I read Alex's email too quickly. He sug
Hi Alex/David,
> Alternatively, you can override the __unicode__ method of your model:
>
>class SizeOption(db.Model):
>code = db.StringProperty(required = True)
>html = db.StringProperty(required = True, multiline = True)
>
>def __unicode__(self):
>return self.code > > You ca
On Sun, Dec 28, 2008 at 9:02 AM, Alexander Kojevnikov
wrote:
> You can use a custom ModelChoiceField and override its
> label_from_instance() method:
Nice one! The alternative is to define a __str__ method on your
SizeOption class, since that is what is used to render the options in
the default
> thank you very much for your suggestion to use the RefrenceProperty. I
> am halfway there now. The Product form now displays a dropdown.
> However, I am not really clear on how to specify what will be
> displayed in that dropdown. Here is what it is displaying currently
> when you open a dropdow
Hi Consultuning/David,
> You probably want to use a ReferenceProperty to a Colour entity in
> your Product model. Then, customise your form something like this:
>
> class ProductEntryForm(djangoforms.ModelForm):
> class Meta:
> model = Product
>
> colour = djangoforms.ModelChoiceField(Col
On Sat, Dec 27, 2008 at 10:07 PM, Martynas Brijunas wrote:
> Why am I doing this? It is because I want to use it with the
> db.djangoforms.ModelForm class. If I have a list of choices for a
> field, the ModelForm automatically gives me a dropdown. If there is no
> list of choices all I get is a
I think that the best way to address your problem would be using a
ReferenceProperty to another object type where you list all the colors
you wish to present as choices, does that work?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to t
12 matches
Mail list logo