Re: DJANGO 1.1 dynamic url on static javascript

2017-05-30 Thread ludovic coues
Everything looking like {% %} or {{ }} are template tag. Your js file
are not processed by the templating engine so they can be served
really fast directly by your web server and not by django which is a
lot slower.

One solution would be to but the url in your html file. Add a 

DJANGO 1.1 dynamic url on static javascript

2017-05-30 Thread lenin david
*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+unsubscr...@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.


DJANGO 1.1 dynamic url on static javascript

2017-05-30 Thread lenin david
## 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


I posted this question on: https://stackoverflow.com/posts/44266904/edit

-- 
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+unsubscr...@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/99b1a2e3-879e-4395-98b4-52ba8d286bbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.