0

请任何人告诉我为什么在下面保存此模型时收到此消息我环顾四周发现有类似问题但有很多解决方案的人。

Exception Type:     DatabaseError
Exception Value: value too long for type character varying(10)
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py in execute, line 52


class Stylesheet(models.Model): 
    text_color = models.CharField(max_length = 50,default = '#000')
    a_visited = models.CharField(max_length = 50,default = '#000')
    background = models.CharField(max_length = 50,default = '#000')
    content_background_color = models.CharField(max_length = 50,default= '#000')
    nav_color = models.CharField(max_length = 50,default = '#000')
    nav_background = models.CharField(max_length = 50,default = '#000')
    nav_gradient_start = models.CharField(max_length = 50,default = '#000')
    nav_gradient_end = models.CharField(max_length = 50,default = '#000')
    nav_a_color = models.CharField(max_length = 50,default = '#000')
    nav_a_hover_color = models.CharField(max_length = 50,default = '#000')
    nav_a_hover_background = models.CharField(max_length = 50,default = '#000')
    nav_a_hover_gradient_start = models.CharField(max_length = 50,default = '#000')
    nav_a_hover_gradient_end = models.CharField(max_length = 50,default = '#000')
    slug = models.SlugField(max_length = 255,blank=True,null = True,editable=False)

    class Meta:
            db_table = 'stylesheet'
            verbose_name = 'Style sheet'
            verbose_name_plural = 'Style sheets'

    def __unicode__(self):
            return self.slug

    def save(self):                   
            super(Stylesheet, self).save()
4

1 回答 1

1

您的应用程序中的哪一行是第 52 行?

问题似乎是您在数据库字段上设置了 10 个字符限制,并且您试图将其传递给大于 10 的值

有关更多信息,请参阅此 SO 问题奇怪的 PostgreSQL“对于类型字符变化(500)的值太长”

于 2013-02-13T03:19:10.820 回答