'Django PostgreSQL ArrayField does not work
I have just switched to PostegreSQL. Now whenever I add the following code to my Custom User Model, the database is broken, no new values are added to the database, for example during registration
from django.contrib.postgres.fields import ArrayField
class NewUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(_('Email'), unique=True)
username = models.CharField(max_length=150, unique=True)
start_date = models.DateTimeField(default=timezone.now)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
last_login = models.DateTimeField(default=timezone.now)
code = models.ImageField(blank=True, upload_to='code',)
#part that breaks the databse:
ip_addresses = ArrayField(
models.CharField(blank=True), default=list)
From the moment also no more migrations are recognized. Or I get something like this
django.db.utils.ProgrammingError: column "ip_addresses" does not exist
LINE 1: ...ER COLUMN "ip_addresses" TYPE varchar(15)[] USING "ip_addres...
What error I get is 50 50 chance but atleast the first error is always here.
I also tried this which did not work either
ip_addresses = ArrayField(
models.CharField(max_length=15), default=list)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
