Hello.

I'm using Django v1.

When I want to add a column in an admin list page, I just create a
function in the associated model class and add it to the
"list_display" tuple in the same model class.  For instance, if I
wanted to create a link to a reference id that would show up as a
column, I would do something like this:

def link_to_reference(self):
    try:
        id = Reference.objects.get(id=self.referenced_by_id).id
    except Reference.DoesNotExist:
        return 'Does not exist.'
    return '<a href="/resourcesguide/resource/reference/''+\
                str(id)+'">'+str(id)+'</a>'
    link_to_reference.short_description = 'Referral ID'
    link_to_reference.allow_tags = True

Then do this:

list_display = ('somefield1', 'somefield2' ... 'link_to_referrer')

This always works well for me. Now I am trying to do something similar
on an admin change form. Instead of using the "list_display" tuple, I
try the "fields" tuple like this:

fields = (('Section 1', {'fields': ('field1', 'field2' ...
'link_to_reference'})))

I get a "FieldDoesNotExist" exception.

Does anyone know a (simple) way perform this type of function-based
sudo-field creation on the admin change form?

Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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