prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  I can't add members in the Django admin page.
  I can't add members in the Django admin page.
  
  steps
  - Add a member in the admin page (click a SAVE button).
    - <img width="1273" alt="スクリーンショット 2022-01-27 9 52 17" src="https://user-images.githubusercontent.com/20487308/151271702-bf60ae7e-f131-45fe-8314-e7726e90f90c.png">
  - However, I get a 500 error.
    - <img width="1085" alt="スクリーンショット 2022-01-27 9 53 08" src="https://user-images.githubusercontent.com/20487308/151271872-c3fa75e8-c491-4aff-b88e-c9d970406ede.png">
  - The endpoints of the POST request are different between admin page and member page.
    - `POST /admin/members/member/add/`
    - `POST /v1/projects/1/members`
  
  Environment
  ---------
  doccano v1.5.5
  
  
  </issue>
  <code>
  [start of backend/members/models.py]
  1 from django.conf import settings
  2 from django.contrib.auth.models import User
  3 from django.core.exceptions import ValidationError
  4 from django.db import models
  5 
  6 from django.db.models import Manager
  7 
  8 from api.models import Project
  9 from roles.models import Role
  10 
  11 
  12 class MemberManager(Manager):
  13 
  14     def can_update(self, project: int, member_id: int, new_role: str) -> bool:
  15         """The project needs at least 1 admin.
  16 
  17         Args:
  18             project: The project id.
  19             member_id: The member id.
  20             new_role: The new role name.
  21 
  22         Returns:
  23             Whether the mapping can be updated or not.
  24         """
  25         queryset = self.filter(
  26             project=project, role__name=settings.ROLE_PROJECT_ADMIN
  27         )
  28         if queryset.count() > 1:
  29             return True
  30         else:
  31             admin = queryset.first()
  32             # we can change the role except for the only admin.
  33             return admin.id != member_id or new_role == settings.ROLE_PROJECT_ADMIN
  34 
  35     def has_role(self, project_id: int, user: User, role_name: str):
  36         return self.filter(project=project_id, user=user, role__name=role_name).exists()
  37 
  38 
  39 class Member(models.Model):
  40     user = models.ForeignKey(
  41         to=User,
  42         on_delete=models.CASCADE,
  43         related_name='role_mappings'
  44     )
  45     project = models.ForeignKey(
  46         to=Project,
  47         on_delete=models.CASCADE,
  48         related_name='role_mappings'
  49     )
  50     role = models.ForeignKey(
  51         to=Role,
  52         on_delete=models.CASCADE
  53     )
  54     created_at = models.DateTimeField(auto_now_add=True)
  55     updated_at = models.DateTimeField(auto_now=True)
  56     objects = MemberManager()
  57 
  58     def clean(self):
  59         members = self.objects.exclude(id=self.id)
  60         if members.filter(user=self.user, project=self.project).exists():
  61             message = 'This user is already assigned to a role in this project.'
  62             raise ValidationError(message)
  63 
  64     @property
  65     def username(self):
  66         return self.user.username
  67 
  68     class Meta:
  69         unique_together = ('user', 'project')
  70
  [end of backend/members/models.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/backend/members/models.py b/backend/members/models.py
  --- a/backend/members/models.py
  +++ b/backend/members/models.py
  @@ -56,7 +56,7 @@
       objects = MemberManager()
   
       def clean(self):
  -        members = self.objects.exclude(id=self.id)
  +        members = self.__class__.objects.exclude(id=self.id)
           if members.filter(user=self.user, project=self.project).exists():
               message = 'This user is already assigned to a role in this project.'
               raise ValidationError(message)
  
verification_info: {"golden_diff": "diff --git a/backend/members/models.py b/backend/members/models.py\n--- a/backend/members/models.py\n+++ b/backend/members/models.py\n@@ -56,7 +56,7 @@\n     objects = MemberManager()\n \n     def clean(self):\n-        members = self.objects.exclude(id=self.id)\n+        members = self.__class__.objects.exclude(id=self.id)\n         if members.filter(user=self.user, project=self.project).exists():\n             message = 'This user is already assigned to a role in this project.'\n             raise ValidationError(message)\n", "issue": "I can't add members in the Django admin page.\nI can't add members in the Django admin page.\r\n\r\nsteps\r\n- Add a member in the admin page (click a SAVE button).\r\n  - <img width=\"1273\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2022-01-27 9 52 17\" src=\"https://user-images.githubusercontent.com/20487308/151271702-bf60ae7e-f131-45fe-8314-e7726e90f90c.png\">\r\n- However, I get a 500 error.\r\n  - <img width=\"1085\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2022-01-27 9 53 08\" src=\"https://user-images.githubusercontent.com/20487308/151271872-c3fa75e8-c491-4aff-b88e-c9d970406ede.png\">\r\n- The endpoints of the POST request are different between admin page and member page.\r\n  - `POST /admin/members/member/add/`\r\n  - `POST /v1/projects/1/members`\r\n\r\nEnvironment\r\n---------\r\ndoccano v1.5.5\r\n\n", "before_files": [{"content": "from django.conf import settings\nfrom django.contrib.auth.models import User\nfrom django.core.exceptions import ValidationError\nfrom django.db import models\n\nfrom django.db.models import Manager\n\nfrom api.models import Project\nfrom roles.models import Role\n\n\nclass MemberManager(Manager):\n\n    def can_update(self, project: int, member_id: int, new_role: str) -> bool:\n        \"\"\"The project needs at least 1 admin.\n\n        Args:\n            project: The project id.\n            member_id: The member id.\n            new_role: The new role name.\n\n        Returns:\n            Whether the mapping can be updated or not.\n        \"\"\"\n        queryset = self.filter(\n            project=project, role__name=settings.ROLE_PROJECT_ADMIN\n        )\n        if queryset.count() > 1:\n            return True\n        else:\n            admin = queryset.first()\n            # we can change the role except for the only admin.\n            return admin.id != member_id or new_role == settings.ROLE_PROJECT_ADMIN\n\n    def has_role(self, project_id: int, user: User, role_name: str):\n        return self.filter(project=project_id, user=user, role__name=role_name).exists()\n\n\nclass Member(models.Model):\n    user = models.ForeignKey(\n        to=User,\n        on_delete=models.CASCADE,\n        related_name='role_mappings'\n    )\n    project = models.ForeignKey(\n        to=Project,\n        on_delete=models.CASCADE,\n        related_name='role_mappings'\n    )\n    role = models.ForeignKey(\n        to=Role,\n        on_delete=models.CASCADE\n    )\n    created_at = models.DateTimeField(auto_now_add=True)\n    updated_at = models.DateTimeField(auto_now=True)\n    objects = MemberManager()\n\n    def clean(self):\n        members = self.objects.exclude(id=self.id)\n        if members.filter(user=self.user, project=self.project).exists():\n            message = 'This user is already assigned to a role in this project.'\n            raise ValidationError(message)\n\n    @property\n    def username(self):\n        return self.user.username\n\n    class Meta:\n        unique_together = ('user', 'project')\n", "path": "backend/members/models.py"}]}