Re: TemplateSyntaxError
When you execute manage.py sql wkw, the output is just how your
current models translate into SQL. To see what's actually in the
database you should do manage.py dbshell and then use whatever command
your database supports (\d wkw_lawyer in PostgreSQL and DESCRIBE
wkw_lawyer in MySQL).
Try doing manage.py reset wkw
My guess is that the wkw_lawyer table in the database probably has a
field called education_id instead of school_id, the reset command
should drop and create the wkw_lawyer table again (like my predecessor
proposed). More about how syncdb works (and why it wouldn't have
changed education_id into school_id) here:
http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb
And finally, you don't have to change the name of the class when you
don't like how the plural of a class name is being rendered. You can
specify the plural in the Meta class of the model:
http://docs.djangoproject.com/en/dev/topics/db/models/#meta-options
http://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name-plural
Hope that helps :)
On Nov 10, 3:14 am, Zeynel <azeyn...@gmail.com> wrote:
> Hello,
>
> These are my tables:
>
> BEGIN;
> CREATE TABLE "wkw_school" (
> "id" integer NOT NULL PRIMARY KEY,
> "school" varchar(200) NOT NULL
> )
> ;
> CREATE TABLE "wkw_lawyer" (
> "id" integer NOT NULL PRIMARY KEY,
> "first" varchar(20) NOT NULL,
> "initial" varchar(2) NOT NULL,
> "last" varchar(20) NOT NULL,
> "year_graduated" datetime NOT NULL,
> "school_id" integer NOT NULL REFERENCES "wkw_school" ("id")
> )
> ;
> COMMIT;
>
> (I changed "Education" to "School" because in the admin panel it
> showed up as "Educations". I think "Schools" makes more sense.)
>
> I created the admin and I registered School and Lawyer.
>
> In the admin panel School link works fine but when I click on Lawyer
> link I get a "TemplateSyntaxError at /admin/wkw/lawyer/
> Caught an exception while rendering: no such column:
> wkw_lawyer.school_id"
>
> But according to the above tables, school_id has been created.
>
> I tried to add in the shell,
>
> p = Lawyer(school_id=1)
>
> but
>
> p.save()
>
> throws an error.
>
> Any ideas why Lawyer link in the admin panel does not work?
>
> This is the offending line on the debug page:
>
> 78 {% result_list cl %}
>
> Thank you.
--~--~---------~--~----~------------~-------~--~----~
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 django-users+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home