django-dajaxice
django-dajaxice copied to clipboard
FORCE_SCRIPT_NAME
It may be my lack of understanding of the Django settings system, but in my settings.py I set the FORCE_SCRIPT_NAME variable to 'X" so my application is located under http://servername/X/ and not http://servername/, without adding 'X' every time in urls.py.
The problem I found that 'X' is not included in the url path of the ajax message sent from the JS side and so obviously it can not be interpreted on the server.
I think the solution could be something like modifying dajaxice.core.js as follows;
{% load settings_value %}
...
endpoint = '{% settings_value "FORCE_SCRIPT_NAME" %}{% url 'dajaxice-endpoint' %}'+dajaxice_function+'/';
Where settings_value
is a template tag defined as follows:
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag
def settings_value(name):
return getattr(settings, name, "")
This worked for me, but I am not sure if this is the correct approach, since I am a bit lost in the many configuration options of Django.