Django BD错误

时间:2015-05-26 20:48:43

标签: python django web

大家好我正在使用Django 1.7和mysql创建一个应用程序,我收到此错误

var ds = new kendo.data.DataSource({
  data: [{
      name: "John Doe",
      gender: "male",
      age: 33
  }],
  group:[{
      field: "gender"
  }]
});

ds.fetch(function(){
  var view = ds.view();
});

我不知道这是什么。这个错误发生在我的forms.py上,这里是代码: forms.py

ValueError at /Cannot create form field for 'radiotipo_idradiotipo' yet, because its related model u'Radioinfo' has not been loaded yet

这是我的models.py

from django import forms
from models import Node, Datasource, Radio, Radiotipo, Snapshot, Tag, Taginfo, Valores

class NodeForm(forms.ModelForm):
    class Meta:
        model = Node

class DatasourceForm(forms.ModelForm):
    class Meta:
        model = Datasource
class RadiotipoForm(forms.ModelForm):
    class Meta:
        model = Radiotipo
class SnapshotForm(forms.ModelForm):
    class Meta:
        model = Snapshot
class TagForm(forms.ModelForm):
    class Meta:
        model = Tag
class TaginfoForm(forms.ModelForm):
    class Meta:
        model = Taginfo
class ValoresForm(forms.ModelForm):
    class Meta:
        model = Valores
class RadioForm(forms.ModelForm):
    class Meta:
        model = Radio

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

radiotipo_idradiotipo是名为“RadioInfo”的模型的外键,但是您没有任何模型称为:只有一个名为“Radiotipo”。那是你的意思吗?

答案 1 :(得分:0)

变化:

radiotipo_idradiotipo = models.ForeignKey('Radioinfo', db_column='radioInfo_idRADIOINFO')  # Field name made lowercase.

人:

radiotipo_idradiotipo = models.ForeignKey('Radiotipo', db_column='radioInfo_idRADIOINFO')  # Field name made lowercase.

请注意,您使用table_name而不是Model_Name作为foreingkey