In my project I get a DoesNotExist error whenever I try to set permissions after a POST.
My models.py
class Project(models.Model):
# Leader of the project
project_name = models.CharField(max_length=200, unique=True)
# The url for the stash repository
#project_repo = models.
# Date the project was created
date_created = models.DateTimeField(auto_now=True)
# Person in charge of the project
project_lead = models.ForeignKey(User, related_name='%(class)s_lead_set')
# Group of members to use for permission checking
members = models.ForeignKey(Group, null=True, default=None)
class Meta:
permissions = (
('edit_project', 'Edit Project'),
)
My views.py
@login_required
def create(request):
if request.method== "POST":
form = NewProjectForm(request.POST)
if form.is_valid():
# Create the new project
project = Project(**form.cleaned_data)
project.project_lead = request.user
# Create a user group
members = Group.objects.create(name = project.project_name)
members.save()
# Add the members group to the project
project.members = members
project.save()
assign_perm('edit', members, project)
members.save()
I'm an idiot and didn't realize that my permissions didn't match between my model and my view.
Ticket closed.
I have version 2.2 of djnago with the djnago guardian 2
i use the shortcut
assign_perm('can_add_widget', group, obj)
and I get django.contrib.auth.models.Permission.DoesNotExist: Permission matching query does not exist.
Most helpful comment
I have version 2.2 of djnago with the djnago guardian 2
i use the shortcut
assign_perm('can_add_widget', group, obj)
and I get django.contrib.auth.models.Permission.DoesNotExist: Permission matching query does not exist.