1 Commits

Author SHA1 Message Date
6332b49eac Fixed Ticket#01 2016-02-15 18:02:39 +01:00

View File

@@ -38,7 +38,12 @@ from tipp.forms import *
from openliga import *
from datetime import datetime
from PIL import Image as PImage
import urllib2, pytz, os
import urllib2, pytz, os, sys
# setting utf-8 as default encoding to avoid errors in file
# uploads and form data
reload(sys)
sys.setdefaultencoding('utf8')
timezoneLocal = pytz.timezone('Europe/Berlin')
@@ -68,25 +73,17 @@ def profile(request, pk):
# If it's a HTTP POST, we're interested in processing form data.
if request.method == 'POST':
# Attempt to grab information from the raw form information.
# Note that we make use of both UserForm and UserProfileForm.
user_form = UserForm(data=request.POST, instance=user)
profile_form = UserProfileForm(data=request.POST, instance=profile)
# If the two forms are valid...
if user_form.is_valid() and profile_form.is_valid():
# Save the user's form data to the database.
user = user_form.save()
# Now sort out the UserProfile instance.
# Since we need to set the user attribute ourselves, we set commit=False.
# This delays saving the model until we're ready to avoid integrity problems.
profile = profile_form.save(commit=False)
profile.user = user
# Did the user provide a profile picture?
# If so, we need to get it from the input form and put it in the UserProfile model.
if 'avatar' in request.FILES:
profile.avatar = request.FILES['avatar']
# Now we save the UserProfile model instance.