[Fixed]-Getting items in model referenced by a onetoonemodel in django


clinic.menu.objects is the ModelManager for the Menu model – note that it’s an attribute of the Menu class, not of your clinic.menu instance. ModelManager classes are used to query the underlying table, and are not supposed to be called directly from instances (which wouldn’t make much sense anyway), hence the error message.

Conceptually it seems like I should be able to access the items and get a list by tracing the relationship down through the clinic model like this Clinic > Menu > Items

That’s indeed possible (hopefully), but where are you mentionning items in clinic.menu.objects ? You want clinic.menu.item_set.all().


Try this:


Leave a comment