[Python] You are trying to add a non-nullable field 'new_field' to userprofile without a...

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    I know that from Django 1.7 I don't need to use South or any other migration system, so I am just using simple command python manage.py makemigrations

    However, all I get is this error:

    You are trying to add a non-nullable field 'new_field' to userprofile without a default;
    we can't do that (the database needs something to populate existing rows).


    Here is models.py:

    class UserProfile(models.Model):
    user = models.OneToOneField(User)
    website = models.URLField(blank=True)
    new_field = models.CharField(max_length=140)


    What are options?

    Continue reading...

Compartilhe esta Página