diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index 19a9cca..63041b2 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -26,16 +26,23 @@ def registration_ajax(request): html = render_to_string('forms/f_registration.html', Dict) return JsonResponse({'html': html}, status=400) + user = User.objects.create_user(username=form.data['email'], email=form.data['email'], password=form.data['password']) + # user = auth.authenticate(username=new_user_Dict['name'], password=new_user_Dict['pass']) + if user: + auth.login(request, user) - res_data = { - 'errors': 'тестовый верный ответ' - } + res_Dict = {} + + JsonResponse(res_Dict) except Exception as e: - res_data = { - 'errors': f'ошибка в запросе = {str(e)}' + errors_Dict = { + 'errors': { + '__all__': f'ошибка в запросе = {str(e)}' + } } + Dict = {'form': errors_Dict} + html = render_to_string('forms/f_registration.html', Dict) + return JsonResponse({'html': html}, status=400) - - return JsonResponse(res_data) \ No newline at end of file diff --git a/AuthApp/urls.py b/AuthApp/urls.py index a6f259f..fd11a63 100644 --- a/AuthApp/urls.py +++ b/AuthApp/urls.py @@ -8,6 +8,7 @@ from django.contrib.auth import views urlpatterns = [ path('registration/', registration_View, name='registration_page'), + path('profile/', user_profile_View, name='user_profile'), # ajax ---------------- # url(r'^login$', user_login_View_ajax, name='user_login_View_ajax'), diff --git a/AuthApp/views.py b/AuthApp/views.py index 9ae9fa2..597095f 100644 --- a/AuthApp/views.py +++ b/AuthApp/views.py @@ -21,6 +21,19 @@ def registration_View(request): return HttpResponse(t.render(Dict, request)) +def user_profile_View(request): + + Dict = {} + + t = loader.get_template('pages/p_user_profile.html') + return HttpResponse(t.render(Dict, request)) + + + + + + + def create_personal_user(data, creator): try: diff --git a/templates/forms/f_registration.html b/templates/forms/f_registration.html index 7cb895a..652f8a1 100644 --- a/templates/forms/f_registration.html +++ b/templates/forms/f_registration.html @@ -9,27 +9,27 @@