Tuesday, May 30, 2017

DJANGO 1.1 dynamic url on static javascript

Context

I am adding a static javascript file to my **ModelForm** on this way

forms.py

    class SomeForm(forms.ModelForm):
   
       
class Media:
          js
= ('some-javascript.js',)


Problem

On this javascript I need send a GET request to a rest endpoint hosted on same application using jquery, but i need the Server domain or a function to construct my url 

some-javascript.js,

    django.jQuery.get('{% url "validate_username" %}')



expect behavior

If I could create my url with django I could send the request without problems, Thanks in advance


  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/da93cb04-0310-4918-a810-045011853d34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment