SyntaxError: keyword argument repeated

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SyntaxError: keyword argument repeated

ocha

    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'
    )

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

RE: SyntaxError: keyword argument repeated

Matthew Pava

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?

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Alabi
Sent: Wednesday, November 7, 2018 8:51 AM
To: Django users
Subject: SyntaxError: keyword argument repeated

 

 

    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'

    )

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/624423a6bae949b5966429bb426a3426%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SyntaxError: keyword argument repeated

Vishvajit Pathak
In reply to this post by ocha
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


On Wednesday, 7 November 2018 20:20:46 UTC+5:30, Dennis Alabi wrote:

    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'
    )

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/95dffaa5-a961-483e-b946-d870757c76f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SyntaxError: keyword argument repeated

Ryan Gedwill
You can only pass in a keyword argument once, you pass in related_name twice in one of your properties

Sent from my iPhone

On Nov 8, 2018, at 12:02 PM, Vishvajit Pathak <[hidden email]> wrote:

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


On Wednesday, 7 November 2018 20:20:46 UTC+5:30, Dennis Alabi wrote:

    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'
    )

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/95dffaa5-a961-483e-b946-d870757c76f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8C827210-1EC5-4BA5-89CC-6A1B841126A7%40gmail.com.
For more options, visit https://groups.google.com/d/optout.