Code

Opened 6 years ago

Closed 3 years ago

#7135 closed Bug (wontfix)

Databrowse doesn't handle model inheritance

Reported by: admackin Owned by: nobody
Component: contrib.databrowse Version: 1.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Databrowse currently doesn't support model inheritance. This is related to not supporting one-to-one fields, for which there is already a patch over at #6913. This patch enacts the same changes (in a slightly different way) as the other ticket but also checks to see whether accessing the one-to-one field (eg from a subclass) throws a DoesNotExist exception (in which case the instance isn't linked to a corresponding subclass of that type) and doesn't list it as a related field in that case.

Attachments (2)

databrowse-fix-for-inheritance.diff (1.5 KB) - added by admackin 6 years ago.
models-with-test-for-databrowse-and-inheritance.py (727 bytes) - added by admackin 6 years ago.
models.py which has a minimal doctest to reproduce the problem

Download all attachments as: .zip

Change History (11)

Changed 6 years ago by admackin

comment:1 Changed 6 years ago by admackin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I should note that at least in my dev setup, this still doesn't produce exactly the correct behaviour (it produces links to subclass instances which don't actually exist, and then these of course produce errors), but this is due to a bug in model inheritance which I will post a new ticket on shortly when I've worked out the exact circumstances under which it occurs.

comment:2 Changed 6 years ago by telenieko

  • Triage Stage changed from Unreviewed to Accepted

#6913 was closed in favour if this one as the patch here provides more functionality.
The next time, *please* don't open a new ticket, attach your patch to the other ticket and add a comment.
Thanks.

Not sure if this needs tests tought. Could you add it?

Changed 6 years ago by admackin

models.py which has a minimal doctest to reproduce the problem

comment:3 Changed 6 years ago by admackin

  • Version changed from SVN to 1.0

Ok, just confirmed the problem still exists in 1.0, and the patch still works.

After some fiddling I managed to get a fairly minimal test case which I've attached. The doctest in the models.py shows the desired behaviour - running manage.py test on the app will fail as it throws a DoesNotExist error.

comment:4 Changed 4 years ago by mtarbit

This is still an issue, and the fix still works. Any particular reason why the ticket has gone quiet?

comment:5 Changed 4 years ago by slewis

Seconding the above question. OneToOneFields break databrowse. Why not accept the patch?

comment:6 Changed 3 years ago by lukeplant

  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 3 years ago by julien

  • Easy pickings unset
  • Needs tests set

comment:8 Changed 3 years ago by oz

databrowse has been broken for 3 years and no-one seems to mind. OneToOne fields don't work, nor do nullalbe ForeignKeys (ticket #15792).
Both have patches that solve the problem, yet are still open for a long long time. It's a shame since it renders databrowse (which is potentially awesome) useless for many projects.

comment:9 Changed 3 years ago by ptone

  • Resolution set to wontfix
  • Status changed from new to closed
  • UI/UX unset

Databrowse is now deprecated, see #16907

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.