Opened 6 years ago
Last modified 3 months ago
#30049 assigned Bug
Multiple problems using gis fields in admin inlines — at Version 1
Reported by: | Lars Solberg | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | gis, admin |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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..
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.
broken widget