Hi Tom,
In some places I *believe* object_id gave me results in my own
templates. The next option is to try to access the context, but I
believe you may have to write a template tag to use it (not totally
sure). Here's an example I used:
### /<project>/test/templatetags/my_tags.py
from django.template import Library, Node
from django import template
from django.contrib.auth.models import User
from test.models import MyUserProfile
register = Library()
class CurrentUserProfile(Node):
def render(self, context):
try:
pid = MyUserProfile.objects.get(user=context['object_id']).id #
get the id for the profile of the currently edited user
except:
pid = 0 # no user? (bad code, just an example)
return pid
def user_profile_id(parser, token):
return CurrentUserProfile()
user_profile_id = register.tag(user_profile_id)
### /<project>/templates/admin/auth/user/change_form.html
{% extends "admin/change_form.html" %}
{% load my_tags %}
{% block form_top %}
{% if user_profile_id %}
<p><a href="/admin/test/userprofile/{% user_profile_id %}/">Edit this
user's profile</a></p>
{% endif %}
{% endblock %}
Make sure your template dir is in your settings. There could be an
easier way too, but this worked for me.
Cheers,
Aaron
Tom Badran wrote:
> Is there a way i can display the id of an object in the admin pages?
> I've had a look over the docs and nothing jumps out. This is using
> django svn
>
> Thanks
>
> Tom
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---