Skip to content
Advertisement

Why am I getting django.db.models error telling me I have no attribute for TextChoices in Django (3.1.6) and Python(3.8)?

thanks so much for reading. I’ve got this running on my computer no problem. It’s working on my VS on Windows 10. But this error keeps coming up, it looks like TextChoices is no longer usable?

AttributeError: module ‘django.db.models’ has no attribute ‘TextChoices’

I’m putting it u0p on PythonAnywhere, Python 3.8, and Django 3.1.6 I am still new at this, so please forgive me1

My issue is with the TextChoices, here is the full error:

JavaScript

This is my models.py in the app directory

JavaScript

Advertisement

Answer

You can use choices this way:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement