On Feb 7, 8:26 pm, Artyom Chernetzov <achernet...@gmail.com> wrote: > Here is model structure: Client is User, Client can be corporate or person: > > class Client(User): > #fields > > class ClientCorporate(Client): > #fields > > class ClientPerson(Client): > #fields > > And client can make orders: > > class Order(models.Model): > client=models.ForeignKey(Client) > #fields > > I try to create common orders list for any type of client, here is view: > > def orders_list(request): > client=request.user.client > return list_detail.object_list(request, > queryset = client.order_set.all(), > #templates ... > ) > > And it leads to an error: > > **DatabaseError while rendering: no such column: cabinets_order.client_id** > > I browse db and find that all User childs have column "user_prt_id". I > can't find way to change pk name in inherited models. But maybe there is > some better approach?
Use OneToOneField with parent_link = True, then you can change the name of the db field. See: https://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield -- 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.