when i try to delete one of the TractorRecord objects in this model, i
get this message:
Caught KeyError while rendering: u'objects_name'
any idea what that means?
Django 1.2.3 (mod_wsgi 3.2/Python 2.6)
# this holds possible dispositions for Tractoruees
class Disposition (models.Model):
id = models.AutoField (primary_key=True)
name = models.CharField (max_length=50, blank=False,
db_index=True)
active = models.IntegerField(blank=False,
choices=active_choices)
order = models.IntegerField(blank=True, default=0)
def __unicode__(self):
return self.name
class DispositionAdmin(admin.ModelAdmin):
list_display = ('name','active','order',)
search_fields = ['name']
admin.site.register(Disposition,DispositionAdmin)
#this holds the Tractor information
class TractorRecord (models.Model):
id = models.AutoField (primary_key=True)
FirstName = models.CharField (max_length=25,blank=False,
db_index=True)
LastName = models.CharField (max_length=45,blank=False,
db_index=True)
Status = models.CharField
(choices=inout_choices,max_length=3,blank=False, db_index=True)
Photo= models.ImageField(upload_to="Tractoruees/", blank=True)
Disposition = models.ForeignKey('Disposition',
verbose_name=_('Disposition Value'),db_index=True, blank=False)
Notes = models.TextField(blank=True)
LastTouchedBy = models.ForeignKey(User, unique=False,
db_index=True, blank=False)
LastUpdated = models.DateTimeField
(auto_now_add=True,blank=False, db_index=True,help_text='Auto Filled')
def disposition_name(self):
return self.Disposition.name
def Last_Updated_By(self):
return self.LastTouchedBy.get_full_name()
#resize uploaded image to max 650 x 650
def save(self, size=(175,175)):
super(TractorRecord, self).save()
if self.Photo:
filename = self.Photo.path
image = Image.open(filename)
image.thumbnail(size, Image.ANTIALIAS)
image.save(filename)
class TractorRecordAdmin(admin.ModelAdmin):
list_display =
('Picture','FirstName','LastName','Status','disposition_name','Last_Updated_By','LastUpdated')
search_fields = ['FirstName','LastName','LastTouchedby']
def Picture(self,instance):
return '<img src="/static/demo/%s" width="65"/>' %
(instance.Photo)
Picture.allow_tags=True
admin.site.register(TractorRecord,TractorRecordAdmin)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.