9👍
✅
It looks like all your factory
classes inherit from factory.Factory
. For example I see:
class UserFactoryCustomer(factory.Factory):
Since you are testing django
models you should instead inherit from factory.django.DjangoModelFactory
. So an example you posted would now look like:
class UserFactoryCustomer(factory.django.DjangoModelFactory):
class Meta:
model = User
first_name = 'name'
last_name = 'Asadov'
username = factory.LazyAttribute(lambda o: slugify(o.first_name + '.' + o.last_name))
email = factory.LazyAttribute(lambda a: '{0}.{1}@example.com'.format(a.first_name, a.last_name).lower())
user_type = 1
balance = 10000.00
👤aqs
0👍
I hate to break it to you, but I think this is a problem of missed indentation…
The super(User, self).save(*args, **kwargs)
part of your save
method for User isn’t actually in the Save method. That’s why it’s not actually being saved.
- [Django]-Errno – 13 Permission denied: '/media/ – Django
- [Django]-Adding new form fields dynamically in admin
- [Django]-Django. Remove select_related from queryset
- [Django]-Django Rest framework authtoken 'module' object has no attribute 'views'
- [Django]-Inheritance model update to its parent model
Source:stackexchange.com