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”. So, what’s the best way to make it work in django? Create custom manager, or change models in appropriate way? …
This error just means you don’t have the database column
client_idin yourcabinets_ordertable.Make sure you
python manage.py syncdb. If you added the foreign key aftersyncdbing once, you’ll have to reset it, or add the foreign key manually. You can generate the SQL needed by runningpython manage.py sqlall cabinets, then picking the ForeignKey generation bits.If you can stand to lose your current data (if in development), just run
python manage.py reset cabinets