> I can do that, but then I get a key error with the name. However, it  
> works with similar code here:
>
> def details(request, pID='0', opts=()):
> response = HttpResponse()
>         response.write("<HTML><BODY>\n")
>         try:
>                 p = Person.objects.get(id=pID)
>                 if (pID == '0'):
>                         response.write("<H1>Person Details Index</H1><HR>\n")
>                 else:
>
>                         for d in opts:
>                                 response.write("<li>%s: %s</li>" % (d, 
> p.__dict__[d]))
>         except Person.DoesNotExist:
>                 response.write("Person Not Found")
>
>         response.write("</BODY></HTML>")
>         return response
>
>
>
> > But, from the error message, I'm guessing that's actually not (yet)
> > your problem. It complains about the 'text' attribute that cannot be
> > found, which would suggest that that field doesn't exist in the actual
> > database (it's there in the model). Did you sync the database, and
> > then later added the text attribute to Blog (or even the whole Blog)?
> > Btw, where in your view is line 53? I'm guessing at "b =
> > Person.objects.get(id=pID)"?
>
> I dropped the database and resynced it. No go.
>
> I then went and changed the URL code to pass the params to the view  
> with this to this:
>
> details4 = {'opts':('name', 'blogs')}
>
> And now I get:
>
> KeyError at /People/Blog/1/
> 'blogs'
>
> Which confused me a bit, since blogs is also a key.
>
> I can probably skip this excercise and proceed on with the rest of the  
> book since I know now how to pass multiple views and have multiple  
> URLs, but this concerns me. Part of me still doesn't understand fully  
> why it is not working and I get a feeling that if I don't resolve  
> this, I probably screw up the rest of the exercises in the book. :|

I would still have a look at that p.__dict__[d] syntax. I've never
used it, but looking it up, it appears to work slightly different for
class variables and instance variables. Perhaps that's what the
problem is here.
You could try and replace p.__dict__[d] with p.__getattribute__(d).
See what that gives you. You'll have to ask other people what is
better, although I prefer the latter.
Then again, as said, I would take a completely other approach to the
problem in the first place, but I guess that's not where the book is
at this moment.

Btw, what did you change to details4? It looks exactly the same to me,
other than an extra space between the two keywords.


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to