Getting approval from Admin first before posting a blog in Django

529 views
Skip to first unread message

Ahmed Khairy

unread,
Apr 21, 2020, 9:03:44 PM4/21/20
to Django users
Hi all, 

I have made a blog as a project and I have set users to submit posts for the blog directly but i want to direct this post to the admin first for approval before showing on the website. here is the Post Create View Class. 

class PostCreateView(CreateView):
    model = Post
    fields = ['title''content']
    template_name = "post_form.html"

    def form_valid(selfform):
        form.instance.author = self.request.user
        return super().form_valid(form)

Thank you in Advance 

Motaz Hejaze

unread,
Apr 21, 2020, 9:09:26 PM4/21/20
to Django users
in post model add a  boolean field ( approved : default = false ) ..
and in your views filter only approved posts before showing them ...
this way admin can login to admin panel , check the latest posts and approve them ( make approve = True ) then and only then they will be viewed in your templates

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/95facfb3-dedb-476d-957f-80ef2eb72e44%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages