Tweepy with Django-Allauth
By Patrick Allan
Posted December 28, 2019
Reading time: 1 minutes.
I have spent a good portion of this year developing Twitter software. Some of it is for research, account maintenance, and retweeting. Now, I am ready to put some of what I developed online, for public use.
I had been learning the Flask web framework, but it seemed inadequate for what I wanted to do–namely keep user data private (including API keys). For the last month or so, I have been banging-out Django code, mostly from tutorials. In fact, it prompted me to write a utility script for customizing Django's settings.py file to my preferences (see below).
Anyway, after much research and reading of code, I have grown to like the Django-Allauth package. It handles the cration of user accounts and managing sessions quite nicely, and should I decide to deploy APIs on any of other social networks that it handles, I suspect integrating them will be quite similar.
Once I figured-out what it was that I needed to do to get what I want, it was relatively simple, as can be seen in the the utils.py file that I added to the Django-Allauth Tutorial. And giving credit where due, I borrowed some of the code from the DjangoTweepy repository on GitHub.
Here is the code:
The utility script that I wrote for updating the Django settings.py file can be found below:
(Note: If you don't have meld installed, you might want to comment-out the line in eoj() that called it, or comment-out the call to eoj(), itself.)
Comments
comments powered by Disqus