lit*_*m84 17 mysql django json fixtures dumpdata
当我尝试将数据转储到我的实时服务器上的Djanog 1.2.1中的JSON夹具时,我收到错误.在实时服务器上,它运行MySQL Server版本5.0.77,我使用phpMyAdmin接口将大量数据导入到我的表中.该网站工作正常,Django管理员正常响应.但是,当我尝试实际转储与表对应的应用程序的数据时,我收到此错误:
$ python manage.py dumpdata --indent=2 gigs > fixtures/gigs_100914.json
/usr/local/lib/python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
Error: Unable to serialize database: Location matching query does not exist.
Run Code Online (Sandbox Code Playgroud)
我正在尝试转储的'gigs'的Django模型在models.py文件中看起来像这样:
from datetime import datetime
from django.db import models
class Location(models.Model):
name = models.CharField(max_length=120, blank=True, null=True)
class Meta:
ordering = ['name']
def __unicode__(self):
return "%s (%s)" % (self.name, self.pk)
class Venue(models.Model):
name = models.CharField(max_length=120, blank=True, null=True)
contact = models.CharField(max_length=250, blank=True, null=True)
url = models.URLField(max_length=60, verify_exists=False, blank=True, null=True) # because of single thread problems, I left this off (http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.URLField.verify_exists)
class Meta:
ordering = ['name']
def __unicode__(self):
return "%s (%s)" % (self.name, self.pk)
class Gig(models.Model):
date = models.DateField(blank=True, null=True)
details = models.CharField(max_length=250, blank=True, null=True)
location = models.ForeignKey(Location)
venue = models.ForeignKey(Venue)
class Meta:
get_latest_by = 'date'
ordering = ['-date']
def __unicode__(self):
return u"%s on %s at %s" % (self.location.name, self.date, self.venue.name)
Run Code Online (Sandbox Code Playgroud)
就像我说的,Django对数据很好.该网站工作正常,关系似乎运行得非常好.当运行命令以获取SQL Django正在使用的内容时:
$ python manage.py sql gigs
/usr/local/lib/python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
BEGIN;CREATE TABLE `gigs_location` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(120)
)
;
CREATE TABLE `gigs_venue` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(120),
`contact` varchar(250),
`url` varchar(60)
)
;
CREATE TABLE `gigs_gig` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`date` date,
`details` varchar(250),
`location_id` integer NOT NULL,
`venue_id` integer NOT NULL
)
;
ALTER TABLE `gigs_gig` ADD CONSTRAINT `venue_id_refs_id_3d901b6d` FOREIGN KEY (`venue_id`) REFERENCES `gigs_venue` (`id`);
ALTER TABLE `gigs_gig` ADD CONSTRAINT `location_id_refs_id_2f8d7a0` FOREIGN KEY (`location_id`) REFERENCES `gigs_location` (`id`);COMMIT;
Run Code Online (Sandbox Code Playgroud)
我已经对数据进行了三次检查,确保导入后确保所有关系和数据都正常.但是我仍然得到这个错误,三天......我一直坚持要做些什么.我无法想象"贬值警告"会成为一个问题.我真的需要将这些数据作为JSON转发回来.
非常感谢任何帮助.
And*_*ard 18
可能是类似的东西这个.
运行它:
python manage.py dumpdata --indent=2 -v 2 --traceback gigs
Run Code Online (Sandbox Code Playgroud)
要查看潜在的错误.
归档时间: |
|
查看次数: |
11413 次 |
最近记录: |