Django-邮政编码问题

时间:2018-11-20 13:43:28

标签: django-models

我的models.py文件中的邮政编码存在问题。我得到了附件错误。有人可以帮我吗?Error Message

Models.py

from __future__ import unicode_literals
from django.db import models

# Create your models here.
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone


# Create your models here.
class UserProfile(models.Model):
    image = models.ImageField(upload_to='images', default='Upload Picture')
    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
    address1 = models.CharField(max_length=255, blank=True)
    address2 = models.CharField(max_length=255, blank=True)
    eircode = models.CharField(max_length=7, default="V93CY93")
    email = models.CharField(max_length=50, blank=True, null=True)
    phone = models.CharField(max_length=10, blank=True)
    dob = models.CharField(max_length=10, blank=True)
    gender = models.CharField(max_length=1, blank=True)

class KidProfile(models.Model):
    parent = models.ForeignKey(User, related_name='kids')
    name = models.CharField(max_length=255, null=True, blank=True)
    dob = models.CharField(max_length=10, null=True, blank=True)
    gender = models.CharField(max_length=1, null=True, blank=True)

    def __str__ (self):
        return self.name

1 个答案:

答案 0 :(得分:0)

您正在尝试将空值插入表中名为“邮政编码”的非空列中。您的“ UserProfile”模型类中没有邮政编码。