Alex, Thanks
Ron On Feb 20, 2:37 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: > On Fri, Feb 20, 2009 at 2:34 PM, nixon66 <nixon....@gmail.com> wrote: > > > eleom, > > > Thanks for the catch with country county in my model. > > > On Feb 20, 2:22 pm, eleom <eliseomar...@gmail.com> wrote: > > > Well, as the error message says, you must pass a County instance in > > > the argument 'county'. Now you are passing the name of the county, not > > > the county itself. So, your last line should be > > > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > > > city = 'Walla Walla', county=c, dollar_amount =54000) > > > > instead of > > > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > > > city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > > where c is the County object defined before. > > > > P.S. By the way, you mix 'County' and 'Country' in your example. > > > > On Feb 20, 8:06 pm, nixon66 <nixon....@gmail.com> wrote: > > > > > If this is the wrong list to post a newbie question please let me > > > > know. I'm getting an error message while trying to populate the tables > > > > created by the models and not sure why. Here are the models > > > > > from django.db import models > > > > > class County(models.Model): > > > > name = models.CharField(max_length=80) > > > > slug = models.CharField(max_length=80) > > > > > def __unicode__(self): > > > > return self.name > > > > > def get_absolute_url(self): > > > > return "/countries/%s/" % self.slug > > > > > class Company(models.Model): > > > > name = models.CharField(max_length=50) > > > > address = models.CharField(max_length=80) > > > > client = models.CharField(max_length=50) > > > > city = models.CharField(max_length=50) > > > > county = models.ForeignKey(Country) > > > > dollar_amount = models.DecimalField('Cost (in dollars)', > > > > max_digits=10, decimal_places=2) > > > > > def __unicode__(self): > > > > return self.name > > > > > So I go into the shell and type this: > > > > > >>c=County(name='blah blah, slug="blah-blah") > > > > > then > > > > > >> l = Company(name='xyz corp', address='56 b. street', client='G > > corp', city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > > > The error message I get is Valueerror: Cannot assign "blah blah" : > > > > "Company.county" must be a "County" instance. > > > > > doesn't this create the instance? > > > > >> c=County('blah blah', slug='blah-blah') > > > > > Any suggestion or point out my error would be appreciated. > > If you create a country in the admin the county field will display as a drop > down where you can select the correct county, and have a link where you can > create another one if it doesn't exist yet. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---