-5👍
✅
You can’t really bypass that check. The closest you can get is:
class SomeModel(models.Model):
user_id = models.IntegerField(max_length=10)
9👍
You can use unittest.patch
to mock a property:
class TestThing(django.test.TestCase):
@unittest.patch('my_app.models.SomeModel.user', new_callable=unittest.PropertyMock)
def test_thing(self, user_field):
user_field.return_value = 5
...
This works on Django fields.
Source:stackexchange.com