Well, since no one replied I figured it's probably easier to implement
from scratch rather than adjusting the Admin GUI.
Seems like the Admin GUI is only intended for a basic model layout.
If anyone is interested, here's a linked-list in Django:

MODEL:

class Case(models.Model):
   prev = models.ForeignKey('self', blank=True, null=True,
related_name='a')
   next = models.ForeignKey('self', blank=True, null=True,
related_name='b')
   title = models.CharField(maxlength=256)
   def __str__(self):
       return self.title

VIEW:

def case_list(request):
    cases = Case.objects.filter(next__isnull=True)
    return render_to_response('track/case_list.html', {
        'case_list': cases,
    }, context_instance=template.RequestContext(request))


def recurse_for_parents(self, p_list):
    if not self.prev == None:
        id = self.prev.id
        p = get_object_or_404(Case, pk=id)
        p_list.append(p)
        p_list = recurse_for_parents(p, p_list)
    return p_list


def case_detail(request, id):
    p_list = []
    case = get_object_or_404(Case, pk=id)
    p_list.append(case)
    p_list = recurse_for_parents(case, p_list)

    return render_to_response('track/case_detail.html', {
        'case_list': p_list,
    }, context_instance=template.RequestContext(request))



On Mar 3, 2:47 am, "rh" <[EMAIL PROTECTED]> wrote:
> Hi,
> I've a model which I want to implement as a linked-list.
>
> The model has a pointer to itself:
> prev = models.ForeignKey('self', blank=True, null=True)
>
> Now, my question is about the GUI.
> I want to use the Admin GUI with a small modification: when a user
> edits an existing instance of the model and saves it, I would like to
> generate a new instance and link it to the previous one.
>
> The "Save as new" button seems to be the closest to my needs but how
> can I set the prev pointer?
>
> Any ideas anyone?
>
> Reuven.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to