浏览代码

Necessary corrections have been made for correct operation with the sharix-open-user-model

TonyKurts 1 年之前
父节点
当前提交
2c724a2b20
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      models/attachment.py
  2. 2 2
      models/comment.py

+ 2 - 2
models/attachment.py

@@ -1,7 +1,7 @@
 import os
 
 from django.db import models
-from django.conf import settings
+from django.contrib.auth import get_user_model
 
 from tickets.models.ticket import Ticket
 
@@ -12,7 +12,7 @@ def get_attachment_upload_dir(instance, filename):
 
 class Attachment(models.Model):
     ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
-    added_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
+    added_by = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
     timestamp = models.DateTimeField(auto_now_add=True)
     file = models.FileField(upload_to=get_attachment_upload_dir, max_length=255)
 

+ 2 - 2
models/comment.py

@@ -1,12 +1,12 @@
 from django.db import models
-from django.conf import settings
+from django.contrib.auth import get_user_model
 
 from tickets.models.ticket import Ticket
 
 
 class Comment(models.Model):
     author = models.ForeignKey(
-        settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True,
+        get_user_model(), on_delete=models.CASCADE, blank=True, null=True,
         related_name="tickets_comments"
     )
     ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)