#16565 closed Bug (fixed)
An issue in databrowse's template object_detail.html
Reported by: | leopku | Owned by: | nobody |
---|---|---|---|
Component: | contrib.databrowse | Version: | 1.3 |
Severity: | Normal | Keywords: | databrowse, template |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
1, Steps to reproduce the bug.
i, create a module with a foreignkey and set blank=True and null=True.
ii, create a instance of the module in step 1st, and leave the FK field empty.
iii, install 'databrowse' app and register the model to databrowse.
iv, browse the instance detail info.
An TemplateSyntaxError should be throw out.
2, Issue detail:
TemplateSyntaxError at /databrowse/appname/modelname/objects/objectid/
Caught AttributeError while rendering: 'NoneType' object has no attribute '_get_pk_val'
...
...
...
Template error
In template /opt/Documents/Source/itman/templates/databrowse/object_detail.html, error at line 13
Caught AttributeError while rendering: 'NoneType' object has no attribute '_get_pk_val'
3,How to fix.
Open object_detail.html and go to line 18.
change "{% if field.urls %}" to "{% if field and field.urls %}"
Attachments (1)
Change History (9)
comment:1 by , 13 years ago
- Steps to reproduce the bug.
- create a module with a foreignkey and set blank=True and null=True.
- create a instance of the module in step 1st, and leave the FK field empty.
- install 'databrowse' app and register the model to databrowse.
- browse the instance detail info. An TemplateSyntaxError? should be throw out.
- Issue detail:
- How to fix.
comment:2 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I'm sure I've seen this problem before, but it seems it was never reported in Trac.
I'm attaching the patch I wrote to circumvent this bug on projects where I used databrowse.
by , 13 years ago
Attachment: | django-databrowse-fix-crash-on-null-foreign-keys.patch added |
---|
comment:4 by , 13 years ago
Has patch: | set |
---|---|
Triage Stage: | Accepted → Ready for checkin |
looks good, I need it too so please check in :)
comment:5 by , 13 years ago
My patch doesn't include tests, I'm not sure it can be checked in.
Unfortunately the lack of tests (see #15719) blocks all bugfixes on databrowse.
comment:6 by , 13 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
That said, it still needs tests :)
comment:7 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
I'm wontfixing a bunch of databrowse tickets since it is now deprecated. However since this has a patch, and since databrowse doesn't have tests and is unlikely to get them, I'd propose that some simple fixes like this are allowed in without tests to improve databrowse during its twilight.