Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name conflict if tracked model has "instance" field #633

Open
shemigon opened this issue Oct 19, 2024 · 0 comments
Open

Name conflict if tracked model has "instance" field #633

shemigon opened this issue Oct 19, 2024 · 0 comments

Comments

@shemigon
Copy link

Problem

If a tracked model has the instance field, creating a instance of the model throws

TypeError: Model.__init__() got multiple values for argument 'instance'

Environment

  • Django Model Utils version: 5.0.0
  • Django version: any
  • Python version: any
  • Other libraries used, if any: none

Code examples

class SomeModel(models.Model):
    name = models.CharField(max_length=100)
    instance = models.CharField(max_length=100)
model = SomeModel.objects.create(name="test", instance="12.34")
Error
Traceback (most recent call last):
  File "<projectdir>/env/lib/python3.11/site-packages/django/test/utils.py", line 446, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "<projectdir>/tests/testapp/tests/test_model.py", line 273, in test_model_with_instance_property
    model = SomeModel.objects.create(name="test", instance="test")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<projectdir>/env/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<projectdir>/env/lib/python3.11/site-packages/django/db/models/query.py", line 677, in create
    obj = self.model(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^
TypeError: Model.__init__() got multiple values for argument 'instance'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant