do it like in any other application:
custom view, custom template, change urls

in the custom view, you could use a changemanipulator for your data and a dict for your additional data.
for the template: just copy change_form.html and add your extra_data.

the view looks like this:

def custom_change(request, model_name, entry_id):
    model = models.get_model('container', model_name)
    opts = model._meta
    app_label = opts.app_label
    manipulator = model.ChangeManipulator(int(entry_id))
    entry = manipulator.original_object
    if request.POST:
        new_data = request.POST.copy()
        errors = manipulator.get_validation_errors(new_data)
        if not errors:
            manipulator.do_html2python(new_data)
            new_object = manipulator.save(new_data)
msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object}
            request.user.message_set.create(message=msg)
            redirect_url = '/admin/container/' + model_name
            return HttpResponseRedirect(redirect_url)
    else:
        errors = {}
        new_data = entry.__dict__

   extra_data = ExtraData.objects.all()

    form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('admin/container/ change_form_change.html', {
        'form': form,
        'extra_data':extra_data,
    }, context_instance=RequestContext(request) )


donĀ“t know if that really helps.
if not, maybe you can be more specific.

patrick

Am 20.12.2006 um 01:06 schrieb Rob Slotboom:


For a model I want to add a custom manipulator which can be used in the
admin.
With this manipulator I want to be able to add an extra formfield for
displaying some additional data from a related object. There is no need
for database storage.

In this group I red that it isn't possible to extend manipulators in
admin so the first question is if it is possible to replace the
'default' manipulator by providing a custom one?

The next question is how to feed the form? From a custom template I
suppose.


Cheers,

Rob


>


--~--~---------~--~----~------------~-------~--~----~
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