Your Ad Here

Wednesday, January 11, 2012

Re: Help me with django Form

Can you provide your register model?

Is it possible that you've extended the user model and that your username, password etc is getting stored inside auth_user table?


On 12 January 2012 12:49, coded kid <duffleboi911@gmail.com> wrote:
Hi guys, I've been trying to signup using the django form I created.
Whenever I signup, the form is always saving the id no and not other
fields like names, username.pasword,email etc. Below are the codes;
In views.py:
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.template import RequestContext
from django.http import HttpResponseRedirect
from mymeek.meekme import models
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def welcome(request):
   #Allow new user reg and login, if failed direct the user to signup
   if request.method=='POST':
       form=models.Register()
       new_user=form.save()
       return HttpResponseRedirect('/logpage/')
   else:
       form=models.Register()
       return render_to_response('mainpage.html',
{'form':models.Register})

In Models.py
from django.db import models
class Register(models.Model):
   names=models.CharField(max_length=50)
   email=models.EmailField('e-mail', blank=False)
   password=models.CharField(max_length=25)
   username=models.CharField(max_length=25)
   country=models.CharField(max_length=40)
   state_province=models.CharField(max_length=30)

   def __unicode__(self):
       return self.names

In Template Form:
<html>
<form action="." method="POST"> {% csrf_token %}
Names: <input type="text" name="names"/><br/>
Email Address: <input type="text" name="email address"/><br />
Password: <input type="text" name="password"/><br />
Username: <input type="text" name="username"/><br />
Country: <input type="text" name="country"/><br />
State: <input type="text" name="state"/><br />
<input type="submit" value="Sign Up"/><br />
</form>
</html>
Please where I've I done something wrong? Help me out!

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 comments:

Post a Comment