--
Ticket URL: <https://code.djangoproject.com/ticket/18368>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0
Comment:
I'm not thrilled by this proposed addition. I don't see anything here that
cannot be done either by field default values on the model or by updating
the created objects in a second pass.
--
Ticket URL: <https://code.djangoproject.com/ticket/18368#comment:1>
* status: closed => reopened
* resolution: wontfix =>
Comment:
@claudep, I just want to make sure you're clear on the use case that made
me request this. I'm bulk loading geometries using LayerMapping from a
management command (code at
https://github.com/PitonFoundation/atlas/blob/locations_places/apps/storybase_geo/management/commands/loadplaces.py).
The reason I needed to be able to pass additional model attributes to
LayerMapping.save() was to set a ForeignKey field to a model representing
levels of a geographic hierarchy. In my use case, this field can be null,
so that can't be used to identify the newly-created values. Also,
geometries may be loaded at different times and for different levels of
the geo hierarchy, so a default value for that field doesn't make sense.
Also, maybe I'm missing something, but I couldn't seem to find a way to
retrieve the model instances created by LayerMapping.save(). Certainly, I
could add a field to the model to indicate whether or not the model
instances had been post-processed in a second pass, but preferred not to
add fields to the model just to accommodate the occasional data load.
--
Ticket URL: <https://code.djangoproject.com/ticket/18368#comment:2>
Comment (by claudep):
And what about post_save signal?
--
Ticket URL: <https://code.djangoproject.com/ticket/18368#comment:3>
* status: reopened => closed
* resolution: => wontfix
Comment:
Replying to [comment:3 claudep]:
> And what about post_save signal?
You're absolutely right that signals are the way to go in this case.
However, I think it would have to be the pre_save signal in my case.
Thanks for the helpful observation.
--
Ticket URL: <https://code.djangoproject.com/ticket/18368#comment:4>
Comment (by Austin Riba):
I still think LayerMapping.save() at the least should return the saved
object. I've run into the issue where I need to save data into the created
object not in the shapefile, like the original author. Unlike the OP
however a signal won't work (unless I'm missing something obvious) because
the context needs to come from the import script, it can't be done in
isolation.
--
Ticket URL: <https://code.djangoproject.com/ticket/18368#comment:5>