IMHO, when using "order_with_respect_to", one should be able to order
the inlines (stacked & tabular).
whatīs necessary:
1. can_order should be set to true when using "order_with_respect_to".
e.g., if you currently subclass a formset and use can_order=true, there
īs an error in the admin-interface (key "ORDER" not found).
2. ordered_forms should be available independently from is_valid() -
even if thereīs an error somewhere in your form, the ordering should
be retained.
note: this proposal is not about integrating some drag/drop-
functionality within the templates (using javascript). although that
would be nice, itīs just about having the _possibility_ to reorder
stuff.
if someome points me to the right direction, I might be able to
provide a patch for this issue. yesterday, I tried to sketch the
relations between the different formset-classes, -methods and -
helpers, but (to be honest) Iīm a bit lost here.
furthermore, itībe interesting if the dev-team wants this to be solved
or if this behaviour is intentional (for whatever reason).
thanks,
patrick
On 22 Okt., 18:06, patrickk <patr...@vonautomatisch.at> wrote:
> IMHO, when using "order_with_respect_to", one should be able to order
> the inlines (stacked & tabular).
> whatīs necessary:
> 1. can_order should be set to true when using "order_with_respect_to".
> e.g., if you currently subclass a formset and use can_order=true, there
> īs an error in the admin-interface (key "ORDER" not found).
> 2. ordered_forms should be available independently from is_valid() -
> even if thereīs an error somewhere in your form, the ordering should
> be retained.
> note: this proposal is not about integrating some drag/drop-
> functionality within the templates (using javascript). although that
> would be nice, itīs just about having the _possibility_ to reorder
> stuff.
On Wed, Oct 22, 2008 at 10:06 AM, patrickk <patr...@vonautomatisch.at> wrote: > IMHO, when using "order_with_respect_to", one should be able to order > the inlines (stacked & tabular).
Yup, this has been on the todo list for quite some time. We even discussed it at PyCon a couple years ago as we kicked off newforms-admin. A few things that I recall from that discussion:
* We decided that we'd like to remove ``order_with_respect_to`` particularly the way it adds a magical ``_order`` field in favor of an explicit ``OrderingField``.
* This would work with related objects::
class Poll(Model): ...
class Choice(Model): poll = ForeignKey(Poll, related_name="choices") order = OrderingField(with_respect_to="poll")
* This would give you an API that provided things like ``poll.choices.in_order()`` and ``poll.choices.set_order()``.
* ``OrderingField``s would also work without a related object::
class Person(Model): order = OrderingField()
* That'd allow APIs like ``Person.objects.in_order()`` and ``Person.objects.set_order()``.
I can't recall more of this discussion, but perhaps this'll be enough to get you (or someone) started?
thanks, jacob.
doing the OrderingField doesnīt seem too much or a problem (and I do
like the idea of getting rid of order_with_respect_to).
where Iīm really struggeling is the admin-interface:
letīs say I have changed the order of my inline-related forms, Iīve
made an error (e.g. a required field is not given somewhere within the
whole form) and then I click "submit".
of course, the inline-related forms should be displayed in the new
order - but that order is not saved yet. so, Iīm not quite sure how
this OrderingField has to be connected with the admin-functionality.
the only solution I can think of right now is reordering the inline-
related forms via javascript onload. but thatīs already possible and
doesnīt require an OrderingField.
it gets even more complicated when thinking of empty extra forms,
ordered between forms with an "original". these empty forms should be
removed from the list (in case of an error) from my point of view.
any ideas on how to reorder inline-related forms in case of an error? I
īd definitely prefer a non-javascript-solution ...
thanks,
patrick
On 28 Okt., 16:31, "Jacob Kaplan-Moss" <jacob.kaplanm...@gmail.com>
wrote:
> On Wed, Oct 22, 2008 at 10:06 AM, patrickk <patr...@vonautomatisch.at> wrote:
> > IMHO, when using "order_with_respect_to", one should be able to order
> > the inlines (stacked & tabular).
> Yup, this has been on the todo list for quite some time. We even
> discussed it at PyCon a couple years ago as we kicked off
> newforms-admin. A few things that I recall from that discussion:
> * We decided that we'd like to remove ``order_with_respect_to``
> particularly the way it adds a magical ``_order`` field in favor of
> an explicit ``OrderingField``.
> * This would work with related objects::
> class Poll(Model):
> ...
> class Choice(Model):
> poll = ForeignKey(Poll, related_name="choices")
> order = OrderingField(with_respect_to="poll")
> * This would give you an API that provided things like
> ``poll.choices.in_order()`` and ``poll.choices.set_order()``.
> * ``OrderingField``s would also work without a related object::
> class Person(Model):
> order = OrderingField()
> * That'd allow APIs like ``Person.objects.in_order()`` and
> ``Person.objects.set_order()``.
> I can't recall more of this discussion, but perhaps this'll be enough
> to get you (or someone) started?