Adding MediaFile inline to 3rd party model's admin?

24 views
Skip to first unread message

t scytale

unread,
Jan 31, 2012, 4:00:28 PM1/31/12
to django-...@googlegroups.com
I'm using using from feincms.module.medialibrary.models.MediaFile in my own models. 
At the moment it's admin field shows as a drop-down list with a '+' to open a new window to add new files (see attached image "current_media_inline.png")
I'd really like to have field that uses the MediaFile inline form that shows up on feincms admin pages (see attached image "feincms_media_inline.png")
I've been reading the feincms source to try to figure out how to get this working but not making progress.
I'd really appreciate any tips on how to set this up because at the moment 

thanks

At the moment here's my setup:

models.py:

from feincms.module.medialibrary.models import MediaFile
from feincms.module.medialibrary.fields import MediaFileForeignKey
...
class Foo(models.Model):
    ...
    image = MediaFileForeignKey(MediaFile, blank=True, null=True)

---

I've 
current_media_inline.png
feincms_media_inline.png

Matthias Kestenholz

unread,
Jan 31, 2012, 4:19:02 PM1/31/12
to django-...@googlegroups.com

Hi

You have to add the image field to raw_id_fields when registering your model with the admin site. Otherwise, MediaFileForeignKey behaves exactly the same way as a stock Django ForeignKey.

Best,
Matthias

--
You received this message because you are subscribed to the Google Groups "Django FeinCMS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-feincms/-/ebeK7pHkLw8J.
To post to this group, send email to django-...@googlegroups.com.
To unsubscribe from this group, send email to django-feincm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-feincms?hl=en.

t scytale

unread,
Feb 6, 2012, 8:26:05 AM2/6/12
to django-...@googlegroups.com
ah! of course! thanks very much.

I have to say that the mediafile library is excellent as a stand-alone project.

t
Reply all
Reply to author
Forward
0 new messages