diff options
Diffstat (limited to 'tests/admin_widgets/models.py')
-rw-r--r-- | tests/admin_widgets/models.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/admin_widgets/models.py b/tests/admin_widgets/models.py index 5f990bdce3..d795fea007 100644 --- a/tests/admin_widgets/models.py +++ b/tests/admin_widgets/models.py @@ -32,7 +32,7 @@ class Band(models.Model): @python_2_unicode_compatible class Album(models.Model): - band = models.ForeignKey(Band) + band = models.ForeignKey(Band, models.CASCADE) name = models.CharField(max_length=100) cover_art = models.FileField(upload_to='albums') backside_art = MyFileField(upload_to='albums_back', null=True) @@ -49,7 +49,7 @@ class HiddenInventoryManager(models.Manager): @python_2_unicode_compatible class Inventory(models.Model): barcode = models.PositiveIntegerField(unique=True) - parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True) + parent = models.ForeignKey('self', models.SET_NULL, to_field='barcode', blank=True, null=True) name = models.CharField(blank=False, max_length=20) hidden = models.BooleanField(default=False) @@ -62,7 +62,12 @@ class Inventory(models.Model): class Event(models.Model): - main_band = models.ForeignKey(Band, limit_choices_to=models.Q(pk__gt=0), related_name='events_main_band_at') + main_band = models.ForeignKey( + Band, + models.CASCADE, + limit_choices_to=models.Q(pk__gt=0), + related_name='events_main_band_at', + ) supporting_bands = models.ManyToManyField(Band, blank=True, related_name='events_supporting_band_at') start_date = models.DateField(blank=True, null=True) start_time = models.TimeField(blank=True, null=True) @@ -73,7 +78,7 @@ class Event(models.Model): @python_2_unicode_compatible class Car(models.Model): - owner = models.ForeignKey(User) + owner = models.ForeignKey(User, models.CASCADE) make = models.CharField(max_length=30) model = models.CharField(max_length=30) @@ -85,7 +90,7 @@ class CarTire(models.Model): """ A single car tire. This to test that a user can only select their own cars. """ - car = models.ForeignKey(Car) + car = models.ForeignKey(Car, models.CASCADE) class Honeycomb(models.Model): @@ -98,7 +103,7 @@ class Bee(models.Model): (Honeycomb) so the corresponding raw ID widget won't have a magnifying glass link to select related honeycomb instances. """ - honeycomb = models.ForeignKey(Honeycomb) + honeycomb = models.ForeignKey(Honeycomb, models.CASCADE) class Individual(models.Model): @@ -108,8 +113,8 @@ class Individual(models.Model): related instances (rendering will be called programmatically in this case). """ name = models.CharField(max_length=20) - parent = models.ForeignKey('self', null=True, on_delete=models.SET_NULL) - soulmate = models.ForeignKey('self', null=True, on_delete=models.CASCADE, related_name='soulmates') + parent = models.ForeignKey('self', models.SET_NULL, null=True) + soulmate = models.ForeignKey('self', models.CASCADE, null=True, related_name='soulmates') class Company(models.Model): @@ -149,7 +154,7 @@ class School(models.Model): @python_2_unicode_compatible class Profile(models.Model): - user = models.ForeignKey('auth.User', 'username') + user = models.ForeignKey('auth.User', models.CASCADE, to_field='username') def __str__(self): return self.user.username |