vinaykrsharma vinaykrsharma - 2 years ago 88
Python Question

Python: module to share post on facebook and twitter

I've build an Admin panel to post contents on front-end such as Articles.

This admin is created using Django Admin.

How can I share newly posted article on Facebook and Twitter?

Answer Source

You can use post_save signal which allows you to hook on a new object creation, for example:

from django.db       import models
from django.dispatch import receiver

class Article(models.Model):
  name = models.CharField(max_length = 255)

@receiver(post_save, sender = Article)
def new_article_event(sender, instance, created, **kwargs):
  if created:
    # Put facebook/twitter post code here

It's important that you'll check if created is True, to make sure you perform posting only on new articles.

You can use the following projects to post on Facebook/Twitter:



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download