Took me a bit to get .FileField() working in the admin, and im wondering if it 
needs to be as complicated as it seems.  I think it currently violates DRY, and 
maybe that was intentional for 'security' or 'performance' reasons, or maybe it 
was just an oversight.

I did the following, and got the following.

[EMAIL PROTECTED]:~/django$ django-admin.py startproject filez
[EMAIL PROTECTED]:~/django/filez$ ./manage.py startapp pics

DATABASE_ENGINE = 'mysql'
db, user, pass ...

INSTALLED_APPS = (
     'django.contrib.admin',
     'filez.pics',

# models.py
from django.db import models
class File(models.Model):
     attachment = models.FileField(upload_to='attaches', blank=True )
     class Admin:
         pass

# urls.py
     # Uncomment this for admin:
      (r'^admin/', include('django.contrib.admin.urls')),


http://dell29:8000/admin/pics/file/add/
Give it a file name (text box or browse button) hit Save.
(it will create the attaches dir.  not sure if that is a good thing or not. 
personally I would rather it error, but at least it makes it obvious where the 
dir 'is'.)

http://dell29:8000/admin/pics/file/1/
source: <a href="attaches/P1010001.JPG"> attaches/P1010001.JPG </a><br>

which is:
http://localhost:8000/admin/pics/file/1/attaches/P1010001.JPG
click that, get

404, Using the URLconf defined in filez.urls, Django tried these URL patterns, 
in this order: ...  The current URL, admin/pics/file/1/attaches/P1010001.JPG, 
didn't match any of these.

As in, it can't find where it put it.  Seems to me the default should be to be 
able to figure that out.  With some help from #django I did get it working, but 
it didn't seem 'right.' so I figured I would throw up a flag and see if anyone 
thinks some tweaks need to happen, or point to the docs that show me how to do 
this the easy way.

Carl K

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

Reply via email to