Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15984 closed New feature (wontfix)

model fields options in Meta class

Reported by: haras 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:


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 Changed 5 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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 Changed 5 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

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