File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Generated by Django 4.1 on 2022-08-31 11:26
2+
3+ from django .conf import settings
4+ from django .db import migrations , models
5+
6+
7+ class Migration (migrations .Migration ):
8+
9+ dependencies = [
10+ migrations .swappable_dependency (settings .AUTH_USER_MODEL ),
11+ ("community_db" , "0004_person_user" ),
12+ ]
13+
14+ operations = [
15+ migrations .RemoveField (
16+ model_name = "person" ,
17+ name = "user" ,
18+ ),
19+ migrations .AddField (
20+ model_name = "person" ,
21+ name = "users" ,
22+ field = models .ManyToManyField (to = settings .AUTH_USER_MODEL ),
23+ ),
24+ ]
Original file line number Diff line number Diff line change @@ -285,9 +285,7 @@ class Countries(models.TextChoices):
285285 last_name = models .CharField (max_length = 100 )
286286 country = models .CharField (max_length = 100 , choices = Countries .choices , blank = True )
287287 mobile_number = models .CharField (max_length = 20 , blank = True )
288- user = models .ForeignKey (
289- settings .AUTH_USER_MODEL , null = True , on_delete = models .SET_NULL
290- )
288+ users = models .ManyToManyField (settings .AUTH_USER_MODEL )
291289
292290 class Meta :
293291 permissions = [
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def detail_person_with_template(request, pk):
3535def edit_person_with_template (request , pk ):
3636 person = get_object_or_404 (Person , id = pk )
3737
38- if person .user != request .user :
38+ if not person .users . contains ( request .user ) :
3939 return redirect_to_login (request .path )
4040
4141 if request .POST :
You can’t perform that action at this time.
0 commit comments