Skip to content

Commit 13df210

Browse files
committed
Adds on_delete argument on user FK field for Django 2.0 compatibility zapier#46
1 parent 0d9eb9d commit 13df210

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
- DJANGO_VERSION="1.9"
1616
- DJANGO_VERSION="1.10"
1717
- DJANGO_VERSION="1.11"
18+
- DJANGO_VERSION="2.0"
1819

1920
install:
2021
- pip install -r devrequirements_${DJANGO_VERSION}.txt
@@ -33,6 +34,8 @@ matrix:
3334
env: DJANGO_VERSION="1.10"
3435
- python: "3.3"
3536
env: DJANGO_VERSION="1.11"
37+
- python: "3.3"
38+
env: DJANGO_VERSION="2.0"
3639
- python: "3.6"
3740
env: DJANGO_VERSION="1.4"
3841
- python: "3.6"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ python runtests.py
5757
### Requirements
5858

5959
* Python 2 or 3 (tested on 2.7, 3.3, 3.4, 3.6)
60-
* Django 1.4+ (tested on 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11)
60+
* Django 1.4+ (tested on 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 2.0)
6161

6262
### Installing & Configuring
6363

@@ -96,7 +96,7 @@ class Book(models.Model):
9696
# which is specific to users. If you want a Hook to
9797
# be triggered for all users, add '+' to built-in Hooks
9898
# or pass user_override=False for custom_hook events
99-
user = models.ForeignKey('auth.User')
99+
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
100100
# maybe user is off a related object, so try...
101101
# user = property(lambda self: self.intermediary.user)
102102

devrequirements_2.0.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r devrequirements.txt
2+
django-contrib-comments>=1.8.0
3+
Django>=2.0,<2.1

rest_hooks/migrations/0001_initial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
import django.db.models.deletion
45
from django.db import models, migrations
56
from django.conf import settings
67

@@ -20,7 +21,7 @@ class Migration(migrations.Migration):
2021
('updated', models.DateTimeField(auto_now=True)),
2122
('event', models.CharField(max_length=64, verbose_name='Event', db_index=True)),
2223
('target', models.URLField(max_length=255, verbose_name='Target URL')),
23-
('user', models.ForeignKey(related_name='hooks', to=settings.AUTH_USER_MODEL)),
24+
('user', models.ForeignKey(related_name='hooks', to=settings.AUTH_USER_MODEL, on_delete=django.db.models.deletion.CASCADE)),
2425
],
2526
options={
2627
},

rest_hooks/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AbstractHook(models.Model):
4040
created = models.DateTimeField(auto_now_add=True)
4141
updated = models.DateTimeField(auto_now=True)
4242

43-
user = models.ForeignKey(AUTH_USER_MODEL, related_name='%(class)ss')
43+
user = models.ForeignKey(AUTH_USER_MODEL, related_name='%(class)ss', on_delete=models.CASCADE)
4444
event = models.CharField('Event', max_length=64, db_index=True)
4545
target = models.URLField('Target URL', max_length=255)
4646

0 commit comments

Comments
 (0)