I have populated a test database using Django Model Factory. Here is the model:
class RecordType(factory.DjangoModelFactory):
class Meta:
model = models.RecordType
class UserRecord(factory.DjangoModelFactory):
user = factory.SubFactory(AccountUser)
record_type = factory.SubFactory(RecordType)
class Meta:
model = models.UserRecord
and here is the relevant part of the test:
# Create record types
for category in enums.Category:
factory.RecordType(
code=category.value, internal_code=internal_codes[category.value],
)
# Add record to the user
blind_record_type = factory.RecordType.objects.get(code="08")
factory.UserRecord(user=user, record_type=blind_record_type)
However, when running the test I am met with the error:
E AttributeError: type object 'RecordType' has no attribute 'objects'
Is it possible to access these objects?
Aucun commentaire:
Enregistrer un commentaire