User Login in django

4 views
Skip to first unread message

Denis Bahati

unread,
Nov 3, 2009, 7:37:20 AM11/3/09
to django...@googlegroups.com
Hi there,
Am creating a login screen using django form but failing to get the concept on how can i query from the database to get the user verified as a registered user. I want that a user is validated and displayed with his/her profile as well update  his/her profile. The user can view only the allowed pages not viewing other pages.
Here is my model for registering users and the form.
class User(models.Model):
title = models.ForeignKey(Title)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
address = models.TextField()
roles = models.ManyToManyField(Role)
username = models.CharField(max_length=30)
password = models.CharField(max_length=30)
date_added = models.DateTimeField()
def __unicode__(self):
return '%s %s %s' %(self.title, self.first_name, self.last_name)

class UserForm(ModelForm):
    date_added=forms.DateField()
    class Meta:
        model = User

class User(forms.Form):
username = models.CharField(max_length=30)
password = models.CharField(max_length=30)

bruno desthuilliers

unread,
Nov 3, 2009, 8:32:31 AM11/3/09
to Django users
On 3 nov, 13:37, Denis Bahati <djma...@gmail.com> wrote:
> Hi there,
> Am creating a login screen using django form but failing to get the concept
> on how can i query from the database to get the user verified as a
> registered user.

Do you have a real need for reinventing the wheel ?

http://docs.djangoproject.com/en/dev/topics/auth/

Denis Bahati

unread,
Nov 3, 2009, 11:26:46 PM11/3/09
to django...@googlegroups.com
Am real need to reinvent the wheel because i have a project which needs to define some user roles, and enable users to update the status of their own properties and not the other property. Thanks in advance for any help you give me.

Daniel Roseman

unread,
Nov 4, 2009, 4:31:17 AM11/4/09
to Django users
On Nov 4, 4:26 am, Denis Bahati <djma...@gmail.com> wrote:
> Am real need to reinvent the wheel because i have a project which needs to
> define some user roles, and enable users to update the status of their own
> properties and not the other property. Thanks in advance for any help you
> give me.
>

Then use a UserProfile linked to the auth.User object.
--
DR.

Julien Petitperrin

unread,
Nov 4, 2009, 4:38:23 AM11/4/09
to django...@googlegroups.com
On Wed, Nov 4, 2009 at 10:31 AM, Daniel Roseman <dan...@roseman.org.uk> wrote:

On Nov 4, 4:26 am, Denis Bahati <djma...@gmail.com> wrote:
> Am real need to reinvent the wheel because i have a project which needs to
> define some user roles, and enable users to update the status of their own
> properties and not the other property. Thanks in advance for any help you
> give me.

Or just create your own authentication backends using your User models, Django will be able to handle session as usual and you will have what you want for your user model

 http://docs.djangoproject.com/en/dev/topics/auth/#specifying-authentication-backends

I hope this helps,

Julien
Reply all
Reply to author
Forward
0 new messages