Of the top of my head, but would the following be helpful? user, new = User.objects.get_or_create(username = user, email = email)
The function returns either: - a new user object and True if the user didn't exist yet (and had to be created); - an object with existing user data and False. Mind that you still have to call user.save() in case of a new user. On Aug 5, 11:42 pm, Aljosa Mohorovic <[EMAIL PROTECTED]> wrote: > i'm currently looking at django.contrib.auth and wondering what is the > correct way to check if user already exists? > before i call User.objects.create_user() i want to know that user with > submitted username and email doesn't exist. > my current situation is that i call > User.objects.get(username__exact=user) and > User.objects.get(email__exact=email) and if i get exception > "DoesNotExist: User matching query does not exist." and i assume that > it's ok to create new user. > > i'm sure there is a better way to check if user with submitted > username or email already exists, please share your ways... > > Aljosa --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---