diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-14 15:39:12 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-14 15:39:12 -0500 |
commit | cadb4a09bfa9457171f03848dd054c987fda3322 (patch) | |
tree | 25d086fa8475de9b2c75d83cf3f3b5c850803718 /app/posts/models.py | |
parent | 95a17d5e053eef07931ee3891c56215ba80fd557 (diff) |
posts: added a filter by username for admin and in forms.py
Diffstat (limited to 'app/posts/models.py')
-rw-r--r-- | app/posts/models.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/posts/models.py b/app/posts/models.py index 1f909f7..91420e1 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -1,7 +1,7 @@ from django.db import models from django.utils.html import format_html, format_html_join from django.utils import timezone -from django.contrib.auth.models import User +import settings from products.models import ProductLink @@ -41,7 +41,7 @@ class TemplateType(models.IntegerChoices): class Post(models.Model): # an entry in a feed - user = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) + user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) title = models.CharField(max_length=512, blank=True, null=True) body = models.TextField(blank=True, null=True) url = models.CharField(max_length=512, blank=True, null=True) @@ -142,4 +142,17 @@ with open(path) as f: update_frequency = int(row[10]*30), ) + + +user = User.objects.get(username="luxagraf") + +user +<User: luxagraf> + +for post in Post.objects.all(): + if post.author == "Scott Gilbertson": + post.user = user + post.save() + + ''' |