这是我的views.py
代码def addCategory(request):
user = users.get_current_user()
if users.is_current_user_admin():
if request.method == 'POST':
form = CategoryForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
Category.objects.create_category(cd['name'])
return HttpResponseRedirect('/admin/dashboard/')
else:
form = CategoryForm()
temdict = {'form': form, 'title': 'New Category'}
return render_to_response('new_category.html', temdict)
else:
return render_to_response('not_admin.html', {'admin': 'no'})
这是我的模型models.py
class Category(db.Model):
catid = db.IntegerProperty(required=True)
name = db.StringProperty(required=True)
def get_absolute_url(self):
return "/tag/%s/" % str(self.catid)
class Meta:
verbose_name = 'Category'
当我运行它显示的代码时:
Exception Type: AttributeError
Exception Value:
type object 'Category' has no attribute '_meta'
Exception Location: D:\shwetanka\projects\shwetanka\django\forms\models.py in fields_for_model, line 166
Python Executable: C:\Python26\pythonw.exe
请帮帮我。我正在使用django和gae。 这是forms.py
class CategoryForm(forms.ModelForm):
name = forms.CharField(label='Category', widget=forms.TextInput(attrs={'size':50}))
class Meta:
model = Category
fields = ['name']
这是完整的堆栈跟踪。 http://dpaste.com/251985/
答案 0 :(得分:2)
Django目前不支持GAE。你必须使用修补的Django,例如http://www.allbuttonspressed.com/projects/djangoappengine,然后使用标准的django db模型重写你的模型(目前你正在使用GAE)。然而,djangoappengine不能提供100%的兼容性。