或多或少,我正处于开发应用程序的早期阶段,该应用程序使用Django Rest框架和Rest。我决定使用django-rest-auth来管理我与应用程序的所有用户集成。
由于我是新的角,我不想使用django-休息-auth样板角应用程序,以理解角的概念。我只想使用django-rest-auth端点。
问题是:注册表单通过内部服务器500,即使我的数据被传递并成功地提交到django.User模型。
这是我的角度app:
// MODULE
var menuApp = angular.module('menuApp', ['ngRoute', 'ngCookies']);
//ROUTES
menuApp.config(function ($locationProvider, $routeProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false,
hashPrefix:'!'
})
$routeProvider
.when('/', {
templateUrl: '/static/app/pages/login.html',
controller: 'homeCtrl'
})
.when('/register', {
templateUrl: 'static/app/pages/register.html',
controller: 'registerCtrl'
})
menuApp.controller('homeCtrl', ['$log', '$scope', function($log, $scope) {
$log.info("homeCtrl is called ");
}]);
menuApp.controller('registerCtrl', ['$scope', '$cookies', '$http','$location',
function($scope, $cookies, $http, $location) {
console.log("registerCtrl is called");
$scope.register = function(email, username, password){
var data = {
'username': username,
'password1': password,
'password2': password,
'email': email
}
console.log(data)
var make_registration = $http({
url: "/api/rest-auth/registration/",
method: "POST",
headers: {
'X-CSRFToken': $cookies.token,
'Content-Type': 'application/json'},
data: data,
})
.success(function(data, status, headers) {
console.log($cookies.csrftoken)
console.log(data);
console.log(status);
console.log(headers);
})
.error(function(data, status, headers) {
// Need a minimal function to pass the errors
console.log(status);
console.log(data);
});
return make_registration
}
}]);
// RUN
menuApp.run(function ($http) {
$http.defaults.xsrfHeaderName = 'X-CSRFToken';
$http.defaults.xsrfCookieName = 'csrftoken';
});My form是一个非常简单的表单,它有一个‘ng-submit=’注册(电子邮件、用户名、密码)‘和3个输入ng-model='email’等等。
我的urls:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^api/rest-auth/', include('rest_auth.urls')),
url(r'^api/rest-auth/registration/',
include('rest_auth.registration.urls')),
url('^.*$', IndexView.as_view(), name='index'),
)发布于 2016-01-27 16:33:20
我也遇到了同样的问题,结果是当django-allauth试图发送确认邮件时引发了500个内部错误,但是失败了,因为我没有运行STMP服务器。
假设您的问题类似于我的问题,只需在您的settings.py上添加这一行
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'发布于 2015-11-29 20:33:12
您需要django-allauth注册才能工作。
来自Docs
注册(可选)
如果您希望启用标准注册过程,则需要安装django-allauth --请参阅此doc以获得Add allauth、allauth.account和rest_auth.registration应用程序到django settings.py中INSTALLED_APPS的安装:
https://stackoverflow.com/questions/30783472
复制相似问题