This is my code for 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'})
and this is my model 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'
When I'm running the code it shows:
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
Please help me out.I'm using django with gae. This is forms.py
class CategoryForm(forms.ModelForm):
name = forms.CharField(label='Category', widget=forms.TextInput(attrs={'size':50}))
class Meta:
model = Category
fields = ['name']
Here is the complete stack trace. http://dpaste.com/251985/