DoesNotExist: Group matching query does not exist.

4,564 views
Skip to first unread message

Robin Fourcade

unread,
Nov 11, 2015, 10:14:41 PM11/11/15
to Django users
Hi,
I'm working with the auth library.

I've imported all of these:

from django.shortcuts import render, redirect
from pizza_club_order.forms import *
from pizza_club_order.models import *
from django.contrib import auth
from datetime import timedelta, date, datetime, time

But when I'm trying to do this:

auth.models.Group.objects.get(name='test')


Here's the error I get:


Traceback (most recent call last):

  File "<console>", line 1, in <module>

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 127, in manager_method

    return getattr(self.get_queryset(), name)(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 334, in get

    self.model._meta.object_name

DoesNotExist: Group matching query does not exist.


Can someone help me ?


Thanks,

Robin.

Vijay Khemlani

unread,
Nov 11, 2015, 10:42:31 PM11/11/15
to django...@googlegroups.com
It seems you don't have any groups in your database with the name "test"

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c4a83bd3-b32a-49cf-9e7e-65c819d143eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robin Fourcade

unread,
Nov 12, 2015, 8:27:10 AM11/12/15
to Django users
Thanks for your reply,
It was in the DB but, I don't know why, I had this issue. I made the migration a second time and this time, it worked.

Thanks,
Robin.

-- Solved.

James Schneider

unread,
Nov 12, 2015, 10:14:06 AM11/12/15
to django...@googlegroups.com

>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 334, in get
>
>     self.model._meta.object_name
>
> DoesNotExist: Group matching query does not exist.
>
>
> Can someone help me ?
>

BTW, this is a standard exception raised by Django for queryset operations that act on single objects that are not found, most commonly for .get(). If there's a chance you'll hit this during normal operation, you'll need to catch the exception and handle it accordingly, or it will turn into a 500 error in the browser.

https://docs.djangoproject.com/en/1.8/ref/models/instances/#doesnotexist

-James

Reply all
Reply to author
Forward
0 new messages