> How do you feel about having a default max_length value for a
> models.CharField, so we can use it like:
> class MyModel(models.Model):
> example = models.CharField()
>
> What are the pros and cons?
I'm pretty -1 against it.
Pros:
+ you get to be lazy in one particular use-case, for whatever
default is chosen
Cons:
- that default has to be chosen -- who is to say it should be?
2? 5? 10? 20? 42? 50? 100? Every case requires its own
consideration, and thus it should be specified as a parameter
- it's fairly easy to create your own CharField subclass that
defaults to whatever you want. Untested, it would be something like
MY_ARBITRARY_DEFAULT_LENGTH = 42
class MyCharField(CharField):
def __init__(self, *args, **kwargs):
if 'max_length' not in kwargs:
kwargs['max_length'] = MY_ARBITRARY_DEFAULT_LENGTH
super(MyCharField, self).__init__(self, *args, **kwargs)
Since everybody's bikeshed tends to be a slightly different color
of 42, and it only takes about 6 lines of code to make your own
shed and paint it, the savings isn't that great to be worth
putting it in Django core, IMHO.
-tkc
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.