#34360 closed Bug (duplicate)

Django development server doesn't reload on TypeError of a CharField

Reported by: dimyG Owned by: nobody
Component: Database layer (models, ORM) Version: 4.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

If you add "required=True" in the tier CharField below, a TypeError exception is raised and development server doesn't reload.
Maybe this is related with https://code.djangoproject.com/ticket/30500

class User(AbstractUser):
    tier_choices = (
        (Tiers.free, 'Free'),
        (Tiers.basic, 'Basic'),
        (Tiers.premium, 'Premium'),
    )

    tier = models.CharField(max_length=10, choices=tier_choices, default=Tiers.free, required=True)
  File "d:\Projects_D\web_ai\auth\auth_src\auth_app\models.py", line 9, in <module>
    class User(AbstractUser):
  File "d:\Projects_D\web_ai\auth\auth_src\auth_app\models.py", line 16, in User
    tier = models.CharField(max_length=10, choices=tier_choices, default='free', required=True)
  File "d:\Projects_D\web_ai\auth\py3107\lib\site-packages\django\db\models\fields\__init__.py", line 1121, in __init__
    super().__init__(*args, **kwargs)
TypeError: Field.__init__() got an unexpected keyword argument 'required'

Change History (1)

comment:1 by Mariusz Felisiak, 22 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #5245, see comment.

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