I'm trying to create a simple twitter bot that recieves info from different API's and posts the tweets based on the info. I'm using a Django for this (not sure if completely needed, but I'm just trying to learn the framework) so I created 2 different apps, one that recieves the information from the API and creates an object (so far this object is just a quote) and send it to another app which handles the twitter publication. The general idea is that my quote app will generate a signal which will be sent to the posting app where I created a function with a receiver decorator so it will be listening all the time. Nevertheless, for some reason the decorator is not working and after sending the signal I get no response.
This is the creation of the signal:
from django.dispatch import Signal
new_quote = Signal(providing_args=['author', 'content'])
This is the sending of the signal:
quote=Quote.objects.create(author=author, content=content)
new_quote.send_robust(sender=quote, author=author, content=content)
The object is being created with no problem, already check that. And this is the catching of the signal.
from .models import Post
from django.dispatch import receiver
from quotes.signals import new_quote
from quotes.models import Quote
@receiver(new_quote, sender=Quote)
def post_tweet(Quote, **kwargs):
print('here')
auth = kwargs['author']
content = kwargs['content']
Post.objects.create(title=auth, content=content)
The print is just for checking if the function actually runs. The posting creation also works fine, already check that too.
I'm just learning Django and already read the documentation and followed the steps of the 'tutorial', but there must be something I'm not seeing.
EDIT:
app file of the post creator
from django.apps import AppConfig
class PostsConfig(AppConfig):
name = 'posts'
def ready(self):
import posts.signals
app file of quotes: from django.apps import AppConfig
class QuotesConfig(AppConfig):
name = 'quotes'
def ready(self):
pass