[Fixed]-AttributeError: 'tuple' object has no attribute 'startswith'

13👍

You do it wrong. You shouldn’t turn your code in quotes. Watch here how it should be

It should be like:

STATICFILES_DIRS = (
    os.path.join(os.path.dirname(__file__), "static")
)

Also it belongs to your MEDIA_ROOT and STATIC_ROOT settings.

4👍

@chris

STATIC_ROOT and MEDIA_ROOTS are absolute paths and they cannot be tuples so no “,”(commas) is allowed,
So mention the absolute path as “/your/static/file/absolute/path”

Hope this will help 🙂

3👍

STATIC_ROOT = os.path.join(BASE_DIR, "static_in_pro","static_root"),

Please Remove the comma at end of Static root

STATIC_ROOT = os.path.join(BASE_DIR, "static_in_pro","static_root")

2👍

Summary

If you’re new to Django (like I am) and run into this issue, I recommend looking over the book Two Scoops of Django’s, in particular they have a GitHub template with a good app layout here. In particular, you want to look at:

  1. Their ‘base.py‘ file under settings, which has all of the configurations for ‘STATIC_ROOT’, ‘MEDIA_ROOT’, etc.
  2. See how their settings matches their folder structure (see below)
    twoscoopsrecommendsettings

Octotree (Optional)

As a side note, if you use GitHub as source control, I highly recommend getting this Chrome extension called Octotree available here. This lets you view the folder layout of any GitHub repository.

octotree extension

👤Will

Leave a comment