我正在创建一个应用程序框架angularjs和django rest。 该列表完成了angularjs,但编辑我对经典CBV.La问题的处理是我想作为参数传递给url编辑相应的id值,但不能失败以下。
HTML
{% extends "base.html" %}
{% block title %}Listado de Nucleos{% endblock %}
{% block content %}
<div ng-controller="comentariosCtrl">
<script>globals = {coresUrl: '{% url "centro" %}'}</script>
<h1>Listado de Nucleos</h1>
<a href="{% url 'core_add'%}" class="btn">Adicionar</a>
<table class="table">
<tr>
<th>Codigo</th>
<th>Nombre</th>
<th>Acciones</th>
<th></th>
</tr>
<tr ng-repeat="c in comentarios">
<td>{$c.code$}</td>
<td>{$c.name$}</td>
<td>
<a href="#" ng-click="removerComentario(c)">remover</a>
<a href="{% url 'edit' {$c.id$} %}" >editar</a>
</td>
<td></td>
</tr>
</table>
</div>
{% endblock %}
Core.js
var profileEditApp = angular.module('comentariosApp', ['smart-table']);
profileEditApp.config(['$httpProvider', '$interpolateProvider',
function ($httpProvider, $interpolateProvider) {
/* for compatibility with django teplate engine */
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
/* csrf */
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
}]);
profileEditApp.controller('comentariosCtrl', function ($scope, $http) {
function getComentarios() {
$http({method: 'GET', url: globals.coresUrl}).
success(function (data, status, headers, config) {
$scope.comentarios = data;
$scope.lokos= data;
})
}
getComentarios();
views.py
class BookUpdate(UpdateView):
model = Core
fields = ['code', 'name']
template_name = 'core_form.html'
success_url = '/structure/core'
中的错误
<a href="{% url 'edit' {$c.id$} %}" >editar</a>