views:

45

answers:

1

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/

+2  A: 

Django does not support GAE currently. You have to use patched Django, for example, http://www.allbuttonspressed.com/projects/djangoappengine and then rewrite your model using standard django db model (currently you are using GAE one). However djangoappengine does not provide 100% compatibility.

Vladimir
Ohh.. I got it. Thanks a lot!
Shwetanka
@Shwetanka This would be a good opportunity to work on your accept rate. Under the vote count for this post, to the right, you will see a checkmark. click it. you will then have accepted this answer.
aaronasterling
Ok.. Thank you!
Shwetanka