Re: [mezzanine-users] Nested inline admins

2015-05-19 Thread Josh Cartmell
Hi Tom, I would do something like this:
https://gist.github.com/joshcartme/6856ee5e35c7a6456d9e

I just through that together so there probably are typos and missing
imports, but it's a pattern I've used many times.

If you follow that, you second level inline will have a link that says
Edit third level.  Clicking the link will open the SecondLevelAdmin
(which doesn't show in the menus since it already has an inline) from which
you can edit the third level inlines.

It may be a bit hacky, but I think it works pretty well.  The key is that
SecondLevel has both an inline created for it and it's own admin class.
The inline for editing most of it's content, and the admin class for
editing it's own inlines.

Good luck!

On Sun, May 17, 2015 at 8:28 AM, Tom Cook tom.k.c...@gmail.com wrote:

 Hi Eduardo,

 Thanks for your advice.  What I'm trying to do is a bit like a gallery,
 but where individual photos can have several images attached to them.  The
 purpose of this is for preserving some old photos where some have several
 prints of the same negative or where I want to capture both the front and
 back of the photo because it has a description written on it and so on.  To
 do this, I'm using a model like this:

 class Gallery(Page):
 pass

 class GalleryImage(Orderable):
 gallery = ForeignKey('Gallery')
 caption = CharField(max_length = 200)
 description = TextField()

 def get_thumbnail(self):
 pass  # ie fill it in later

 class GalleryImageVersion(Orderable):
 gallery_image = ForeignKey('GalleryImage')
 thumbnail = FileField(...)
 small_version = FileField(...)
 full_size_version = FileField(...)

 That's only a sketch of the model, of course, but it gives you the idea.
 So I'd like to have an admin page for each Gallery, with GalleryImage
 instances shown as stackable inlines and then each GalleryImageVersion as a
 tabular inline within the stackable inline.

 As far as I can tell, my options are either to use straight Django admins
 (I note that Django-latest has had inlineable admins for the last few days,
 not sure if I want to go that bleeding edge) or come up with some other
 structure.  Is that about right?

 Thanks again,
 Tom

 On Thursday, 14 May 2015 10:04:59 UTC+9:30, Eduardo Rivas wrote:

  Hi Tom. For your particular requirements, I would say no, Mezzanine
 lacks this feature. There are some projects out there that are meant to do
 it for vanilla Django https://github.com/s-block/django-nested-inline
 and for Grappelli https://github.com/datahub/grappelli-nested-inlines.
 In the case of that last one, remember Mezzanine uses a custom version of
 Grappelli which might not be identical to the standard Grappelli. I can't
 vouch for these projects, they just came up first on a Google search.

 As a side note, I would recommend you reconsider the approach of what
 you're trying to do. I've found myself sometimes wishing to have nested
 inlines, but most of the times it is because I want sorting functionality
 or I'm trying to edit several models related to each other. In the first
 case, I've used Django admin sortable
 https://github.com/iambrandontaylor/django-admin-sortable (which works
 great with Mezzanine) to add a Sort button to the list view of my models.
 In the second case, I often add links to edit related objects from one list
 view to another (using admin URLs and filters in the GET parameters).
 Perhaps you'll be interested in exploring these routes.

  --
 You received this message because you are subscribed to the Google Groups
 Mezzanine Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to mezzanine-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Nested inline admins

2015-05-13 Thread Josh Cartmell
Hi Tom, I'm guessing you meant page.  The answer is yes.

Do something like this in your admin.py:

from mezzanine.pages.admin import PageAdmin

from .models import MyPageModel

...set up some inlines here...

class MyPageModelAdmin(PageAdmin):
inlines = ['whatever', 'inlines', 'you', 'want']
admin.site.register(MyPageModel, MyPageModelAdmin)

Good luck!

On Wed, May 13, 2015 at 9:47 AM, Tom Cook tom.k.c...@gmail.com wrote:

 Is it possible to nest inline admins in pace admins in mezzanine?

 --
 You received this message because you are subscribed to the Google Groups
 Mezzanine Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to mezzanine-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Nested inline admins

2015-05-13 Thread Tom Cook
Hi Josh,

Yes, s/pace/page/.  Typing on a phone late at night, I'm afraid.

I don't quite get what you've suggested.  Won't that give me several 
inlines one after the other?  What I mean is a model like this:

class TopLevel(Page):
pass

class SecondLevel(Orderable):
parent = ForeignKey('TopLevel')

class ThirdLevel(Orderable):
parent = ForeignKey('SecondLevel')

and an admin like this:

class ThirdLevelInline(TabularDynamicInlineAdmin):
model = ThirdLevel

class SecondLevelInline(StackedDynamicInlineAdmin):
model = SecondLevel
inlines = (ThirdLevelInline,)

class TopLevelAdmin(PageAdmin):
inlines = (SecondLevelInline,)

admin.site.register(TopLevel, TopLevelAdmin)

Is it possible?


On Thursday, 14 May 2015 00:35:52 UTC+9:30, Josh Cartmell wrote:

 Hi Tom, I'm guessing you meant page.  The answer is yes.

 Do something like this in your admin.py:

 from mezzanine.pages.admin import PageAdmin

 from .models import MyPageModel

 ...set up some inlines here...

 class MyPageModelAdmin(PageAdmin):
 inlines = ['whatever', 'inlines', 'you', 'want']
 admin.site.register(MyPageModel, MyPageModelAdmin)

 Good luck!

 On Wed, May 13, 2015 at 9:47 AM, Tom Cook tom.k...@gmail.com 
 javascript: wrote:

 Is it possible to nest inline admins in pace admins in mezzanine?

 --
 You received this message because you are subscribed to the Google Groups 
 Mezzanine Users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to mezzanine-use...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Nested inline admins

2015-05-13 Thread Eduardo Rivas
Hi Tom. For your particular requirements, I would say no, Mezzanine 
lacks this feature. There are some projects out there that are meant to 
do it for vanilla Django 
https://github.com/s-block/django-nested-inline and for Grappelli 
https://github.com/datahub/grappelli-nested-inlines. In the case of 
that last one, remember Mezzanine uses a custom version of Grappelli 
which might not be identical to the standard Grappelli. I can't vouch 
for these projects, they just came up first on a Google search.


As a side note, I would recommend you reconsider the approach of what 
you're trying to do. I've found myself sometimes wishing to have nested 
inlines, but most of the times it is because I want sorting 
functionality or I'm trying to edit several models related to each 
other. In the first case, I've used Django admin sortable 
https://github.com/iambrandontaylor/django-admin-sortable (which works 
great with Mezzanine) to add a Sort button to the list view of my 
models. In the second case, I often add links to edit related objects 
from one list view to another (using admin URLs and filters in the GET 
parameters). Perhaps you'll be interested in exploring these routes.


--
You received this message because you are subscribed to the Google Groups Mezzanine 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.