I have the following ENUM in my PostgreSQL database:
CREATE TYPE UserType AS ENUM ('Admin','Teacher', 'Student');
CREATE TYPE CourseType AS ENUM ();
I want to use this as one of the column-type in my tables, but how do I create this custom field in Django which uses the values in the ENUM type of PostgreSQL and not just use tuples like:
USER_TYPES = (
('A', 'Admin'),
('T', 'Teacher'),
('S', 'Student'),
)
usertype = models.CharField(max_length=1, choices=USER_TYPES)
as this will be locally saved in Django project and not in database. I plan to add more values in this ENUM so want the Django to use this type as a Field and not choices. How do I do that.