>
> Hi, I know it has been a while since this question was asked but I have  a 
> similar question. I have a Post model, and I want there to be one pinned 
> post out of the list of all posts, I tried creating a new property thus, 

   
```pinned = models.BooleanField(default=False, unique=True)```

but it caused major problems. I want to have just one pinned post and the 
rest unpinned but that would mean pinned = True for one post/article and 
pinned=False for the rest and I don't think that is how unique is supposed 
to work. Unique is supposed to be different for all the objects right? not 
sure how to tackle this problem.

someone suggested I use a foreignkey field to link them all together but 
now if I'm being honest, I actually do not know where to go from here 

```class PinnedPost(models.Model):
pinned_post = models.ForeignKey(Post, related_name='pinned', 
on_delete=models.CASCADE)``` 
if there's anyone here that can help me with this please, I'd really 
appreciate it. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31bc4205-e1fd-4e59-aa47-a488884253eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to