jrief / django-angular

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

Nginx rewrite path wont appear on the djangular url #141

Closed jonardrosas closed 9 years ago

jonardrosas commented 9 years ago
 Hi,

I have a problem when using the the djangoUrl.reverse. On my nginx I rewrite the 

the server name like the example below:

nginx.conf

Nginx settings.

server {
    listen       8088;
    server_name www.example.com;
   location /proj1/ {
        root   /home/username/mysite;
        charset utf-8;
        allow all;
        rewrite /proj1/(.*) /$1 break;
        include uwsgi_params;
        uwsgi_param SCRIPT_NAME /proj1/;
        uwsgi_pass 10.85.87.116:3033;
    }

}

urls.py

url(r'^create/$', MyView.as_view(), name='bug_create'),

angular.js

var app = angular.module("myApp", ['ng.django.urls']);

app.controller('sideBarMaskCtrl', function($scope, $filter, $http, djangoUrl) { console.log('sideBarMaskCtrl Data initialized...');

    $scope.add_comment = function(bug_id, status) {
    data = { 'id': bug_id, 'status': status, }
    console.log(data);
        $http.post(djangoUrl.reverse('bug_create'), data).success(
            function(data) {
                    console.log('posting data');
            }).error(function(data,status) {
                console.log(status);
            });
    };

});

So when i access my website it should expect like this: www.example.com/proj1/create/ But what djangular is doing is write it like this.: www.example.com/create/

The proj1 rewrite on my nginx does not appear.

jrief commented 9 years ago

Django doesn't know anything about the magic happening on your nginx proxy.