SyntaxError: keyword argument repeated

737 views
Skip to first unread message

Dennis Alabi

unread,
Nov 7, 2018, 9:50:46 AM11/7/18
to Django users

    django.setup()
  File "C:\Users\User\Anaconda3\envs\myprogv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\User\Anaconda3\envs\myprogv\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\User\Anaconda3\envs\myprogv\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\User\Anaconda3\envs\myprogv\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\User\Documents\cctv_project\openCV\cam_project\customers\models.py", line 85
    on_delete=models.CASCADE,related_name="'zone's", null=True, related_name='children'
                                                               ^
SyntaxError: keyword argument repeated


I get the above error and the potion of my code causing it in models.py is given below, please help out

# Relationship Fields
    user = ForeignKey(
        'customers.User',
        on_delete=models.CASCADE, related_name="users"
    )
    parent = ForeignKey(
        'customers.Zone',
        on_delete=models.CASCADE, related_name="'zone's", null=True, related_name='children'
    )

Matthew Pava

unread,
Nov 7, 2018, 9:56:18 AM11/7/18
to django...@googlegroups.com

The error message says “keyword argument repeated”

Look at the keyword arguments and check for repeated ones.

I see it in the definition of parent.  Do you see it?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/277c4a05-6744-4d77-b571-db4e5a42386d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vishvajit Pathak

unread,
Nov 8, 2018, 3:02:58 PM11/8/18
to Django users
in the code 

parent = ForeignKey(
        'customers.Zone',
        on_delete=models.CASCADE, related_name="'zone's", null=True, related_name='children'
    )

key `related_name` is repeated

Ryan Gedwill

unread,
Nov 8, 2018, 8:51:49 PM11/8/18
to django...@googlegroups.com
You can only pass in a keyword argument once, you pass in related_name twice in one of your properties

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages