[Django] #30049: Multiple problems using gis fields in admin inlines

29 views
Skip to first unread message

Django

unread,
Dec 20, 2018, 12:22:59 AM12/20/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
----------------------------------------+----------------------------
Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Keywords: gis, admin
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+----------------------------
My goal is to use a field that looks like this:

{{{
from django.contrib.gis.db import models

class FavoriteLocation(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
location = models.PointField()
}}}

as an extra field on a User. The field-type works on other models, so
everything is setup correctly.

However, getting it as a inline is problematic because it doesnt render
correctly in the admin.
The admin code looks like this:

{{{
from django.contrib.auth.admin import UserAdmin
from django.contrib.gis import admin

class FavoriteLocationInline(admin.StackedInline):
model = FavoriteLocation
extra = 1

class CustomUserAdmin(UserAdmin):
inlines = (FavoriteLocationInline,)

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
}}}

however, the widget for displaying the field looks blank (see screenshot).

In the doc, It sais I should use "admin.OSMGeoAdmin" for my admin class.
However, that don't change anything.
Nor changing it to "class CustomUserAdmin(admin.OSMGeoAdmin, UserAdmin).

If I click add "another favorite location", I will also get a text-area
field instead of the widget.

Trying to save the model with this broken widget gives me a
"GDALException" (django.contrib.gis.gdal.error.GDALException: OGR
failure.)
Note that this widget works on other admin-pages I have..

--
Ticket URL: <https://code.djangoproject.com/ticket/30049>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 20, 2018, 12:23:24 AM12/20/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
------------------------------+--------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:

Keywords: gis, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Lars Solberg):

* Attachment "Screenshot 2018-12-20 at 06.13.12.png" added.

broken widget

Django

unread,
Dec 20, 2018, 12:26:27 AM12/20/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
------------------------------+--------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:

Keywords: gis, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Old description:

New description:

{{{
from django.contrib.gis.db import models

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
}}}

Also note that the broken widget is black because it is all zoomed in on
0, 0.. However, it also misses some elements in the upper right corner.
I am seeing no errors in the browser console.

--

Comment (by Lars Solberg):

info about broken widget

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:1>

Django

unread,
Dec 20, 2018, 12:27:08 AM12/20/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
------------------------------+--------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:

Keywords: gis, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Lars Solberg):

* Attachment "Screenshot 2018-12-20 at 06.26.39.png" added.

top of working widget

Django

unread,
Dec 20, 2018, 11:04:07 PM12/20/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
------------------------------+--------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:

Keywords: gis, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Tim Graham):

I think you should try inheriting from `OSMGeoAdmin` rather than
`UserAdmin`. You'll have to copy the parts of `UserAdmin` that you want
into your subclass, I imagine. I imagine this use case isn't too common
and I'm not sure if there's anything Django could do to make it easier.

This looks more like a usage question than a bug in Django, but if you
have some idea about what could be done, feel free to let us know.

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:2>

Django

unread,
Dec 21, 2018, 1:43:01 AM12/21/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
------------------------------+--------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:

Keywords: gis, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Lars Solberg):

I still coulnt get it to work.

I tried using one I have working as an inline, then the inlined version
stopped working as well.
So this happens when I am using inlines..

The html to render the widgets are wastly different..
* Inlined version @
https://gist.github.com/xeor/968ad1c597c59c432b4a3588b87f2178
* Normal version @
https://gist.github.com/xeor/84a374d57b89adeef5b37513b4409667

In this case, I have taken out the useradmin part, and have made a normal
admin interface..


{{{
from django.contrib.gis import admin
from .models import Other, Spot

class SpotInline(admin.StackedInline):
model = Spot
extra = 1

class OtherAdmin(admin.OSMGeoAdmin):
inlines = (SpotInline,)

admin.site.register(Other, OtherAdmin)
}}}

OtherAdmin now has the map as a normal widget (works), and one as an
inline (doesnt work).

I can see in eg
https://github.com/django/django/blob/master/django/contrib/gis/templates/gis/admin/openlayers.html
that there are some references around to example `{{ id }}_map`.. Will
`id` be correct when this is using an inline?

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:3>

Django

unread,
Dec 24, 2018, 11:04:48 AM12/24/18
to django-...@googlegroups.com
#30049: Multiple problems using gis fields in admin inlines
------------------------------+--------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:

Keywords: gis, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Tim Graham):

It's possible that inline GIS widgets are broken. I'm not sure if the
Django tests cover that. Can you put together a small sample project that
reproduces the issue? You could also check with if it works with older
versions (2.0.x, 1.11.x, etc.) of Django.

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:4>

Django

unread,
Dec 27, 2018, 10:02:09 AM12/27/18
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+------------------------------------

Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

Using the attached sample project, I can reproduce the problem that
clicking "Add another City" on the admin's state change form doesn't
initialize the new widget properly (textarea instead of the openlayers
widget). It doesn't seem to be a new issue -- I reproduced back as far as
I tested (Django 1.11).

I'm not sure if the "missing elements in the upper right corner" part of
this report is valid... when using `PointField` in a non-inline admin,
those elements don't appear either. Are they not applicable to
`PointField`? In any case, a bug report should be limited to one issue so
let's keep this ticket limited to the "Add another" initialization and
open addition tickets if more issues remain.

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:5>

Django

unread,
Dec 27, 2018, 10:08:43 AM12/27/18
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+------------------------------------
Reporter: Lars Solberg | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.1
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Tim Graham):

* Attachment "t30049.zip" added.

sample app to reproduce

Django

unread,
May 13, 2019, 8:27:16 AM5/13/19
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Pavel Tvrdík
Type: Bug | Status: assigned
Component: GIS | Version: 2.1
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Pavel Tvrdík):

* status: new => assigned
* owner: nobody => Pavel Tvrdík


--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:6>

Django

unread,
Jun 27, 2019, 3:19:09 AM6/27/19
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Pavel Tvrdík
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1
* version: 2.1 => master


Comment:

[https://github.com/django/django/pull/11516 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:7>

Django

unread,
Jun 28, 2019, 5:03:41 AM6/28/19
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Pavel Tvrdík
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:8>

Django

unread,
Apr 22, 2022, 7:08:16 AM4/22/22
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Pavel Tvrdík
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------

Comment (by Mariusz Felisiak):

`GISModelAdmin` is also affected.

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:9>

Django

unread,
Aug 17, 2024, 12:26:33 PM8/17/24
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Claude Paroz
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Claude Paroz):

* needs_tests: 0 => 1
* owner: Pavel Tvrdík => Claude Paroz

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:10>

Django

unread,
Aug 17, 2024, 5:39:16 PM8/17/24
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Claude Paroz
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Claude Paroz):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0

Comment:

New [https://github.com/django/django/pull/18490 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:11>

Django

unread,
Aug 18, 2024, 6:15:20 AM8/18/24
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Claude Paroz
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Claude Paroz):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:12>

Django

unread,
Aug 18, 2024, 11:16:10 AM8/18/24
to django-...@googlegroups.com
#30049: GIS widgets don't initialize properly after clicking "Add another" in admin
inlines
------------------------------+----------------------------------------
Reporter: Lars Solberg | Owner: Claude Paroz
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: gis, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Comment (by Claude Paroz):

I think it would be better to wait for #25706 before finishing this one.
--
Ticket URL: <https://code.djangoproject.com/ticket/30049#comment:13>
Reply all
Reply to author
Forward
0 new messages