姜戈装置。 JSON解码错误
我有一个 Django 项目,我想将测试数据添加到数据库中。当我像这样制作syncdb时
python ~/django/foo/manage.py syncdb
安装表后出现错误
Problem installing fixture '~/django/foo/shop/fixtures/initial_data.json':
Traceback (most recent call last):
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
我的模型在这里:
# -*- coding: utf-8 -*-
from django.db import models
class Image(models.Model):
file = models.ImageField(upload_to = "img/")
title = models.CharField(
max_length=128,
blank = True
)
slug = models.SlugField(max_length=128, blank = True)
def __unicode__(self):
return unicode(self.title)
我的固定装置是这样的:
[
{
"pk": 2,
"model": "shop.image",
"fields": {
"slug": "",
"file": "img/8_m.jpg",
"title": "1"
}
}
]
问题出在哪里?
I've a Django project and I want to add test data to database. When I make syncdb like this
python ~/django/foo/manage.py syncdb
After tables are installed I've got an error
Problem installing fixture '~/django/foo/shop/fixtures/initial_data.json':
Traceback (most recent call last):
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
My model is here:
# -*- coding: utf-8 -*-
from django.db import models
class Image(models.Model):
file = models.ImageField(upload_to = "img/")
title = models.CharField(
max_length=128,
blank = True
)
slug = models.SlugField(max_length=128, blank = True)
def __unicode__(self):
return unicode(self.title)
My fixture is this:
[
{
"pk": 2,
"model": "shop.image",
"fields": {
"slug": "",
"file": "img/8_m.jpg",
"title": "1"
}
}
]
Where is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大胆猜测...也许你的装置文件保存为 unicode 文件???尝试在最简单的文本编辑器中打开它,或者运行
并确保转储中的第一个字符是
5b
而不是fe
或其他字符。Wild guess... maybe your fixture file is saved as a unicode file??? Try to open it in the simplest text editor you can, or run
and make sure the first character in the dump is
5b
notfe
or something.