Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 May 21, 2010 15:18:34

B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

hyperlinks within admin interface


Is it possible to mess with the __unicode__ method of a model to
enable a model instance to return a link to itself when viewed within
the admin interface? What I want is for there to be a link on an item
in an inline which takes the user to it's own edit page.

For example, I have a Survey system where we have questionnaires with
pages and questions. I use a questions_in_page model to store extra
attributes for the many_to_many, and this is what appears as an inline
in the Page admin view (i.e. you can't edit the question itself from
the Page admin view, only the object in the link table). I'd like to
be able to create links directly to the questions...

Any suggestions much appreciated.

Ben

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 May 21, 2010 16:09:03

u.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

hyperlinks within admin interface


I did something similar in my project. Here is part of my admin.py

class InvoiceAdmin(admin.ModelAdmin):

def get_urls(self):
urls = super(InvoiceAdmin, self).get_urls()
my_urls = patterns('',
url(r'^admin/invoice/view/(?P<invoice_id>\d+)/$',
self.admin_site.admin_view(self.view_admin_invoice),
name='view_invoice_url'),)
return my_urls + urls

def view_admin_invoice(self, request, invoice_id):
# my own view function

def view_invoice(self, obj):
return mark_safe(' %(link)s Zobraz ') %
dict(link=reverse('admin:view_invoice_url', args=))
view_invoice.is_safe = True
view_invoice.allow_tags = True

list_display = ('number', 'view_invoice','status', 'name', 'ico',
'ic_dph',
'price', 'vat', 'final_price', 'e_bill')
search_fields = ('ico','e_bill')

admin.site.register(Invoice, InvoiceAdmin)


Maybe it'll point you to the direction u want.

Radovan


Ben-302 wrote:
>
> Is it possible to mess with the __unicode__ method of a model to
> enable a model instance to return a link to itself when viewed within
> the admin interface? What I want is for there to be a link on an item
> in an inline which takes the user to it's own edit page.
>
> For example, I have a Survey system where we have questionnaires with
> pages and questions. I use a questions_in_page model to store extra
> attributes for the many_to_many, and this is what appears as an inline
> in the Page admin view (i.e. you can't edit the question itself from
> the Page admin view, only the object in the link table). I'd like to
> be able to create links directly to the questions...
>
> Any suggestions much appreciated.
>
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>
>

--
View this message in context:http://old.nabble.com/hyperlinks-within-admin-interface-tp28634491p28635092.htmlSent from the django-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 18, 2010 14:57:26

s.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

hyperlinks within admin interface


Hi Ben,

I'm trying to do the same thing, I thought perhaps list_display_links
would automagically link to related objects, but unfortunately not.
did you manage to find a solution?

Regards,
Steve

On May 21, 3:12 pm, Ben <benwhal...@gmail.com> wrote:
> Is it possible to mess with the __unicode__ method of amodelto
> enable amodelinstance to return alinkto itself when viewed within
> theadmininterface? What I want is for there to be alinkon an item
> in an inline which takes the user to it's owneditpage.
>
> For example, I have a Survey system where we have questionnaires with
> pages and questions. I use a questions_in_pagemodelto store extra
> attributes for the many_to_many, and this is what appears as an inline
> in the Pageadminview (i.e. you can'teditthe question itself from
> the Pageadminview, only the object in thelinktable). I'd like to
> be able to create links directly to the questions...
>
> Any suggestions much appreciated.
>
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group
> athttp://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support