Opened 4 years ago

Closed 4 years ago

#29756 closed Bug (fixed)

Missing information about model field name restriction

Reported by: zdpx Owned by: nobody
Component: Documentation Version: 2.1
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

Documentation available at https://docs.djangoproject.com/en/2.1/topics/db/models/#field-name-restrictions says, that there are only 2 restrictions on naming model fields:

  1. A field name cannot be a Python reserved word
  2. A field name cannot contain more than one underscore in a row

I've found another restriction: field name can't ends with underscore, because it generates error during making migrations:

 (fields.E001) Field names must not end with an underscore.

Change History (2)

comment:1 Changed 4 years ago by zdpx

Summary: Missing information aboutMissing information about model field name restriction

comment:2 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In d483a5f:

Fixed #29756 -- Doc'd that model field names can't end with an underscore.

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