I'm working on adding "user ratings" to my first Django web app.
I'm having trouble getting the admin interface to work with
subclasses.

When I try the following it seems to work... up to a point.  In a sh
script I create the db and populate with a couple of "places".  Then, in
admin, when I click on Add Rating it shows a page with (as expected):
rateable (empty selection list), rating, and user (my logged in user
since I did createsuperuser and logged in for admin).

Then, when I click on the "plus sign" of "Rateable:" it goes off to
.../rateables/add/ and gives the following error:

  IndexError at /admin/myapp/rateables/add/

  list index out of range
  Request Method: GET
  Request URL: http://127.0.0.1:8000/admin/myapp/rateables/add/
  Exception Type: IndexError
  Exception Value: list index out of range
  Exception Location:
  ... Django-0.91-py2.4.egg/django/contrib/admin/views/main.py in __init__, 
line 359


Well, I don't have any "Rateable" objects... I've got two "Place"
objects which were created via a "Place" class subclassed from
"Rateable".  I'd think that I somehow have to get it to do
.../places/add/ instead, but I don't see how to do that or the admin
interface doesn't work completely / correctly for subclasses.  When I
try, in admin, to go to one of those "places" or try to add a new
place, it doesn't give me the option of seeing or adding a "Rating".

?????

Below is the the model I was using...

-- 
Glenn




class Rateable(meta.Model):
   rating = meta.IntegerField( null=True, editable=False,
      help_text = "computed rating of this one thing", core=True)
   def __repr__(self):
      return self.rating
   class META:
      admin = meta.Admin(
      list_display=("rating", "get_rating", ),
      )
class Rating(meta.Model):
   ratee = meta.ForeignKey(Rateable, core=True, null=True, 
edit_inline=meta.TABULAR,)
   rating = meta.IntegerField( null=True, editable=True,
      help_text = "this person's rating of this one thing", core=True)
   rater = meta.ForeignKey(User, edit_inline=meta.TABULAR,)
   class META:
      admin = meta.Admin(
      list_display=("rater", "rating", "ratee", ),
      )
class Place(Rateable):
        title = meta.CharField('Title', maxlength=50, core=True)
        description = meta.TextField('Description',
                help_text='Short summary of this place',
                blank=True,
                )
        city=meta.CharField(maxlength=50)
        state=meta.USStateField()
        address=meta.TextField(blank=True)
        when_created=meta.DateTimeField(auto_now_add=True)
        def __repr__(self):
                return self.title
        class META:
                admin = meta.Admin(
                        list_display=("title", "description", "city", "state",) 
,
                        list_filter=("title", "description", "city", "state",) ,
                        search_fields=("title", "description", "city", "state"),
                )
        def get_absolute_url(self):
                return "/place/%i/" % self.id

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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