Перестали работать ссылки на медиа файлы django после angular роутинга
вот такие urls в django:
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import url, include
from django.contrib import admin
from rest_framework_nested import routers
from posts import views
router = routers.SimpleRouter()
router.register(r'shows', views.ShowsViewSet)
router.register(r'users', views.UsersViewSet)
router.register(r'actors', views.ActorsViewSet)
router.register(r'series', views.SeriesViewSet)
admin.autodiscover()
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^authsys/', include('authapp.urls', namespace='authsys')),
url(r'^accounts/', include('allauth.urls')),
url(r'^check_login/', views.check_login),
url(r'^api/v1/', include(router.urls)),
url(r'^api/v1/shows/$', views.ShowsViewSet, name='shows'),
url(r'^api/v1/users/$', views.UsersViewSet, name='users'),
url(r'^api/v1/actors/$', views.ActorsViewSet, name='actors'),
url(r'^api/v1/series/$', views.SeriesViewSet, name='series'),
url('^.*$', views.homepage, name='index'),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Так выглядит файл с ангуларом:
var myApp = angular.module('myApp', ['ngRoute']);
myApp.run(function ($http) {
$http.defaults.xsrfCookieName = 'csrftoken';
$http.defaults.xsrfHeaderName = 'X-CSRFToken';
});
myApp.config(function($locationProvider) {
$locationProvider.html5Mode(true);
});
myApp.controller('DetailController',['$scope','$http','$routeParams', function($scope, $http, $routeParams){
$http.get('api/v1/shows/' + $routeParams.showID + '/').success(function(data){
$scope.show_detail = data;
});
$http.get('/check_login/').success(function (data) {
$scope.mediaurl = data.mediaUrl;
$scope.user = data;
});
$scope.getSRC = function(imagesrc){
return $scope.mediaurl + imagesrc;
};
}]);
myApp.controller('ShowsListController', ['$scope', '$http','$routeParams','$location','$route', function ($scope, $http, $routeParams,$route) {
$http.get('/api/v1/shows/').success(function (data) {
$scope.shows = data;
});
$http.get('/check_login/').success(function (data) {
$scope.mediaurl = data.mediaUrl;
$scope.user = data;
});
$http.get('/api/v1/actors/').success(function (data) {
$scope.actors = data;
});
$http.get('/api/v1/users/').success(function (data) {
$scope.users = data;
});
$http.get('/api/v1/shows/').success(function (data) {
$scope.shows = data;
});
$scope.getSRC = function(imagesrc){
return $scope.mediaurl + imagesrc;
};
$scope.updateUsername = function (user) {
var data = JSON.stringify({
'username': user.user,
'password':user.password
});
$http.put('/api/v1/users/' + user.id + '/', data).success(function (response) {
}).error(function(data, status, headers, config){
$scope.error = data.username
});
};
}]);
// configuring routing.
myApp.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/', { // If URL is at /, uses template at
templateUrl: '/static/templates/home.html/', // this location
controller: 'ShowsListController' // and apply instructions from this controller
})
.when('/about', { // If URL is at /, uses template at
templateUrl: '/static/templates/about.html/', // this location
controller: 'ShowsListController' // and apply instructions from this controller
})
.when('/shows', { // If URL is at /, uses template at
templateUrl: '/static/templates/shows.html/', // this location
controller: 'ShowsListController' // and apply instructions from this controller
}).when('/admin',{redirectTo:'/admin/'})
.when('/authsys/login/',{redirectTo:'/authsys/login/'})
.when('/authsys/logout/',{redirectTo:'/authsys/logout/'})
.when('/authsys/register/',{redirectTo:'/authsys/register/'})
.when('/shows/:showID',{
templateUrl: '/static/templates/show.html/', // this location
controller: 'DetailController' // and apply instructions from this controller
})
.otherwise({
redirectTo: '/'
});
});
Так вывожу в шаблон:
<h1>shows list</h1>
<div ng-repeat='show in shows'>
<div class="col-xs-6 col-md-3">
<a ng-href="shows/{{show.id}}" class="thumbnail">
<img ng-src="{{getSRC(show.image)}}" style='height: 200px; width: 200px' alt="">
<p class="offset1">{{ show.title }}</p>
</a>
</div>
</div>
Переход к этим медиафайлам прямо по ссылке перебрасывает на главную страницу "/", понятно что это из-за роутинга ангуларовского, но как исправить не понятно