Re: post data always empty
On Apr 10, 2006, at 10:53 PM, [EMAIL PROTECTED] wrote: > > I was wondering if somebody could help me out. i'm trying to write a > simple form to create users ... however the post data always seems to > be empty. > > And here's the view: > > from django.core.template import Context, loader > from django.utils.httpwrappers import HttpResponse, > HttpResponseRedirect > > from django.models.gms import chapters, Member > from django.models.auth import users > > def createAccount(request): > """ > Create new account view. > """ > t = loader.get_template('gms/CreateAccount') > errors = request > if request.POST: > data = request.POST > return HttpResponseRedirect('/member') > # Check that passwords are equal. > if data['password'] != data['confirmpassword']: >errors = 'Passwords do not match!' > else: Not sure what you're trying to do here, but you're returning immediately without handling the POSTed data: if request.POST: data = request.POST return HttpResponseRedirect('/member') Fix this first, then move on to the other fixes suggested in this thread. Don --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: post data always empty
> > I was wondering if somebody could help me out. i'm trying to write a > simple form to create users ... however the post data always seems to > be empty. this is not the django way of doing things. Use add/change manipulators to create your forms - you are doing it by hand kg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: post data always empty
[EMAIL PROTECTED] wrote: > I was wondering if somebody could help me out. i'm trying to write a > simple form to create users ... however the post data always seems to > be empty. > > Here's the template: > > http://code.djangoproject.com/wiki/NewbieMistakes#POSTtoviewslosesPOSTdata -- --Max Battcher-- http://www.worldmaker.net/ "I'm gonna win, trust in me / I have come to save this world / and in the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: post data always empty
On 4/11/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I was wondering if somebody could help me out. i'm trying to write a > simple form to create users ... however the post data always seems to > be empty. > [snip] Please check this document first: http://code.djangoproject.com/wiki/NewbieMistakes -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
post data always empty
I was wondering if somebody could help me out. i'm trying to write a simple form to create users ... however the post data always seems to be empty. Here's the template: {% extends "base" %} {% block heading %} Welcome to Greek Life Management System, complete the information below to create a new account. {% endblock %} {% block content %} Create a new account {% if errors %} {{errors}} {% endif %} First Name: Last Name: E-Mail: Username: Password: Confirm password: What chapter do you belong to? {% for option in chapters %} {{ option.title }} {% endfor %} {% endblock %} And here's the view: from django.core.template import Context, loader from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect from django.models.gms import chapters, Member from django.models.auth import users def createAccount(request): """ Create new account view. """ t = loader.get_template('gms/CreateAccount') errors = request if request.POST: data = request.POST return HttpResponseRedirect('/member') # Check that passwords are equal. if data['password'] != data['confirmpassword']: errors = 'Passwords do not match!' else: # Check that username does not already exist. try: user = users.get_object(username__exact=data['username']) errors = 'Username already exists!' except: # Validation done, create user and member user = users.create_user(data['username'], data['email'], data['password']) user.first_name = data['first_name'] user.last_name = data['last_name'] user.save() # get the chapter chapter = chaptesr.get_object(id__exact=data['chapter']) member = Member(chapter=chapter, user=user, verified=False) member.save() # Created the user, notify the user. return HttpResponseRedirect('/members/%s' % user.username) c = Context({'title': 'Create Account', 'navigation': 'nav/none', 'chapters': chapters.get_list(), 'errors': errors, }) return HttpResponse(t.render(c)) Thanks for any help! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---