5

I am new to django and i am getting this error after I run the command python manage.py collectstatic

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 76, in load_command_class
    return module.Command()
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/contrib/staticfiles/management/commands/collectstatic.py", line 58, in __init__
    self.storage.path('')
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/utils/functional.py", line 213, in inner
    self._setup()
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/contrib/staticfiles/storage.py", line 311, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/files/storage.py", line 282, in get_storage_class
    return import_by_path(import_path or settings.DEFAULT_FILE_STORAGE)
  File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/utils/module_loading.py", line 16, in import_by_path
    module_path, class_name = dotted_path.rsplit('.', 1)
AttributeError: 'tuple' object has no attribute 'rsplit'

When I runserver this is the output

http://pastebin.com/2bh7h7gY

Liondancer
  • 15,721
  • 51
  • 149
  • 255

3 Answers3

18

One of your settings in your settings.py is a tuple, or has a unnecessary trailing comma, which will turn it into a tuple and it's not supposed to be. It's supposed to be a string.

I'd start by looking at STATICFILES_STORAGE and DEFAULT_FILE_STORAGE

notbad.jpeg
  • 3,308
  • 1
  • 32
  • 37
  • Thank you! `STATIC_STORAGE` is not a tuple. However I am getting another error now when I run `collectstatic` – Liondancer Apr 10 '14 at 02:24
  • It is unrelated to this question though – Liondancer Apr 10 '14 at 02:24
  • If you care to take a look it is `django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.` I am not sure what to do with my `STATIC_ROOT` as I am learning Django =/ – Liondancer Apr 10 '14 at 02:25
  • http://stackoverflow.com/questions/22976596/handling-static-files-that-dont-pertain-to-an-app-in-django – Liondancer Apr 10 '14 at 02:26
  • Thanks in my case I had a trailing comma – Praneeth Aug 01 '15 at 23:46
  • 3
    "One of your settings in your settings.py is a tuple... and it's not supposed to be." This saved me today. – mRotten Sep 22 '19 at 23:59
  • Very useful to me. i terminated my MIDDLEWARE Settings option with 3 dots and a comma, and so i had to remove it and things went back to normal – vially Apr 20 '22 at 08:07
1

I have the same issue.

After I copied from django restframework documentation the following settings:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
        (...)
    ),
} 

into my project. Then I removed (...) in above mentioned settings, it works now. Plz be careful copying the code ))

While the correct would be:

    REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
        ),
    }

The (...), in this scenario, means "whatever code you have" add before it.

Leonardo Hermoso
  • 838
  • 12
  • 26
Sanjar
  • 35
  • 4
  • 2
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – JayPeerachai Feb 24 '22 at 04:59
0

I had this error when using djoser for authentication in Django Rest Framework. Just change

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
        (...)
    ),
}

to

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
     
    ),
}