Re: Passing the max_length from the Model into the Form

2007-11-23 Thread Wolfram Kriesing
really good idea. I will add constants to the model-classes and refer to them via the model.FIELD_MAX_LENGTH thx Wolfram On Nov 23, 2007 11:59 PM, leotr <[EMAIL PROTECTED]> wrote: > > Yes, not only it's dirty but it's ineffective as well! > > Declare a constant somewhere and use it in bot

Re: Passing the max_length from the Model into the Form

2007-11-23 Thread Mark Green
On Fri, 2007-11-23 at 14:59 -0800, leotr wrote: > Yes, not only it's dirty but it's ineffective as well! And your idea violates DRY. > Declare a constant somewhere and use it in both model and form. And where would that "somewhere" be? Custom constants on the model? I see no point in adding in

Re: Passing the max_length from the Model into the Form

2007-11-23 Thread leotr
Yes, not only it's dirty but it's ineffective as well! Declare a constant somewhere and use it in both model and form. max_link_url_len = 80 class Link(models.Model): url = bla_bla_field(max_length = max_link_url_len) class myForm(forms.Form): url = forms.URLField( max_length=m

Passing the max_length from the Model into the Form

2007-11-23 Thread Wolfram Kriesing
What I am doing currently is: class myForm(forms.Form): url = forms.URLField( max_length=Link._meta.get_field('url').maxlength ) is this really the django-way to pass the maxlength into the form, when i build the form by hand? looks pretty dirty -- cu Wolfram --~--~-~--~-