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?
Wim
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