Oh yeah, SQL output: [EMAIL PROTECTED]:~/iFriends$ python manage.py sql People BEGIN; CREATE TABLE "People_blog" ( "id" serial NOT NULL PRIMARY KEY, "title" varchar(200) NOT NULL, "text" text NOT NULL ); CREATE TABLE "People_person" ( "id" serial NOT NULL PRIMARY KEY, "userID_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "name" varchar(200) NOT NULL, "birthday" date NULL, "gender" varchar(1) NOT NULL, "email" varchar(75) NOT NULL UNIQUE, "headshot" varchar(100) NOT NULL, "favoriteURL" varchar(200) NOT NULL, "desc" text NULL ); CREATE TABLE "People_person_favoriteBooks" ( "id" serial NOT NULL PRIMARY KEY, "from_person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, "to_person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, UNIQUE ("from_person_id", "to_person_id") ); CREATE TABLE "People_person_favoriteMovies" ( "id" serial NOT NULL PRIMARY KEY, "from_person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, "to_person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, UNIQUE ("from_person_id", "to_person_id") ); CREATE TABLE "People_person_friends" ( "id" serial NOT NULL PRIMARY KEY, "from_person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, "to_person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, UNIQUE ("from_person_id", "to_person_id") ); CREATE TABLE "People_person_blogs" ( "id" serial NOT NULL PRIMARY KEY, "person_id" integer NOT NULL REFERENCES "People_person" ("id") DEFERRABLE INITIALLY DEFERRED, "blog_id" integer NOT NULL REFERENCES "People_blog" ("id") DEFERRABLE INITIALLY DEFERRED, UNIQUE ("person_id", "blog_id") );
On Mar 8, 2008, at 10:32 PM, Rilindo Foster wrote: > > On Mar 8, 2008, at 7:04 AM, Evert Rol wrote: >> >> Have you checked what 'd' is here? It may be something different than >> you'd expect or hope, in particular for the __dict__[d] lookup (not >> sure what you're expecting here). >> I would actually work with something like >> Person.objects.filter(id=pID), which keeps b a QuerySet instead of >> turning it into an object, and then do more filtering later on. > > > 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. :| > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---