oh, forgot to add the view I'm using. Here is the view.
def country_detail(request, country): c = Country.objects.get(slug=country) lobbyists = Activity.objects.filter(country=c) return render_to_response('country/country_detail.html', {'country':c, 'lobbyists':lobbyists}) On Apr 11, 9:56 pm, nixon66 <nixon....@gmail.com> wrote: > I have a legacy database that I used inspectdb to create the models. > I cleaned up the models, set primary keys, foriegn keys etc. But when > I tried to create a view I get an "unknown column activity.fp_id_id > in field list". I'm not sure why its appending an extra id to the end > of a foriegnkey field. Here are the two models in question: > > class Clients(models.Model): > fp_id = models.CharField(max_length=10, primary_key=True) > fp_name = models.CharField(max_length=200, blank=True) > slug = models.CharField(max_length=200, blank=True) > reg_date = models.CharField(max_length=20, blank=True) > termination_date = models.CharField(max_length=20, blank=True) > address_is_foreign = models.CharField(max_length=2, blank=True) > address_1 = models.CharField(max_length=100, blank=True) > city = models.CharField(max_length=50, blank=True) > state = models.CharField(max_length=10, blank=True) > country = models.CharField(max_length=2, blank=True) > zipcode = models.CharField(max_length=10, blank=True) > foreign_cntry_represented = models.ForeignKey(Country, > max_length=2, blank=True) > class Meta: > db_table = u'clients' > > def __unicode__(self): > return self.country > > def get_absolute_url(self): > return 'lobby/client/%s/' % self.slug > > class Activity(models.Model): > activity_id = models.CharField(max_length=10, primary_key=True) > fp_id = models.ForeignKey(Clients, max_length=10, blank=True) > reg_id = models.ForeignKey(Lobbyist, max_length=10, blank=True) > supp_id = models.CharField(max_length=10, blank=True) > period_start_date = models.DateTimeField(null=True, blank=True) > period_end_date = models.DateTimeField(null=True, blank=True) > activity_type=models.ForeignKey > (Lobbytype,max_length=50,related_name="activity_type", blank=True) > slug = models.CharField(max_length=765, blank=True) > activity_desc = models.TextField(blank=True) > financial_amount = models.FloatField(null=True, blank=True) > financial_desc = models.TextField(blank=True) > country = models.CharField(max_length=2, primary_key=True) > year = models.CharField(max_length=5, blank=True) > class Meta: > db_table = u'activity' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---