Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: No module named context_processors, Base URL

I've scoured the web for a solution but nothing seems to work. I'm getting the error:

ImproperlyConfigured at /tool/page4/

Error importing module mysite.context_processors: "No module named context_processors"

settings.py

TEMPLATE_CONTEXT_PROCESSORS = (
# default context processors for Django 1.4
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request",
"mysite.context_processors.baseurl",
)

views.py

if(team_value != "---------" && product_value != "---------" && type_team.length > 3 && pattern_value.length > 1)
      {
        $.ajax({

              url: {{BASE_URL}}'/tool/page4/add_team/',
              type: 'POST',
              dataType: 'html',
              data: {
                  "team" : team_value,
                  "product" : product_value,
                  "pattern" : pattern_value,
                  "type" : type_team,
                  "array" : data_array
              },
              async: false,

              error: function(XMLHttpRequest, textStatus, errorThrown) { 
                  alert("Status: " + textStatus); alert("Error: " + errorThrown); 
              } 
          });
        location.reload(true);

Within my project directory, I have my context_processor.py and init.py files (both not in a folder), however, it doesn't seem to find those files. If I want to avoid using hard-coded URLs, is this way viable or could someone suggest something otherwise? Any help is greatly appreciated!

like image 734
Danny Brown Avatar asked Aug 21 '14 22:08

Danny Brown


Video Answer


1 Answers

The outer project directory is not usually on the Python path. You probably just need context_processors.base_url, without the mysite.

like image 119
Daniel Roseman Avatar answered Oct 12 '22 13:10

Daniel Roseman