jrief / django-angular

Let AngularJS play well with Django
http://django-angular.awesto.com/
MIT License
1.23k stars 293 forks source link

Load urls config in separate request #136

Closed syabro closed 9 years ago

syabro commented 9 years ago

Right now urlconf in my html took 129kb when the whole page is 140kb.

Let's load it with separate request.

Something like:

  1. User adds <script src="{% djng_urls %} " ></script>
  2. django-angular generates dict with urls and calculate hash.
  3. check is file djng-urls.%hash%.js is exists in {{ MEDIA_URL }}/django-angular and saves it if not
  4. djng_urls returns generated js url

So it'll not be loaded every time user loads the page.

jkosir commented 9 years ago

See #134 for discussion about loading urls.

syabro commented 9 years ago

I've already read it. I don't like the whole idea to fetch every url with request. It'll be pain in the ass on slow connections.

jkosir commented 9 years ago

The proposed solution doesn't fetch urls. It just makes a request to "wrapper" view with url name and args/kwargs. The wrapper view than calls the appropriate view and returns the result.

Basically, this doesn't have any overhead compared to hard-coded urls. Right now I'm trying out some ways to implement it on angular side best.

syabro commented 9 years ago

Ah, don't get it. Seems like a nice solution