jrief / django-angular

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

Jamesbrobb django messages #278

Closed adrienbrunet closed 7 years ago

adrienbrunet commented 7 years ago

This is entirely @jamesbrobb work. I just rebased his work on our current master to get rid of the merge conflicts.

Now that we're able to merge, it could be a nice addition. What do you think @jrief and @jkosir ?

Note: I've just read quickly the code, haven't tested it yet.

adrienbrunet commented 7 years ago

Original description:

This adds support to seamlessly pass django messages to an angular app via ajax.

You can either use the Middleware or a view decorator to add the current messages to the HttpResponse of an ajax request (when the response Content-Type is application/json).

Then the messages are extracted from the response data by a HttpInterceptor, which also returns the remaining data to it's original/expected format.

There's a demo page that needs more detail and also docs.

jrief commented 7 years ago

Cool stuff! I was thinking about this feature myself, but had no time to implement it. Many thanks to @jamesbrobb

adrienbrunet commented 7 years ago

Erf, I need to make it work and then we can all have a closer look at it.

adrienbrunet commented 7 years ago

@jrief tests pass now. =) Haven't tried it though, I don't really have the need for it right now. Would be great if you can have a look and merge it.

adrienbrunet commented 7 years ago

I'm going to add compatibility for django1.10 and we're good to go. Or at least, review it :smiling_imp:

jrief commented 7 years ago

a few day ago I started to merge that PR locally. However, I had to adopt a lot of code and then I was distracted with other work.

btw. I had a look at a possible implementation of the client part, http://jsfiddle.net/roopehakulinen/uxeg4nze/ how do you like that?

adrienbrunet commented 7 years ago

That's neat! Currently adding django1.10 support. We'll see then what we can do. :)

adrienbrunet commented 7 years ago

:+1: