From c22bbd97a0bd1a923293e7f68b8fbfa6e3bd19f2 Mon Sep 17 00:00:00 2001 From: Oleksii Malakhov Date: Sun, 6 Sep 2020 12:32:24 +0300 Subject: [PATCH 1/2] #17: models.py: Add on_delete=CASCADE for User foreign key; --- twython_django_oauth/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twython_django_oauth/models.py b/twython_django_oauth/models.py index bb9ce71..04fe548 100644 --- a/twython_django_oauth/models.py +++ b/twython_django_oauth/models.py @@ -10,6 +10,6 @@ class TwitterProfile(models.Model): oauth_secret in relation to a user. Adapt this if you have a current setup, there's really nothing special going on here. """ - user = models.OneToOneField(User) + user = models.OneToOneField(User, on_delete=models.CASCADE) oauth_token = models.CharField(max_length=200) oauth_secret = models.CharField(max_length=200) From cd0b7fe8f310fe1cf556841ada6c47681ea9295f Mon Sep 17 00:00:00 2001 From: Oleksii Malakhov Date: Sun, 6 Sep 2020 18:15:25 +0300 Subject: [PATCH 2/2] Fixup: Django 2.0 and 3.1 migration --- twython_django_oauth/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twython_django_oauth/views.py b/twython_django_oauth/views.py index d44c83f..be29650 100644 --- a/twython_django_oauth/views.py +++ b/twython_django_oauth/views.py @@ -1,9 +1,9 @@ from django.contrib.auth import authenticate, login, logout as django_logout from django.contrib.auth import get_user_model from django.http import HttpResponseRedirect -from django.shortcuts import render_to_response +from django.shortcuts import render from django.conf import settings -from django.core.urlresolvers import reverse +from django.urls import reverse from twython import Twython @@ -90,4 +90,4 @@ def user_timeline(request): twitter = Twython(settings.TWITTER_KEY, settings.TWITTER_SECRET, user.oauth_token, user.oauth_secret) user_tweets = twitter.get_home_timeline() - return render_to_response('tweets.html', {'tweets': user_tweets}) + return render(None, 'tweets.html', {'tweets': user_tweets})