django-mock-queries
django-mock-queries copied to clipboard
ForeignKey access attribute.
Hi, First of all, thanks for sharing this! Is simply amazing to be able to mock QuerySet in few simple lines!
Saying that, I am trying to replicate a ForeignKey relation and access to its attribute. I understand it might not be supported by the library but do you have any suggestion to replicate such behavior?
Thanks a lot
from django_mock_queries.query import MockSet, MockModel
OPERATOR = MockSet(
MockModel(
name="Name_1",
surname="Surname_1"
)
)
TICKETS = MockSet(
MockModel(
change_id=123456,
change_type="test",
status="implementation",
operator=OPERATOR,
date_diff=-10
),
)
for x in TICKETS.all():
op = x.operator_set.all()
print(op)
The above returns:
AttributeError: 'NoneType' object has no attribute 'all'
Have you tried using django_mock_queries.mocks.mocked_relations?