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 indirection here.
The model definition itself is supposed to
be canonical (dynamic model tricks aside).

No, I think Wolfram's approach is conceptually correct.
If it looks dirty then that's a matter of API cosmetics.
If it's inefficient then that's a matter of optimization.

Rule of thumb: If you want information about the
model then ask the model.

> 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=max_link_url_len)
> 
> :)



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to