Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def start(request):
- try:
- username = request.POST['username']
- password = request.POST['password']
- except (KeyError):
- return render_to_response('user/start.html')
- user = authenticate(username=username, password=password)
- if user is not None:
- if user.is_active:
- try:
- UserProfile.objects.get(username=user)
- except:
- editprofileform = EditProfileForm()
- msg = "Welcome. \n Please fill out your personal information below in order to proceed to the site."
- return render_to_response('user/editprofile.html', {'user': user, 'msg': msg, 'editprofileform': editprofileform})
- [snip]
- @login_required
- def editprofile(request):
- if request.method == 'POST':
- requestprofile = EditProfileForm(request.POST)
- if requestprofile.is_valid():
- insertuserprofile = UserProfile()
- insertuserprofile.username = User.objects.get(id=request.user.id)
- insertuserprofile.save()
- addartist = Artists(name = request.POST['band'])
- addartist.save()
- insertuserprofile.band.add(addartist)
- #( UserProfile.objects.create(band=request.POST['band']))
- insertuserprofile.address = request.POST['address']
- insertuserprofile.city = request.POST['city']
- insertuserprofile.zip = request.POST['zip']
- insertuserprofile.age = request.POST['age_year']+"-"+request.POST['age_month']+"-"+request.POST['age_day']
- insertuserprofile.save()
- msg = "Thank you! Your user profile has been updated successfully"
- return render_to_response('user/result.html', {'user': request.user, 'msg': msg})
- editprofileform = EditProfileForm()
- return render_to_response('user/editprofile.html', {'user': request.user, 'editprofileform': editprofileform})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement