Changes between Version 2 and Version 3 of Ticket #28262
- Timestamp:
- Jun 1, 2017, 2:13:48 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28262
- Property Severity Normal → Release blocker
- Property Triage Stage Unreviewed → Accepted
- Property Summary Using lookup with autocreated fields crashes django admin → ModelAdmin.lookup_allowed() incorrectly raises DisallowedModelAdminLookup lookup with reverse relation to origin model
-
Ticket #28262 – Description
v2 v3 2 2 3 3 {{{ 4 class AuditSession(Model): 5 auditor = models.ForeignKey(User) 4 from django.db import models 5 from django.contrib.auth.models import User 6 6 7 class Institution(Model): 7 class AuditSession(models.Model): 8 auditor = models.ForeignKey(User, on_delete=models.CASCADE) 9 10 class Institution(models.Model): 8 11 name = models.CharField(max_length=100) 9 12 10 class Auditor(Model): 11 user = models.OneToOneField(User) 12 institution = models.ForeignKey(Institution, null=True, blank=True) 13 def __str__(self): 14 return self.name 15 16 class Auditor(models.Model): 17 user = models.OneToOneField(User, on_delete=models.CASCADE) 18 institution = models.ForeignKey(Institution, on_delete=models.CASCADE, null=True, blank=True) 13 19 }}} 14 20 15 21 And the following filter in audit session admin: 16 22 {{{ 17 class AuditSessionAdmin(ModelAdmin): 23 from django.contrib import admin 24 25 from .models import AuditSession, Institution, Auditor 26 27 @admin.register(AuditSession) 28 class AuditSessionAdmin(admin.ModelAdmin): 18 29 list_filter = ( 19 30 ('auditor__auditor__institution'), 20 31 ) 32 33 admin.site.register((Institution, Auditor)) 21 34 }}} 22 35