Thanks. I will try what you suggested. But I am almost there with the admin, the only thing is I need to change the date format so that it takes only the year. Now DateField requires month, day and year. I tried this
year_graduated = models.DateField('Year graduated', input_formats= ['%Y']) as in class Lawyer(models.Model): first = models.CharField(max_length=20) initial = models.CharField(blank=True, max_length=2) last = models.CharField(max_length=20) year_graduated = models.DateField('Year graduated', input_formats= ['%Y']) school = models.CharField(max_length=200) school = models.ForeignKey(School) def __unicode__(self): return self.first but it doesn't work. Some googling shows that I may be confusing "form" and "models" http://osdir.com/ml/DjangoUsers/2009-03/msg02593.html In that case how can I fix the DateField so that it takes only the date? Because I only need "Year Graduated" not month or day. Thanks again. On Nov 10, 9:40 am, Monika Sulik <monikasu...@e.pl> wrote: > 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-optionshttp://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name... > > 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---