4

I am a newbie so I might have done something stupid. running python 3.3 and Django 1.6.2.

When I run the local server via command line, this is the error I receive "P/1.1 404 1712" and error on the browser is "module not found" and the exception location direct me urls.py line 22;

document_root=settings.STATIC_ROOT)

this is a part of urls.py:

from django.conf.urls import patterns, include, url

from django.conf import settings
from django.conf.urls import static



from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'signups.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),

)


if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)

    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)

This is how my settings.py looks:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/whattheheck/static/'

# Template location
TEMPLATE_DIRS = {
    os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "templates"),

}

if DEBUG:
    MEDIA_URL = '/whattheheck/media/'
    STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "static-only")
    MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "media")
    STATICFLIES_DIRS = (
        os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "static")

    )

Can someone help please?

8
  • where is the variable DEBUG at? Looks like its not being set so all of the stuff your trying to call is not being executed correctly. Commented May 30, 2014 at 6:07
  • @TimCastelijns Line 22 is document_root=settings.STATIC_ROOT) and it is a part of urls.py code block: if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Commented May 30, 2014 at 6:16
  • @NicholasYoung The debug is in settings.py; DEBUG = True TEMPLATE_DEBUG = DEBUG ALLOWED_HOSTS = [] Commented May 30, 2014 at 6:21
  • Please provide the full traceback of the "Module not found" error. Commented May 30, 2014 at 6:22
  • Wait why are you trying to include file paths into urls? You shouldn't in the first place. Also im a bit tired BUT i do not think the if gets ran when your just trying to include a variable into a script. I could be wrong Commented May 30, 2014 at 6:25

1 Answer 1

12

You forgot one static in the import statement, see the documentation:

from django.conf.urls.static import static
                    # ^^^^^^ this one

Right now, it tries to use the static module as a function but obviously, it does not work. The error 'module' object is not callable is raised when you are trying to use a module object (for example os, sys or any third-party) as a callable (with a __call__ method).

Sign up to request clarification or add additional context in comments.

7 Comments

Oh duh, I completely passed over that xD
It still does not explain why I am getting a downvote (even it is not you) :(
I have no clue, it wasn't me. Stackoverflow scares me a bit with how much people want everything perfect.
@MaximeLorant Hey Maxine, It worked thanks... not sure who gave you a downvoter, sorry :(. It does not allow me give you a up vote because I do not have the minimum required reputation of 15 yet...but I sure will give an up vote as soon as I get the reputation. Thanks a ton x. Another problem that I am facing now is that my css file is not loading up. If you would like I will create another question since you got voted down on this...let me know?
@MaximeLorant Here you go, I have got enough reputation to up vote you now. Thanks for the help :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.