Would there be an issue with including a factory in the model class itself? I know it's valid python but I'm not sure it would break anything in Django. My initial testing shows it works fine, but I haven't seen examples online doing it this way.
class SampleModel(models.Model):
....
class Factory(factory.django.DjangoModelFactory):
....
I believe it won't break anything, but in my opinion, keeping factories together with models doesn't look good. I think it's cleaner to split them and put factories closer to tests rather than the models.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.