Display related foreign key values in Admin - but not inline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Display related foreign key values in Admin - but not inline

orestis-2

Hello, I have a model of EnglishWords and GreekWords. EnglishWords are
referenced as a ForeignKey in GreekWords, ie one EnglishWord may have
more than one GreekWords referencing it.

I would like when going in admin to edit an EnglishWord to see what
Greek words are referencing it, and be able to click on each GreekWord
and go to its edit page.

If I use edit_inline, I suppose I'll get a huge select box of all the
GreekWords there, and I don't want that.

Thanks!


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

Reply | Threaded
Open this post in threaded view
|

Re: Display related foreign key values in Admin - but not inline

Malcolm Tredinnick

On Wed, 2006-10-11 at 15:40 +0000, orestis wrote:

> Hello, I have a model of EnglishWords and GreekWords. EnglishWords are
> referenced as a ForeignKey in GreekWords, ie one EnglishWord may have
> more than one GreekWords referencing it.
>
> I would like when going in admin to edit an EnglishWord to see what
> Greek words are referencing it, and be able to click on each GreekWord
> and go to its edit page.
>
> If I use edit_inline, I suppose I'll get a huge select box of all the
> GreekWords there, and I don't want that.

The admin page does not operate in the way you want. You will need to do
some deep customisation in order to make that happen. There's been some
discussion on this list recently about how to customise the appearance
of various pages. You will also possibly have to write your own template
tags here, too. Not impossible if you approach with the right mindset,
but it's not "out of the box".

Regards,
Malcolm



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

Reply | Threaded
Open this post in threaded view
|

Re: Display related foreign key values in Admin - but not inline

PatrickK-2

if I´m not mistaken, what malcolm described is not too hard to achieve.

### copy the change_form.html to you personal admin-directory
### change the change_form: add something like {% ShowGreekWords  
object_id %}
### GreekWords is a templatetag which might look like:
from django.template import Library
register = Library()

def ShowGreekWords(object_id):
     from app.words.models import GreekWord

     greek_words_list = GreekWord.objects.filter(englishword=object_id)

     return {
         'greek_words': greek_words_list,
     }

register.inclusion_tag('admin/tag_container/list_greekwords.html')
(ShowGreekWords )

### finally, you have to write the template mentioned above (which is  
probably a list of greek words linked to its edit page)

patrick


Am 12.10.2006 um 03:39 schrieb Malcolm Tredinnick:

>
> On Wed, 2006-10-11 at 15:40 +0000, orestis wrote:
>> Hello, I have a model of EnglishWords and GreekWords. EnglishWords  
>> are
>> referenced as a ForeignKey in GreekWords, ie one EnglishWord may have
>> more than one GreekWords referencing it.
>>
>> I would like when going in admin to edit an EnglishWord to see what
>> Greek words are referencing it, and be able to click on each  
>> GreekWord
>> and go to its edit page.
>>
>> If I use edit_inline, I suppose I'll get a huge select box of all the
>> GreekWords there, and I don't want that.
>
> The admin page does not operate in the way you want. You will need  
> to do
> some deep customisation in order to make that happen. There's been  
> some
> discussion on this list recently about how to customise the appearance
> of various pages. You will also possibly have to write your own  
> template
> tags here, too. Not impossible if you approach with the right mindset,
> but it's not "out of the box".
>
> Regards,
> Malcolm
>
>
>
> >


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

Reply | Threaded
Open this post in threaded view
|

Re: Display related foreign key values in Admin - but not inline

orestis-2

Thanks! I'll try that and get back here...


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