小编sha*_*ank的帖子

您试图在没有默认值的情况下向contact_info添加不可为空的字段"id"

我只是使用简单的命令python manage.py makemigrations

但是,我得到的只是这个错误:

You are trying to add a non-nullable field 'id' to contact_info without a default;
we can't do that (the database needs something to populate existing rows). Please select a fix:
1) Provide a one-off default now (will be set on all existing rows)
2) Quit, and let me add a default in models.py
Run Code Online (Sandbox Code Playgroud)

这是models.py:

class Document(models.Model):
    docfile = models.FileField(upload_to='documents/')


class contact_number(models.Model):
    contact_numbers= models.CharField(max_length=13)

class contact_address(models.Model):
    address = models.CharField(max_length=100)
    city = models.CharField(max_length=50)
    state = models.CharField(max_length=50)
    zip = …
Run Code Online (Sandbox Code Playgroud)

python django django-models python-2.7

15
推荐指数
2
解决办法
3万
查看次数

RabbitMQ def回调(通道,方法,属性,主体)

只想知道worker.py文件中的参数名称含义:

def callback(ch, method, properties, body):
    print " [x] Received %r" % (body,)
Run Code Online (Sandbox Code Playgroud)

ch,方法,属性意味着什么?

rabbitmq pika python-pika

6
推荐指数
1
解决办法
1820
查看次数

适用于移动设备和台式机的Django WebApp

我用django制作了Web应用程序,它在桌面浏览器上看起来非常不错,但是在移动浏览器中,某些页面看起来并不完美。我的模板目录是myproject/template/我想要为移动浏览器创建新模板,myproject/template_mobile/并且每当网页通过移动设备访问时,它就会重定向到myproject/template_mobile/模板,否则它将进入低谷myproject/template/。有没有什么办法,使之形成setting.pydecorates?我不想改变整体的观点和旧模板。

提前致谢。

python django mobile django-templates

3
推荐指数
1
解决办法
4446
查看次数