Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:04:26+00:00 2026-06-18T04:04:26+00:00

Trying to use Django MongoDBForms to replace ModelForms but I get this really weird

  • 0

Trying to use Django MongoDBForms to replace ModelForms but I get this really weird error when saving the instance of the form.

During save(), mongoengine.Document checks for the cascade keyword in the _meta dict which MongoDBForm wraps.

MongoDBForm then throws a KeyError from getitem

What’s that cascade key it’s looking for?!

Am I doing it wrong?

Request Method: POST
Request URL:    http://localhost:8000/add_item/Books
Django Version: 1.4.2
Exception Type: KeyError
Exception Value:    
0
Exception Location: /Users/holografix/.virtualenvs/troca/lib/python2.7/site-packages/mongodbforms/documentoptions.py in __getitem__, line 171
Python Executable:  /Users/holografix/.virtualenvs/troca/bin/python
Python Version: 2.7.3

The model from models.py

class GenericItem(Document):
    owner_id = IntField(required=True)
    title = StringField(max_length=70, required=True)
    description = StringField(max_length=140, required=True)
    value = IntField()
    location = GeoPointField()
    offers = ListField(EmbeddedDocumentField('Offer'))

    def __unicode__(self):
        return self.title

    class Meta:
        abstract = False
        app_label = 'troca_app'
        db_table = 'generic_item'
        allow_inheritance = True

ModelForm equivalent in forms.py

class ModelFormGenericItem(DocumentForm):
   class Meta:
       document = GenericItem
       fields = ('title', 'value', 'description')

View where I process the form

@login_required
def add_item(request, category):

    if request.method == 'POST':        

        if category == 'Muffins':
            form = ModelFormMuffin(request.POST)        

        elif category == 'Cameras':
            form = ModelFormCameras(request.POST)        

        else:        
            form = ModelFormGenericItem(request.POST)

        form = ModelFormGenericItem(request.POST)

        if form.is_valid():
            #process the data in form.cleaned_data

            instance = form.save(commit = False)
            instance.owner_id = request.user.id
            instance.save(safe=True, cascade=)

            return HttpResponseRedirect('/thanks/')

    else:
        # Ensure that this is a "final" category:
        p = get_object_or_404( Category, categoryTitle = category )        
        i = Category.objects.filter( parentCategory = p )
        if i.count() != 0:
            raise Http404

        if category == 'Muffins':
            form = ModelFormMuffin()

        elif category == 'Cameras':
            form = ModelFormCameras()

        else:        
            form = ModelFormGenericItem()

    return render(request, 'item.html', {
        'form': form,
        'category': category,
    } )

More from the Django error:

/Users/holografix/Documents/development/troca_proj/troca_app/views.py in add_item
            instance.save() ...
▶ Local vars
/Users/holografix/.virtualenvs/troca/lib/python2.7/site-packages/mongoengine/document.py in save
            warn_cascade = not cascade and 'cascade' not in self._meta ...
▶ Local vars
/Users/holografix/.virtualenvs/troca/lib/python2.7/site-packages/mongodbforms/documentoptions.py in __getitem__
        return self.meta[key] ...
▶ Local vars
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:04:28+00:00Added an answer on June 18, 2026 at 4:04 am

    EDIT:
    Implementing a contains() method for documentoptions.py seems to fix it without needing to change anything else.

    Ended up hacking around this issue as I have no idea why it’s happening…

    Added a “has_key()” method to mongodbforms.documentoptions as such:

    def has_key(self, key):
        return self.meta.has_key(key)
    

    and changing the offending line from mongoengine from the in operator to a check on the has_key() method:

    warn_cascade = not cascade and not self._meta.has_key('cascade')
    

    If anyone could answer just WTF the original error is popping up, that’d be awesome!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to use django comments on my web application but I get
I am trying to use django.form redirect to redirect to a page after a
I am trying to use Django with jquery UI autocomplete but having trouble sending
I'm trying to use a Django template, but even thought I've used pip install,
I'm trying to use django-multilingual and setup it properly. But what I found is
I've been trying to use Django-appengine to write a small web app, but I
I'm trying to use the django-voting tutorial from this blog: http://new.justinlilly.com/blog/2008/nov/04/django-voting-a-brief-tutorial/ to get a
I am trying to use the dynamic django form script from http://www.djangosnippets.org/snippets/714/ The dynamic
I am trying to use django-sitetree but I don't understand how to do step
I'm trying to use django-taggit ( see ). This is what I have in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.