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

  • SEARCH
  • Home
  • 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 850737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:18:46+00:00 2026-05-15T07:18:46+00:00

The setup = I have this class, Transcript: class Transcript(models.Model): body = models.TextField(‘Body’) doPagination

  • 0

The setup =

I have this class, Transcript:

class Transcript(models.Model):    
    body = models.TextField('Body')
    doPagination = models.BooleanField('Paginate')
    numPages = models.PositiveIntegerField('Number of Pages')

and this class, TranscriptPages(models.Model):

class TranscriptPages(models.Model):
    transcript = models.ForeignKey(Transcript)
    order = models.PositiveIntegerField('Order')
    content = models.TextField('Page Content', null=True, blank=True)

The Admin behavior I’m trying to create is to let a user populate Transcript.body with the entire contents of a long document and, if they set Transcript.doPagination = True and save the Transcript admin, I will automatically split the body into n Transcript pages.

In the admin, TranscriptPages is a StackedInline of the Transcript Admin.

To do this I’m overridding Transcript’s save method:

def save(self):
    if self.doPagination:
        #do stuff
        super(Transcript, self).save()
    else:
        super(Transcript, self).save()

The problem =

When Transcript.doPagination is True, I want to manually delete all of the TranscriptPages that reference this Transcript so I can then create them again from scratch.

So, I thought this would work:

#do stuff   
TranscriptPages.objects.filter(transcript__id=self.id).delete()
super(Transcript, self).save()

but when I try I get this error:

Exception Type: ValidationError
Exception Value: [u’Select a valid
choice. That choice is not one of the
available choices.’]

… and this is the last thing in the stack trace before the exception is raised:

…/django/forms/models.py in save_existing_objects

  1. pk_value = form.fields[pk_name].clean(raw_pk_value)

Other attempts to fix:

  • t =
    self.transcriptpages_set.all().delete()
    (where self = Transcript from the
    save() method)
  • looping over t (above) and deleting each item individually
  • making a post_save signal on TranscriptPages that calls the delete method

Any ideas? How does the Admin do it?

UPDATE: Every once in a while as I’m playing around with the code I can get a different error (below), but then it just goes away and I can’t replicate it again… until the next random time.

Exception Type:
MultiValueDictKeyError Exception
Value: “Key ‘transcriptpages_set-0-id’
not found in ”
Exception Location:
…/django/utils/datastructures.py in
getitem, line 203

and the last lines from the trace:

…/django/forms/models.py in _construct_form

  1. form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)

…/django/utils/datastructures.py in getitem

  1. pk = self.data[pk_key]
  • 1 1 Answer
  • 1 View
  • 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-05-15T07:18:47+00:00Added an answer on May 15, 2026 at 7:18 am

    In the end it was a matter of timing. When deleting only a single child object out of many, there was no problem. If I was deleting too many child objects at once, the error could happen, because the delete action was attempting to reference ids that were not around. This is why nothing worked, not signals, not [object]_set. I fixed it by using jquery to set a hidden variable in the edit form for the child object, which caused the object to first process the update (slowing down it’s processing) and THEN the delete.

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

Sidebar

Related Questions

I have this setup in my models: class Author(models.Model): name = models.CharField(max_length=100) class Topic(models.Model):
If I have a simple class setup like this: class MyClass { private string
I have a page that is setup like this public partial class _Default :
I have a two models set up like this: class User < ActiveRecord::Base #
I have a setup that looks like this. class Checker { // member data
I have this setup: class UsersController < InheritedResources::Base respond_to :html, :js, :xml, :json def
I Have something similar to this setup: public class Base { public String getApple()
I have this setup: class DontUse; template<class T,class U = DontUse, class V =
Suppose I have a unittest like this class TestABC(unittest.TestCase): def setUp(self): .... def test001_abc(self):
I have this setup: class A { public: virtual void Function(); } class B

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.