Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#15984 closed New feature (wontfix)

model fields options in Meta class

Reported by: Matt Harasymczuk Owned by: nobody
Component: Database layer (models, ORM) Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Move model fields options, such as:

  • blank=BOOL
  • null=BOOL
  • auto_add=BOOL
  • auto_add_now=BOOL
  • db_index=BOOL

and others boolean options to Meta class of this model.

It would make model fields more readable and human friendly.

it works for unique_together
why not to add:

unique = ('name', 'login', 'ssn')
db_index = ('name', 'login')
auto_add = ('signup_date', )
auto_add_now = ('last_mod', )
null = ('comment', 'first_name')
read_only = () # editable=False

... and so on ...

It was discussed at 2011-05-06 at Django-dev

Change History (2)

comment:1 by Aymeric Augustin, 13 years ago

Resolution: wontfix
Status: newclosed

In the discussion thread, there is a -1 from a core dev, a +1 from the community and some loosely-related talk.

From a practical point of view:

  • It is hardly possible to remove the current syntax for field options: that would be massively backwards incompatible. I haven't seen thoughts on how to handle this problem.
  • Having two ways to declare field options is unpythonic: "There should be one-- and preferably only one --obvious way to do it."

Based on these elements, I think this ticket falls in the "Django could be designed differently" bucket and I'll mark it as wontfix (it could be re-opened if the discussion on django-developers continues and Alex changes his mind).

comment:2 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

Note: See TracTickets for help on using tickets.
Back to Top