Django: no module named context_processors, base URL

I searched the Internet for a solution, but nothing works. I get an error message:

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

In my project directory, I have context_processor.py and init .py files (as if not in the folder), but they don't seem to detect these files. If I want to avoid using hard-coded URLs, is this way viable or can someone suggest something else? Any help is much appreciated!

+5
source share
2 answers

An external project directory is usually not in the Python path. You probably just need context_processors.base_url , without mysite .

+5
source

in my settings I have:

 from django.conf import global_settings TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( ... '<appname>.context_processors.base_url', ... ) 
0
source

Source: https://habr.com/ru/post/1200893/


All Articles