Re: Viewing details on a record in admin pages gives DoesNotExist error
That was it! Thank you very much for your time and effort! On Jan 11, 5:36 pm, Karen Tracey wrote: > On Mon, Jan 11, 2010 at 4:54 PM, kkerbel wrote: > > [snip] > > File "/usr/local/lib64/python2.5/site-packages/django/db/models/ > > fields/related.py", line 257, in __get__ > > rel_obj = QuerySet(self.field.rel.to).get(**params) > > > File "/usr/local/lib64/python2.5/site-packages/django/db/models/ > > query.py", line 305, in get > > % self.model._meta.object_name) > > > DoesNotExist: Employee matching query does not exist. > > > [snip] > > > ...also, this only happens with the approval and final_approval > > models...the request model works fine and shows the details with no > > problem. > > You need to check that the Employee in requested_by for ALL Requests is > valid. You already know that the specific Employee associated with the > Request associated with the Approval you are attempting to view is valid > because it is part of what you display on the changelist page. However when > you click on the link to produce the detail page you get an error noting > that an Employee cannot be found. A difference with the detail page, > compared to the changelist page, is that the detail page will have a select > box listing all the Requests the Approval could be associated with. My > guess is somewhere you have a Request linked to an Employee that is no > longer valid. It is that Request which is causing the error. > > Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Viewing details on a record in admin pages gives DoesNotExist error
On Mon, Jan 11, 2010 at 4:54 PM, kkerbel wrote: > [snip] > File "/usr/local/lib64/python2.5/site-packages/django/db/models/ > fields/related.py", line 257, in __get__ > rel_obj = QuerySet(self.field.rel.to).get(**params) > > File "/usr/local/lib64/python2.5/site-packages/django/db/models/ > query.py", line 305, in get > % self.model._meta.object_name) > > DoesNotExist: Employee matching query does not exist. > > [snip] > > ...also, this only happens with the approval and final_approval > models...the request model works fine and shows the details with no > problem. > > You need to check that the Employee in requested_by for ALL Requests is valid. You already know that the specific Employee associated with the Request associated with the Approval you are attempting to view is valid because it is part of what you display on the changelist page. However when you click on the link to produce the detail page you get an error noting that an Employee cannot be found. A difference with the detail page, compared to the changelist page, is that the detail page will have a select box listing all the Requests the Approval could be associated with. My guess is somewhere you have a Request linked to an Employee that is no longer valid. It is that Request which is causing the error. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Viewing details on a record in admin pages gives DoesNotExist error
admin.py === from django.contrib import admin from . import models class PerDiemInline(admin.StackedInline): model = models.PerDiem class AccountInline(admin.StackedInline): model = models.Account class RequestAdmin(admin.ModelAdmin): list_display = ('requested_by', 'department', 'date_submitted', 'travel_start', 'travel_end',) list_filter = ('department',) inlines = (PerDiemInline, AccountInline) class ApprovalAdmin(admin.ModelAdmin): list_display = ('request', 'approved_by', 'approved_at', 'approved') list_filter = ('approved', 'approved_by') class FinalApprovalAdmin(admin.ModelAdmin): list_display = ('request', 'approved_by', 'approved_at', 'approved') list_filter = ('approved', 'approved_by') admin.site.register(models.Request, RequestAdmin) admin.site.register(models.Approval, ApprovalAdmin) admin.site.register(models.FinalApproval, FinalApprovalAdmin) === models.py === from django.db import models from django.db.models import Q import datetime from maysnet.directory.models import Employee, Department class Request(models.Model): requested_by = models.ForeignKey(Employee, related_name="foreigntravel_requester") department = models.ForeignKey(Department, related_name="foreigntravel_targetdepartment") no_travel_warning = models.BooleanField() cibs_name = models.CharField("Name", max_length=100, blank=True, null=True) cibs_title = models.CharField("Title", max_length=100, blank=True, null=True) cibs_organization = models.CharField("Funding Organization", max_length=100, blank=True, null=True) teacher = models.BooleanField() substitute_teacher = models.CharField("Teaching Duties Covered By", max_length=100, blank=True) destination = models.CharField(max_length=100) travel_start = models.DateField(default=datetime.date.today() + datetime.timedelta(days=10)) travel_end = models.DateField(default=datetime.date.today() + datetime.timedelta(days=10)) purpose = models.TextField("Purpose of Travel") benefit = models.TextField("Benefit to") airfare = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True, default=0) ground_transportation = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True, default=0) registration_fee = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True, default=0) meals = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True, default=0) lodging = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True, default=0) comments = models.TextField(null=True, blank=True) date_submitted = models.DateField(auto_now_add=True) send_to = models.ForeignKey(Employee, verbose_name="Department Head", related_name="foreigntravel_requestrecipient") def __unicode__(self): return self.requested_by.__unicode__() + " - " + self.date_submitted.strftime("%m/%d/%Y") def status(self): try: self.approval except: return "Pending Approval" try: self.finalapproval except: if self.approval.approved: return "Pending Final Approval" else: return "Denied" if self.finalapproval.approved: return "Approved" else: return "Denied" class Meta: ordering = ["-date_submitted"] permissions = ( ("approve_foreigntravel", "Can approve foreign travel"), ("finalapprove_foreigntravel", "Can give final approval for foreign travel"), ("view_request", "Can view department foreign travel"), ) class PerDiem(models.Model): request = models.ForeignKey(Request) city = models.CharField(max_length=50) lodging = models.DecimalField(max_digits=7, decimal_places=2) meals = models.DecimalField(max_digits=7, decimal_places=2) order = models.IntegerField(default=1) def __unicode__(self): return self.city class Meta: ordering = ["-request", "order"] class Account(models.Model): request = models.ForeignKey(Request) number = models.IntegerField() name = models.CharField(max_length=50) amount = models.DecimalField(max_digits=7, decimal_places=2) def __unicode__(self): return self.number.__unicode__() class Meta: ordering = ["-request", "number"] class Approval(models.Model): request = models.OneToOneField(Request) approved_by = models.For
Re: Viewing details on a record in admin pages gives DoesNotExist error
Ok...I'm sorry. The change list page is what I'm referring to...I'll try to gather some info and post it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Viewing details on a record in admin pages gives DoesNotExist error
On Mon, Jan 11, 2010 at 2:59 PM, kkerbel wrote: > When viewing the admin pages for a travel request app we wrote, the > admin page shows the record links, however, when you click to view the > details of any record, I get an error stating "DoesNotExist: Employee > matching query does not exist." I've looked at the database and the > employee does indeed exist and all of the related tables' keys link > properly to each other. I recently upgraded from Django 1.0 to 1.1.1, > might there be a change between those versions that could cause this > issue? Any direction would be appreciated...i'm just failing to see > what could be causing this. > > It would help people help you if you were a bit more specific about what admin pages are displaying these links, what their values are, what admin definitions exist for the models(s) in question, etc. Given that the recommended way of specifying admin urls changed from 1.0 to 1.1 it might also be helpful to include exactly what admin url pattern you are using (though the old way should still work). The basic admin function of listing all the objects on the change list page with links to an edit page for each certainly still works in 1.1.1, so it's a little hard to know what is going on in your case without more information. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Viewing details on a record in admin pages gives DoesNotExist error
When viewing the admin pages for a travel request app we wrote, the admin page shows the record links, however, when you click to view the details of any record, I get an error stating "DoesNotExist: Employee matching query does not exist." I've looked at the database and the employee does indeed exist and all of the related tables' keys link properly to each other. I recently upgraded from Django 1.0 to 1.1.1, might there be a change between those versions that could cause this issue? Any direction would be appreciated...i'm just failing to see what could be causing this. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.