What would cause a raw_id_admin field to have a proper ID number in it,
but not be able to:

1. display the __str__() of the chosen object beside the input field
2. render the usual list of objects when clicking on the hour glass

The hourglass link shows "http://((server))/admin///", which is
obviously not correct.

Is this a known issue with a known workaround, or have I created truly
stupid and evil objects (code snippet below)? Also, without the
try/except clause in __str__() on the invoice object, I get a horrid
traceback when trying to load the payment object in the admin
(traceback snippet below). Note that if I take out the raw_id_admin
part, there's no traceback.

Enlighten me!


Models.py
======
class Invoice(models.Model):
        policy = models.ForeignKey(Policy, raw_id_admin=True)
        endorsement = models.ForeignKey(Endorsement, raw_id_admin=True,
blank=True, null=True)
        number = models.CharField("Invoice Number", maxlength=20)
        amount = models.FloatField("Incoice Amount", max_digits=15,
decimal_places=2)
        due = models.DateField("Date Due")
        master = models.BooleanField(default=0)
        def __str__(self):
                try:
                        return "%s %s %s" % (self.policy, self.number,
self.amount)
                except:
                        return ""
        class Admin:
                pass

class Payment(models.Model):
        timestamp = models.DateTimeField()
        invoice = models.ForeignKey(Invoice, blank=True, null=True,
raw_id_admin=True)
        account = models.ForeignKey(Account, blank=True, null=True,
raw_id_admin=True)
        check_number = models.CharField("Check Number", maxlength = 15)
        originator = models.CharField("Originator", maxlength = 255)
        amount = models.FloatField("Amount", max_digits=15,
decimal_places=2)
        recieved = models.DateField("Date Recieved")
        notes = models.TextField("Additional Notes")
        def __str__(self):
                return "%s %s %s" % (self.originator, self.amount,
self.recieved)
        class Admin:
                pass


Traceback
======
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in
render_node
  706. result = node.render(context)
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in
render
  752. output = self.filter_expression.resolve(context)
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in
resolve
  548. obj = resolve_variable(self.var, context)
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in
resolve_variable
  657. raise VariableDoesNotExist, "Failed lookup for key [%s] in %r" %
(bits[0], current) # missing attribute
File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in
__repr__
  80. return '<%s: %s>' % (self.__class__.__name__, self)
File "/var/www/commund/financial_database/models.py" in __str__
  521. return "%s %s %s" % (self.policy, self.number, self.amount)
File
"/usr/lib/python2.4/site-packages/django/db/models/fields/related.py"
in __get__
  163. raise self.field.rel.to.DoesNotExist

  DoesNotExist at /admin/financial_database/payment/4895/


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to