Image/file upload and use approaches

105 views
Skip to first unread message

Donn

unread,
Aug 9, 2008, 12:49:54 PM8/9/08
to django...@googlegroups.com
Hi,
I am wondering, in general, how you Django-ites handle image/file uploading.

If you want to give your admins/managers some way to upload images or docs and
then refer to them in articles etc. what are the built-in approaches?

I have seen a few image/file browsers, one looks really good but it requires
some hacking into Django which I don't want to mess with.

I am thinking: Have an ImageFile model and let people upload from it, via
admin. Then they simply have to remember the filename when they refer to it
someplace -- say in an article (perhaps using tinymce). This does not sound
friendly enough though.

What are your tricks?
\d

Donn

unread,
Aug 10, 2008, 1:26:50 PM8/10/08
to django...@googlegroups.com
No one got an opinion?

\d

Erik Allik

unread,
Aug 10, 2008, 1:29:28 PM8/10/08
to django...@googlegroups.com
Hey,

I've been wondering about the same thing myself. I don't think it's
good to hard-code URLs to files in the HTML body of an article. I know
that at least FCKeditor has plugin/extension support so it should be
possible to write a plugin that retrieves a list of model objects that
contain files and inserts images/links into the HTML. Additional
special markup should be added to be able to keep the URLs in sync if
for some reason the file that is being referred to is deleted or
moved. I guess you can ask the FCKeditor/tinyMCE/etc. guys about the
plugin support of the corresponding editor.

It'd be real nice if you kept me in sync with any progress you make,
too. :)

Regards,
Erik

Donn

unread,
Aug 10, 2008, 1:50:15 PM8/10/08
to django...@googlegroups.com
On Sunday, 10 August 2008 19:29:28 Erik Allik wrote:
> It'd be real nice if you kept me in sync with any progress you make,  
> too.
This thread is likely to be the place. Thanks for the input.

\d

Donn

unread,
Aug 11, 2008, 12:54:01 PM8/11/08
to django...@googlegroups.com
I'm kinda surprised that this is not a question that gathers wider views.
Surely managing uploads is a thing just about every site must do?

\d

Erik Allik

unread,
Aug 11, 2008, 1:17:22 PM8/11/08
to django...@googlegroups.com
I share your opinion, Donn. Let's hope people will come to their
senses. :)

Erik

Marty Alchin

unread,
Aug 11, 2008, 1:47:01 PM8/11/08
to django...@googlegroups.com
On Mon, Aug 11, 2008 at 1:17 PM, Erik Allik <eal...@gmail.com> wrote:
> I share your opinion, Donn. Let's hope people will come to their
> senses. :)

Some people have been following this thread fairly closely, trying to
figure out if there's actually a feature being requested here. Any
time I see "Image/file upload" my antennae perk up, but I really can't
figure out what you're asking for.

On one hand, it sounds like there's a request for including a rich
editor, with a file picker for images. I can almost certainly assume
that'll never happen in Django; that's third-party app territory.
Maybe there's something else.

There also seems to be a request to be able to type a filename and
have it magically transformed into a URL. First, something has to
parse that filename and turn it into a URL, which again sounds like
third-party app territory. Second, in the current trunk (after
changest 8244, that is), there's no longer a simple mapping between
filenames and URLs. Each storage system might give different URLs for
a given filename, and you can have different storage sytems on
different models (or even on different fields in the same model).

There may well be a void here for a third-party application to fill,
but I can't tell what that void really is. If you guys have a need,
maybe you can put your heads together and come up with a solution for
it. Maybe a markdown extension or a new markup syntax entirely, I
don't know. Maybe the solution is to write your articles in templates,
so that you can just use something like {{
article.image_set.1.image.url }}.

There are a number of options, but I think there needs to be a more
solid need before anybody can hope to fill it.

-Gul

Donn

unread,
Aug 11, 2008, 2:42:00 PM8/11/08
to django...@googlegroups.com
On Monday, 11 August 2008 19:47:01 Marty Alchin wrote:
> There may well be a void here for a third-party application to fill,
> but I can't tell what that void really is.
From my pov it's a missing section in the admin. One can upload an Image (say)
based on an ImageField and click to view it, but referring to the 'media' in
other fields is hard to do. It demands copy-paste or just remembering what
the urls are. For example putting images into a flatpage - If there were a
box on the side of the screen that showed thumbnails and urls that would
simplify the process.

Some kind of connection between media and urls from the admin is what I feel
is missing.

> Maybe the solution is to write your articles in templates,

I'm not fluent enough in django to follow that, not being sure what you mean
by articles.

> There are a number of options, but I think there needs to be a more
> solid need before anybody can hope to fill it.

My OP basically said it - I was hoping to hear from people about how they
manage media and allow their users to do so. I imagined that since Django
came from a newspaper/magazine background there must have been this intimate
tie-up between words and text.

