White Error Screen Appears when I try to update from form
I am getting a white error screen when I try to add an item via a form in python / django. I am trying to debug it but there is no information. Can somebody point me in the right direction?
Models.py
from __future__ import unicode_literals
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
# Create your models here.
class UserProfile(models.Model):
image = models.ImageField(upload_to='images', default='Upload Picture')
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
biography = models.TextField(max_length=280,blank=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
dob = models.CharField(max_length=10, blank=True)
gender = models.CharField(max_length=1, blank=True)
facebook = models.CharField(max_length=50, blank=True, null=True)
twitter = models.CharField(max_length=50, blank=True, null=True)
instagram = models.CharField(max_length=50, blank=True, null=True)
class KidProfile(models.Model):
parent = models.ForeignKey(User, related_name='kids')
name = models.CharField(max_length=255, null=True, blank=True)
dob = models.CharField(max_length=10, null=True, blank=True)
gender = models.CharField(max_length=1, null=True, blank=True)
needs = models.CharField(max_length=3, null=True, blank=True)
def __str__ (self):
return self.name
views.py
from django.contrib import messages, auth
from accounts.forms import UserRegistrationForm, UserLoginForm, FullUserDetailsForm, KidDetailsForm
from django.core.urlresolvers import reverse
from django.shortcuts import render, redirect, HttpResponseRedirect, HttpResponse, get_object_or_404
from django.template.context_processors import csrf
from django.contrib.auth.decorators import login_required
from .models import KidProfile, UserProfile
@login_required(login_url='/accounts/login')
def profile(request):
kids = KidProfile.objects.filter(parent=request.user)
adults = UserProfile.objects.filter(user=request.user)
return render(request, 'profile.html', {'kids': kids}, {'adults': adults})
def update_profile(request):
form=FullUserDetailsForm(request.POST, request.FILES)
if form.is_valid():
request.user.first_name=form.cleaned_data['first_name']
request.user.last_name=form.cleaned_data['last_name']
request.user.email=form.cleaned_data['email']
request.user.profile.address1=form.cleaned_data['address1']
request.user.profile.address2=form.cleaned_data['address2']
request.user.profile.postcode=form.cleaned_data['postcode']
request.user.profile.phone=form.cleaned_data['phone']
request.user.profile.dob=form.cleaned_data['dob']
request.user.profile.gender=form.cleaned_data['gender']
request.user.profile.facebook=form.cleaned_data['facebook']
request.user.profile.twitter=form.cleaned_data['twitter']
request.user.profile.instagram=form.cleaned_data['instagram']
request.user.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def update_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def create_profile_kid(request):
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid=KidProfile()
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.parent=request.user
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def delete_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
kid.delete()
return redirect(reverse('profile'))
def login(request):
if request.method == 'POST':
form = UserLoginForm(request.POST)
if form.is_valid():
user = auth.authenticate(username=request.POST.get('username_or_email'),
password=request.POST.get('password'))
if user is not None:
auth.login(request, user)
messages.error(request, "You have successfully logged in")
if request.GET and request.GET['next'] !='':
next = request.GET['next']
return HttpResponseRedirect(next)
else:
return redirect(reverse('babysitters'))
else:
form.add_error(None, "Your username or password was not recognised")
else:
form = UserLoginForm()
args = {'form': form, 'next': request.GET['next'] if request.GET and 'next' in request.GET else ''}
args.update(csrf(request))
return render(request, 'login.html', args)
def logout(request):
auth.logout(request)
messages.success(request, 'You have successfully logged out')
return redirect(reverse('index'))
def register(request):
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
form.save()
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password1'))
if user:
auth.login(request, user)
messages.success(request, "You have successfully registered")
return redirect(reverse('profile'))
else:
messages.error(request, "unable to log you in at this time!")
else:
form = UserRegistrationForm()
args = {'form': form}
return render(request, 'profile.html', args)
urls.py
from django.conf.urls import url
from .views import register, profile, logout, login, update_profile, update_profile_kid, create_profile_kid, delete_profile_kid
urlpatterns = [
url(r'^register/$', register, name='register'),
url(r'^profile/$', profile, name='profile'),
url(r'^profile/update/$', update_profile, name='update_profile'),
url(r'^profile/kids/update/(?P<id>d+)$', update_profile_kid, name='update_profile_kid'),
url(r'^profile/kids/delete/(?P<id>d+)$', delete_profile_kid, name='delete_profile_kid'),
url(r'^profile/kids/create/$', create_profile_kid, name='create_profile_kid'),
url(r'^logout/$', logout, name='logout'),
url(r'^login', login, name='login'),
]
I am trying to debug the problem but I am so far unsuccessful. Can somebody help me or point me in the right direction.
javascript python html css django
add a comment |
I am getting a white error screen when I try to add an item via a form in python / django. I am trying to debug it but there is no information. Can somebody point me in the right direction?
Models.py
from __future__ import unicode_literals
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
# Create your models here.
class UserProfile(models.Model):
image = models.ImageField(upload_to='images', default='Upload Picture')
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
biography = models.TextField(max_length=280,blank=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
dob = models.CharField(max_length=10, blank=True)
gender = models.CharField(max_length=1, blank=True)
facebook = models.CharField(max_length=50, blank=True, null=True)
twitter = models.CharField(max_length=50, blank=True, null=True)
instagram = models.CharField(max_length=50, blank=True, null=True)
class KidProfile(models.Model):
parent = models.ForeignKey(User, related_name='kids')
name = models.CharField(max_length=255, null=True, blank=True)
dob = models.CharField(max_length=10, null=True, blank=True)
gender = models.CharField(max_length=1, null=True, blank=True)
needs = models.CharField(max_length=3, null=True, blank=True)
def __str__ (self):
return self.name
views.py
from django.contrib import messages, auth
from accounts.forms import UserRegistrationForm, UserLoginForm, FullUserDetailsForm, KidDetailsForm
from django.core.urlresolvers import reverse
from django.shortcuts import render, redirect, HttpResponseRedirect, HttpResponse, get_object_or_404
from django.template.context_processors import csrf
from django.contrib.auth.decorators import login_required
from .models import KidProfile, UserProfile
@login_required(login_url='/accounts/login')
def profile(request):
kids = KidProfile.objects.filter(parent=request.user)
adults = UserProfile.objects.filter(user=request.user)
return render(request, 'profile.html', {'kids': kids}, {'adults': adults})
def update_profile(request):
form=FullUserDetailsForm(request.POST, request.FILES)
if form.is_valid():
request.user.first_name=form.cleaned_data['first_name']
request.user.last_name=form.cleaned_data['last_name']
request.user.email=form.cleaned_data['email']
request.user.profile.address1=form.cleaned_data['address1']
request.user.profile.address2=form.cleaned_data['address2']
request.user.profile.postcode=form.cleaned_data['postcode']
request.user.profile.phone=form.cleaned_data['phone']
request.user.profile.dob=form.cleaned_data['dob']
request.user.profile.gender=form.cleaned_data['gender']
request.user.profile.facebook=form.cleaned_data['facebook']
request.user.profile.twitter=form.cleaned_data['twitter']
request.user.profile.instagram=form.cleaned_data['instagram']
request.user.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def update_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def create_profile_kid(request):
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid=KidProfile()
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.parent=request.user
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def delete_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
kid.delete()
return redirect(reverse('profile'))
def login(request):
if request.method == 'POST':
form = UserLoginForm(request.POST)
if form.is_valid():
user = auth.authenticate(username=request.POST.get('username_or_email'),
password=request.POST.get('password'))
if user is not None:
auth.login(request, user)
messages.error(request, "You have successfully logged in")
if request.GET and request.GET['next'] !='':
next = request.GET['next']
return HttpResponseRedirect(next)
else:
return redirect(reverse('babysitters'))
else:
form.add_error(None, "Your username or password was not recognised")
else:
form = UserLoginForm()
args = {'form': form, 'next': request.GET['next'] if request.GET and 'next' in request.GET else ''}
args.update(csrf(request))
return render(request, 'login.html', args)
def logout(request):
auth.logout(request)
messages.success(request, 'You have successfully logged out')
return redirect(reverse('index'))
def register(request):
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
form.save()
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password1'))
if user:
auth.login(request, user)
messages.success(request, "You have successfully registered")
return redirect(reverse('profile'))
else:
messages.error(request, "unable to log you in at this time!")
else:
form = UserRegistrationForm()
args = {'form': form}
return render(request, 'profile.html', args)
urls.py
from django.conf.urls import url
from .views import register, profile, logout, login, update_profile, update_profile_kid, create_profile_kid, delete_profile_kid
urlpatterns = [
url(r'^register/$', register, name='register'),
url(r'^profile/$', profile, name='profile'),
url(r'^profile/update/$', update_profile, name='update_profile'),
url(r'^profile/kids/update/(?P<id>d+)$', update_profile_kid, name='update_profile_kid'),
url(r'^profile/kids/delete/(?P<id>d+)$', delete_profile_kid, name='delete_profile_kid'),
url(r'^profile/kids/create/$', create_profile_kid, name='create_profile_kid'),
url(r'^logout/$', logout, name='logout'),
url(r'^login', login, name='login'),
]
I am trying to debug the problem but I am so far unsuccessful. Can somebody help me or point me in the right direction.
javascript python html css django
1
If you're on a local environment (your development machine), you should setDEBUG = True
in your settings.py file. That will show you the full error trace in the browser instead of just Error. Also regardless of theDEBUG
setting, you should be able to see the detailed error in your console (where you didmanage.py runserver
).
– dirkgroten
Nov 26 '18 at 15:47
add a comment |
I am getting a white error screen when I try to add an item via a form in python / django. I am trying to debug it but there is no information. Can somebody point me in the right direction?
Models.py
from __future__ import unicode_literals
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
# Create your models here.
class UserProfile(models.Model):
image = models.ImageField(upload_to='images', default='Upload Picture')
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
biography = models.TextField(max_length=280,blank=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
dob = models.CharField(max_length=10, blank=True)
gender = models.CharField(max_length=1, blank=True)
facebook = models.CharField(max_length=50, blank=True, null=True)
twitter = models.CharField(max_length=50, blank=True, null=True)
instagram = models.CharField(max_length=50, blank=True, null=True)
class KidProfile(models.Model):
parent = models.ForeignKey(User, related_name='kids')
name = models.CharField(max_length=255, null=True, blank=True)
dob = models.CharField(max_length=10, null=True, blank=True)
gender = models.CharField(max_length=1, null=True, blank=True)
needs = models.CharField(max_length=3, null=True, blank=True)
def __str__ (self):
return self.name
views.py
from django.contrib import messages, auth
from accounts.forms import UserRegistrationForm, UserLoginForm, FullUserDetailsForm, KidDetailsForm
from django.core.urlresolvers import reverse
from django.shortcuts import render, redirect, HttpResponseRedirect, HttpResponse, get_object_or_404
from django.template.context_processors import csrf
from django.contrib.auth.decorators import login_required
from .models import KidProfile, UserProfile
@login_required(login_url='/accounts/login')
def profile(request):
kids = KidProfile.objects.filter(parent=request.user)
adults = UserProfile.objects.filter(user=request.user)
return render(request, 'profile.html', {'kids': kids}, {'adults': adults})
def update_profile(request):
form=FullUserDetailsForm(request.POST, request.FILES)
if form.is_valid():
request.user.first_name=form.cleaned_data['first_name']
request.user.last_name=form.cleaned_data['last_name']
request.user.email=form.cleaned_data['email']
request.user.profile.address1=form.cleaned_data['address1']
request.user.profile.address2=form.cleaned_data['address2']
request.user.profile.postcode=form.cleaned_data['postcode']
request.user.profile.phone=form.cleaned_data['phone']
request.user.profile.dob=form.cleaned_data['dob']
request.user.profile.gender=form.cleaned_data['gender']
request.user.profile.facebook=form.cleaned_data['facebook']
request.user.profile.twitter=form.cleaned_data['twitter']
request.user.profile.instagram=form.cleaned_data['instagram']
request.user.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def update_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def create_profile_kid(request):
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid=KidProfile()
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.parent=request.user
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def delete_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
kid.delete()
return redirect(reverse('profile'))
def login(request):
if request.method == 'POST':
form = UserLoginForm(request.POST)
if form.is_valid():
user = auth.authenticate(username=request.POST.get('username_or_email'),
password=request.POST.get('password'))
if user is not None:
auth.login(request, user)
messages.error(request, "You have successfully logged in")
if request.GET and request.GET['next'] !='':
next = request.GET['next']
return HttpResponseRedirect(next)
else:
return redirect(reverse('babysitters'))
else:
form.add_error(None, "Your username or password was not recognised")
else:
form = UserLoginForm()
args = {'form': form, 'next': request.GET['next'] if request.GET and 'next' in request.GET else ''}
args.update(csrf(request))
return render(request, 'login.html', args)
def logout(request):
auth.logout(request)
messages.success(request, 'You have successfully logged out')
return redirect(reverse('index'))
def register(request):
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
form.save()
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password1'))
if user:
auth.login(request, user)
messages.success(request, "You have successfully registered")
return redirect(reverse('profile'))
else:
messages.error(request, "unable to log you in at this time!")
else:
form = UserRegistrationForm()
args = {'form': form}
return render(request, 'profile.html', args)
urls.py
from django.conf.urls import url
from .views import register, profile, logout, login, update_profile, update_profile_kid, create_profile_kid, delete_profile_kid
urlpatterns = [
url(r'^register/$', register, name='register'),
url(r'^profile/$', profile, name='profile'),
url(r'^profile/update/$', update_profile, name='update_profile'),
url(r'^profile/kids/update/(?P<id>d+)$', update_profile_kid, name='update_profile_kid'),
url(r'^profile/kids/delete/(?P<id>d+)$', delete_profile_kid, name='delete_profile_kid'),
url(r'^profile/kids/create/$', create_profile_kid, name='create_profile_kid'),
url(r'^logout/$', logout, name='logout'),
url(r'^login', login, name='login'),
]
I am trying to debug the problem but I am so far unsuccessful. Can somebody help me or point me in the right direction.
javascript python html css django
I am getting a white error screen when I try to add an item via a form in python / django. I am trying to debug it but there is no information. Can somebody point me in the right direction?
Models.py
from __future__ import unicode_literals
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
# Create your models here.
class UserProfile(models.Model):
image = models.ImageField(upload_to='images', default='Upload Picture')
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
biography = models.TextField(max_length=280,blank=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
dob = models.CharField(max_length=10, blank=True)
gender = models.CharField(max_length=1, blank=True)
facebook = models.CharField(max_length=50, blank=True, null=True)
twitter = models.CharField(max_length=50, blank=True, null=True)
instagram = models.CharField(max_length=50, blank=True, null=True)
class KidProfile(models.Model):
parent = models.ForeignKey(User, related_name='kids')
name = models.CharField(max_length=255, null=True, blank=True)
dob = models.CharField(max_length=10, null=True, blank=True)
gender = models.CharField(max_length=1, null=True, blank=True)
needs = models.CharField(max_length=3, null=True, blank=True)
def __str__ (self):
return self.name
views.py
from django.contrib import messages, auth
from accounts.forms import UserRegistrationForm, UserLoginForm, FullUserDetailsForm, KidDetailsForm
from django.core.urlresolvers import reverse
from django.shortcuts import render, redirect, HttpResponseRedirect, HttpResponse, get_object_or_404
from django.template.context_processors import csrf
from django.contrib.auth.decorators import login_required
from .models import KidProfile, UserProfile
@login_required(login_url='/accounts/login')
def profile(request):
kids = KidProfile.objects.filter(parent=request.user)
adults = UserProfile.objects.filter(user=request.user)
return render(request, 'profile.html', {'kids': kids}, {'adults': adults})
def update_profile(request):
form=FullUserDetailsForm(request.POST, request.FILES)
if form.is_valid():
request.user.first_name=form.cleaned_data['first_name']
request.user.last_name=form.cleaned_data['last_name']
request.user.email=form.cleaned_data['email']
request.user.profile.address1=form.cleaned_data['address1']
request.user.profile.address2=form.cleaned_data['address2']
request.user.profile.postcode=form.cleaned_data['postcode']
request.user.profile.phone=form.cleaned_data['phone']
request.user.profile.dob=form.cleaned_data['dob']
request.user.profile.gender=form.cleaned_data['gender']
request.user.profile.facebook=form.cleaned_data['facebook']
request.user.profile.twitter=form.cleaned_data['twitter']
request.user.profile.instagram=form.cleaned_data['instagram']
request.user.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def update_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def create_profile_kid(request):
form=KidDetailsForm(request.POST, request.FILES)
if form.is_valid():
kid=KidProfile()
kid.name=form.cleaned_data['name']
kid.dob=form.cleaned_data['dob']
kid.gender=form.cleaned_data['gender']
kid.needs=form.cleaned_data['needs']
kid.parent=request.user
kid.save()
return redirect(reverse('profile'))
else:
return HttpResponse("Error")
def delete_profile_kid(request, id):
kid = get_object_or_404(KidProfile, pk=id)
kid.delete()
return redirect(reverse('profile'))
def login(request):
if request.method == 'POST':
form = UserLoginForm(request.POST)
if form.is_valid():
user = auth.authenticate(username=request.POST.get('username_or_email'),
password=request.POST.get('password'))
if user is not None:
auth.login(request, user)
messages.error(request, "You have successfully logged in")
if request.GET and request.GET['next'] !='':
next = request.GET['next']
return HttpResponseRedirect(next)
else:
return redirect(reverse('babysitters'))
else:
form.add_error(None, "Your username or password was not recognised")
else:
form = UserLoginForm()
args = {'form': form, 'next': request.GET['next'] if request.GET and 'next' in request.GET else ''}
args.update(csrf(request))
return render(request, 'login.html', args)
def logout(request):
auth.logout(request)
messages.success(request, 'You have successfully logged out')
return redirect(reverse('index'))
def register(request):
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
form.save()
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password1'))
if user:
auth.login(request, user)
messages.success(request, "You have successfully registered")
return redirect(reverse('profile'))
else:
messages.error(request, "unable to log you in at this time!")
else:
form = UserRegistrationForm()
args = {'form': form}
return render(request, 'profile.html', args)
urls.py
from django.conf.urls import url
from .views import register, profile, logout, login, update_profile, update_profile_kid, create_profile_kid, delete_profile_kid
urlpatterns = [
url(r'^register/$', register, name='register'),
url(r'^profile/$', profile, name='profile'),
url(r'^profile/update/$', update_profile, name='update_profile'),
url(r'^profile/kids/update/(?P<id>d+)$', update_profile_kid, name='update_profile_kid'),
url(r'^profile/kids/delete/(?P<id>d+)$', delete_profile_kid, name='delete_profile_kid'),
url(r'^profile/kids/create/$', create_profile_kid, name='create_profile_kid'),
url(r'^logout/$', logout, name='logout'),
url(r'^login', login, name='login'),
]
I am trying to debug the problem but I am so far unsuccessful. Can somebody help me or point me in the right direction.
javascript python html css django
javascript python html css django
edited Nov 26 '18 at 15:47
mplungjan
88.4k21125182
88.4k21125182
asked Nov 26 '18 at 15:45
Pierce O'NeillPierce O'Neill
121312
121312
1
If you're on a local environment (your development machine), you should setDEBUG = True
in your settings.py file. That will show you the full error trace in the browser instead of just Error. Also regardless of theDEBUG
setting, you should be able to see the detailed error in your console (where you didmanage.py runserver
).
– dirkgroten
Nov 26 '18 at 15:47
add a comment |
1
If you're on a local environment (your development machine), you should setDEBUG = True
in your settings.py file. That will show you the full error trace in the browser instead of just Error. Also regardless of theDEBUG
setting, you should be able to see the detailed error in your console (where you didmanage.py runserver
).
– dirkgroten
Nov 26 '18 at 15:47
1
1
If you're on a local environment (your development machine), you should set
DEBUG = True
in your settings.py file. That will show you the full error trace in the browser instead of just Error. Also regardless of the DEBUG
setting, you should be able to see the detailed error in your console (where you did manage.py runserver
).– dirkgroten
Nov 26 '18 at 15:47
If you're on a local environment (your development machine), you should set
DEBUG = True
in your settings.py file. That will show you the full error trace in the browser instead of just Error. Also regardless of the DEBUG
setting, you should be able to see the detailed error in your console (where you did manage.py runserver
).– dirkgroten
Nov 26 '18 at 15:47
add a comment |
1 Answer
1
active
oldest
votes
Your views return just the string "Error" with no information in certain cases. That's what you see.
You should never return HttpResponse("Error")
because that just returns a document with the text "Error" to the browser.
When your forms are not valid, you should just return the same page with the bound, invalid form and show the form errors to the user.
Read the Forms documentation and especially how to create a view that handles the three states of a form (unbound, bound invalid and bound valid) properly.
In general one view should handle it like this:
- If your
request.method
isGET
you create the unbound, empty form (or with someinitial
values). You then return the template with this form so the user can fill it in. - If your
request.method
isPOST
you create the bound form and check if it's valid.
- If valid, you save and redirect.
- If not valid, you also return the template with the bound form (same as the
GET
case). And now your template displays the form with the values that the user filled in previously and the errors so the user can correct them and try again.
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53484630%2fwhite-error-screen-appears-when-i-try-to-update-from-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your views return just the string "Error" with no information in certain cases. That's what you see.
You should never return HttpResponse("Error")
because that just returns a document with the text "Error" to the browser.
When your forms are not valid, you should just return the same page with the bound, invalid form and show the form errors to the user.
Read the Forms documentation and especially how to create a view that handles the three states of a form (unbound, bound invalid and bound valid) properly.
In general one view should handle it like this:
- If your
request.method
isGET
you create the unbound, empty form (or with someinitial
values). You then return the template with this form so the user can fill it in. - If your
request.method
isPOST
you create the bound form and check if it's valid.
- If valid, you save and redirect.
- If not valid, you also return the template with the bound form (same as the
GET
case). And now your template displays the form with the values that the user filled in previously and the errors so the user can correct them and try again.
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
add a comment |
Your views return just the string "Error" with no information in certain cases. That's what you see.
You should never return HttpResponse("Error")
because that just returns a document with the text "Error" to the browser.
When your forms are not valid, you should just return the same page with the bound, invalid form and show the form errors to the user.
Read the Forms documentation and especially how to create a view that handles the three states of a form (unbound, bound invalid and bound valid) properly.
In general one view should handle it like this:
- If your
request.method
isGET
you create the unbound, empty form (or with someinitial
values). You then return the template with this form so the user can fill it in. - If your
request.method
isPOST
you create the bound form and check if it's valid.
- If valid, you save and redirect.
- If not valid, you also return the template with the bound form (same as the
GET
case). And now your template displays the form with the values that the user filled in previously and the errors so the user can correct them and try again.
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
add a comment |
Your views return just the string "Error" with no information in certain cases. That's what you see.
You should never return HttpResponse("Error")
because that just returns a document with the text "Error" to the browser.
When your forms are not valid, you should just return the same page with the bound, invalid form and show the form errors to the user.
Read the Forms documentation and especially how to create a view that handles the three states of a form (unbound, bound invalid and bound valid) properly.
In general one view should handle it like this:
- If your
request.method
isGET
you create the unbound, empty form (or with someinitial
values). You then return the template with this form so the user can fill it in. - If your
request.method
isPOST
you create the bound form and check if it's valid.
- If valid, you save and redirect.
- If not valid, you also return the template with the bound form (same as the
GET
case). And now your template displays the form with the values that the user filled in previously and the errors so the user can correct them and try again.
Your views return just the string "Error" with no information in certain cases. That's what you see.
You should never return HttpResponse("Error")
because that just returns a document with the text "Error" to the browser.
When your forms are not valid, you should just return the same page with the bound, invalid form and show the form errors to the user.
Read the Forms documentation and especially how to create a view that handles the three states of a form (unbound, bound invalid and bound valid) properly.
In general one view should handle it like this:
- If your
request.method
isGET
you create the unbound, empty form (or with someinitial
values). You then return the template with this form so the user can fill it in. - If your
request.method
isPOST
you create the bound form and check if it's valid.
- If valid, you save and redirect.
- If not valid, you also return the template with the bound form (same as the
GET
case). And now your template displays the form with the values that the user filled in previously and the errors so the user can correct them and try again.
edited Nov 26 '18 at 15:59
answered Nov 26 '18 at 15:51
dirkgrotendirkgroten
4,76811221
4,76811221
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
add a comment |
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
Thank you. I will try this answer. I just noticed this Error now. Thanks again.
– Pierce O'Neill
Nov 26 '18 at 15:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53484630%2fwhite-error-screen-appears-when-i-try-to-update-from-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
If you're on a local environment (your development machine), you should set
DEBUG = True
in your settings.py file. That will show you the full error trace in the browser instead of just Error. Also regardless of theDEBUG
setting, you should be able to see the detailed error in your console (where you didmanage.py runserver
).– dirkgroten
Nov 26 '18 at 15:47