Re: Nested Foreign Key relationships in Admin?

2012-05-21 Thread Mike Dewhirst

On 21/05/2012 2:55pm, Mike Dewhirst wrote:

On 21/05/2012 2:45pm, Mike Dewhirst wrote:

On 21/05/2012 1:57pm, Aditya Sriram M wrote:

I'd like to represent foreign key relationships inside the Admin
interface when there are multiple nested one-to-many relationships.


Provided you have the admin app enabled, in your admin.py in the same 
directory as your models.py file you need some nested classes ...


class RootAdmin(admin.ModelAdmin):
# any ModelAdmin options

class Model2Admin(admin.TabularInline):# or admin.StackedInline
# any TabularInline options

class Model3Admin(admin..TabularInline):# or 
admin.StackedInline

# any TabularInline options


On 21/05/2012 7:26pm, Matt Schinckel wrote:

The admin.*Inline objects will not render nested inlines.

See https://code.djangoproject.com/ticket/9025

Matt.


As Matt pointed out the Model3 inline won't be nested. But you can 
un-indent it to the same level as the Model2 inline and both will be 
editable within the RootAdmin. I have done this previously and just 
assumed it would work at an extra level. I'll try to avoid that in future.


Mike

Actually, I meant to name the nested classes more appropriately as 
Model2Inline() and Model3Inline().


Then at the bottom of the admin.py file you need ...

admin.site.register(Root, RootAdmin)

... which includes the ModelxInlines because they are nested in your 
code.


Mike




... which ought to give you a nested view of Model2 when you examine 
Root in the admin and a nested view of Model3 inside Model2. You can 
use whatever options are listed in the docs (see below)  to control 
what happens when displaying records in the Admin app..


https://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects 



Mike





--
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Nested Foreign Key relationships in Admin?

2012-05-21 Thread Matt Schinckel
The admin.*Inline objects will not render nested inlines.

See https://code.djangoproject.com/ticket/9025

Matt.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/jZYypQmUa3cJ.
To post to this group, send email to django-users@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.



Re: Nested Foreign Key relationships in Admin?

2012-05-20 Thread Mike Dewhirst

On 21/05/2012 2:45pm, Mike Dewhirst wrote:

On 21/05/2012 1:57pm, Aditya Sriram M wrote:

I'd like to represent foreign key relationships inside the Admin
interface when there are multiple nested one-to-many relationships.


Provided you have the admin app enabled, in your admin.py in the same 
directory as your models.py file you need some nested classes ...


class RootAdmin(admin.ModelAdmin):
# any ModelAdmin options

class Model2Admin(admin.TabularInline):# or admin.StackedInline
# any TabularInline options

class Model3Admin(admin..TabularInline):# or 
admin.StackedInline

# any TabularInline options


Actually, I meant to name the nested classes more appropriately as 
Model2Inline() and Model3Inline().


Then at the bottom of the admin.py file you need ...

admin.site.register(Root, RootAdmin)

... which includes the ModelxInlines because they are nested in your code.

Mike




... which ought to give you a nested view of Model2 when you examine 
Root in the admin and a nested view of Model3 inside Model2. You can 
use whatever options are listed in the docs (see below)  to control 
what happens when displaying records in the Admin app..


https://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects 



Mike



--
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Nested Foreign Key relationships in Admin?

2012-05-20 Thread Mike Dewhirst

On 21/05/2012 1:57pm, Aditya Sriram M wrote:

I'd like to represent foreign key relationships inside the Admin
interface when there are multiple nested one-to-many relationships.


Provided you have the admin app enabled, in your admin.py in the same 
directory as your models.py file you need some nested classes ...


class RootAdmin(admin.ModelAdmin):
# any ModelAdmin options

class Model2Admin(admin.TabularInline):# or admin.StackedInline
# any TabularInline options

class Model3Admin(admin..TabularInline):# or 
admin.StackedInline

# any TabularInline options

... which ought to give you a nested view of Model2 when you examine 
Root in the admin and a nested view of Model3 inside Model2. You can use 
whatever options are listed in the docs (see below)  to control what 
happens when displaying records in the Admin app..


https://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

Mike

--
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Nested Foreign Key relationships in Admin?

2012-05-20 Thread Aditya Sriram M
I too have a similar issue. Any workarounds to achieve this...

On Saturday, 16 December 2006 09:52:39 UTC+5:30, Dan wrote:
>
> I'd like to represent foreign key relationships inside the Admin
> interface when there are multiple nested one-to-many relationships.
> Here's a simple example model to demonstrate, using the
> edit_inline=models.TABULAR parameter:
>
> __
>
> class Root(models.Model):
> name = models.CharField(maxlength=200)
> class Admin:
> pass
>
> class Model2(models.Model):
> root = models.ForeignKey(Root, edit_inline=models.TABULAR,
> num_in_admin=3)
> description = models.CharField(maxlength=2048, core=True)
>
> class Model3(models.Model):
> model2 = models.ForeignKey(Model2, edit_inline=models.TABULAR,
> num_in_admin=3)
> description = models.CharField(maxlength=500, core=True)
>
> __
>
> In the admin, when editing an instance of "Root", I can create/edit
> associated "Model2" rows inline, but there is no inline interface or
> link to create or view "Model3" rows.  Is there a techinique available
> to handle this?  Strictly speaking, I don't necessarily need the nested
> view to appear on the same page, as a link to the "Model3" view would
> suffice.
>
> I'm just getting my feet wet with Django, and I am very impressed!
> Thanks for any possible insight.
>
> Dan
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/y9nS1y2IyP8J.
To post to this group, send email to django-users@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.



Nested Foreign Key relationships in Admin?

2006-12-16 Thread Dan

I'd like to represent foreign key relationships inside the Admin
interface when there are multiple nested one-to-many relationships.
Here's a simple example model to demonstrate, using the
edit_inline=models.TABULAR parameter:

__

class Root(models.Model):
name = models.CharField(maxlength=200)
class Admin:
pass

class Model2(models.Model):
root = models.ForeignKey(Root, edit_inline=models.TABULAR,
num_in_admin=3)
description = models.CharField(maxlength=2048, core=True)

class Model3(models.Model):
model2 = models.ForeignKey(Model2, edit_inline=models.TABULAR,
num_in_admin=3)
description = models.CharField(maxlength=500, core=True)

__

In the admin, when editing an instance of "Root", I can create/edit
associated "Model2" rows inline, but there is no inline interface or
link to create or view "Model3" rows.  Is there a techinique available
to handle this?  Strictly speaking, I don't necessarily need the nested
view to appear on the same page, as a link to the "Model3" view would
suffice.

I'm just getting my feet wet with Django, and I am very impressed!
Thanks for any possible insight.

Dan


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