Nevertheless, thanks for the input.
\d

Marty Alchin

unread,
Aug 11, 2008, 2:49:56 PM8/11/08
to django...@googlegroups.com
On Mon, Aug 11, 2008 at 2:42 PM, Donn <donn....@gmail.com> wrote:
> From my pov it's a missing section in the admin. One can upload an Image (say)
> based on an ImageField and click to view it, but referring to the 'media' in
> other fields is hard to do. It demands copy-paste or just remembering what
> the urls are. For example putting images into a flatpage - If there were a
> box on the side of the screen that showed thumbnails and urls that would
> simplify the process.

That implies some specific markup processor to handle those cases.
Flatpages themselves are just passed to a template. What that template
does with it (running it through markdown, textile or
reStructuredText, for instance) is beyond Django's ability to control.
There's no way to insert images into a flatpage without knowing how
it'll be rendered, so there's not really a way for Django to do this
for you.

It might be possible for an app to do this, but only by forcing you to
use a specific markup library. Django won't do that.

>> Maybe the solution is to write your articles in templates,
> I'm not fluent enough in django to follow that, not being sure what you mean
> by articles.

I don't mean anything about Django here. By "articles" I mean whatever
you meant when you wrote: "If you want to give your admins/managers


some way to upload images or docs and then refer to them in

-->articles<-- etc. what are the built-in approaches?"

>> There are a number of options, but I think there needs to be a more
>> solid need before anybody can hope to fill it.
> My OP basically said it - I was hoping to hear from people about how they
> manage media and allow their users to do so. I imagined that since Django
> came from a newspaper/magazine background there must have been this intimate
> tie-up between words and text.

Okay, I'll grant you that. I'll stand aside and let those people
who've done this in the past explain how they did it (since I don't
know), but I don't think asking for explicit admin integration is
gonna get you anywhere.

-Gul

Donn

unread,
Aug 11, 2008, 4:22:57 PM8/11/08
to django...@googlegroups.com
On Monday, 11 August 2008 20:49:56 Marty Alchin wrote:
> I'll stand aside and let those people
> who've done this in the past explain how they did it (since I don't
> know), but I don't think asking for explicit admin integration is
> gonna get you anywhere.
Cool, I hear you and I'll also wait and see what happens to the thread.

\d

John M

unread,
Aug 11, 2008, 4:53:17 PM8/11/08
to Django users
I too am at a loss as to what is being requested?

If you create a simple model with a category and imagefield, and
create a pass version form for admin, you can upload imagefiles to the
server w/o issue and then search based on Category.

I just created a quick form (filefield only) that allows me via curl
on a remote machine to upload files easily into the server, and then I
have views which will allow me to download various files.

Is this what is being asked for? If so, just update to the latest
trunk version with New Form's admin and it's there.

John

Donn

unread,
Aug 11, 2008, 5:14:13 PM8/11/08
to django...@googlegroups.com
On Monday, 11 August 2008 22:53:17 John M wrote:
> If you create a simple model with a category and imagefield, and
> create a pass version form for admin, you can upload imagefiles to the
> server w/o issue and then search based on Category.

Hi, what is a 'pass version' form? Perhaps it's something I missed.

\d

John M

unread,
Aug 11, 2008, 7:28:08 PM8/11/08
to Django users
Wow, sorry about that, it is very hard to understand.

What I meant was to create a form with the New Form Admin branch with
just the two fields on them. One is the category and the other the
imagefield, with an automatic browse button to allow the user to pick
the file to upload. From there, the NFA branch will help the browser
upload the file to the server (to where upload_to points to in your
model). It works very well.

A basic file upload app is very easy now with NFA, and has even been
improved more with the file handling update they just added to trunk,
although I haven't used the new updates yet, I only needed the NFA
stuff.

HTH

John

Donn

unread,
Aug 12, 2008, 2:38:04 AM8/12/08
to django...@googlegroups.com
On Tuesday, 12 August 2008 01:28:08 John M wrote:
> Wow, sorry about that, it is very hard to understand.
Heh, I know the feeling :)

> What I meant was to create a form ...
Okay, I think I see what you mean. I guess I have been stuck on the flatpages
concept -- using them as a means to allow the user to create content quickly,
but darned if I know how to allow them to place images and links to media (in
an easy way).

So, I'd create my own 'flatpage' with an inline section of image & "reference"
and then a template to draw it all would place the images in the page based
on some system - perhaps a div id = reference, or a sub-template language of
some kind to be replaced by the view before the html string hits the
template.

My initial impression is still there, however. Look at the date picker that
admin provides. That could also be dismissed as '3rd party' and left at that.
I think a media picker should be built-in so that references to media (<a>
tags) can be generated as quickly as proper dates are. Admittedly I have not
thought deeply upon this and still need to work out the question :)

Anyway, thanks for the clarification.
\d

Reply all
Reply to author
Forward
0 new messages