Opened 5 years ago

Closed 5 years ago

#10544 closed (invalid)

Saving ModelForm to update exisitng record generates No {model} matches the given query.

Reported by: mcwong644 Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mtredinnick)

class Publisher(models.Model):
    name = models.CharField(max_length=30)
    address = models.CharField(max_length=50)
    city = models.CharField(max_length=60)
    state_province = models.CharField(max_length=30)
    country = models.CharField(max_length=50)
    website = models.URLField()

    def __unicode__(self):

    class Meta:
        ordering = ["name"]

class Author(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    email = models.EmailField(blank=True, verbose_name='e-mail')
    objects = models.Manager()
    def __unicode__(self):
        return self.first_name+' '+ self.last_name

class Book(models.Model):
    title = models.CharField(max_length=100)
    authors = models.ManyToManyField(Author)
    publisher = models.ForeignKey(Publisher)
    publication_date = models.DateField(blank=True, null=True)
    num_pages = models.IntegerField(blank=True, null=True)
    objects = models.Manager()
    bookobjects = BookManager()
    wong = WongAuthor()

class BookForm(ModelForm):
    class Meta:
        model = Book
def authorcontactupd(request,id):
    if request.method == 'POST':
        form = AuthorForm(request.POST, instance=a)
        if form.is_valid():
            return HttpResponseRedirect('/contact/created')
        form = AuthorForm(instance=a)
    return render_to_response('author_form.html', {'form': form})

Produces this error

Page not found (404)
Request Method: 	POST
Request URL:

No Publisher matches the given query.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by mtredinnick

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

This looks like a problem in your code, rather than Django. Please post some details to the mailing list to get help with this.

I'll note that the error is reporting a problem about the Publisher model, which is not going to be used by AuthorForm at all. So you should start out by checking you are debugging the right problem.

(fixed description)

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.