> Hi, I'm getting started in the (highly enjoyable!) admin models -
> FileField upload works when I give upload_to the full absolute
> filepath.
> However, as soon as I try and use MEDIA_ROOT in settings.py it baulks.
what do you mean by 'baulks' - what is the error message?
--
regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/
Best,
Ben
--
--
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.8/1415 - Release Date:
05/05/2008 06:01
> Thanks for for your swift attention.
> It reloads the same form with the message at the top: 'Please correct
> the error below.' (although it doesn't actually show any error below).
please paste your model here
Class HIP has a 1-to-many with Property (many HIPs / 1 Property) . The
offending field is HIP.hip
#CODE
class Property(models.Model):
"""Model of a property"""
reference = models.CharField(max_length=20)
Archive = models.BooleanField()
SSTC = models.BooleanField()
price_prefix =
models.IntegerField(max_length=1,choices=PRICE_PREFIX,default=2) #temp
price = models.DecimalField(max_digits=10,decimal_places=2)
address_1 = models.CharField(max_length=50)
address_2 = models.CharField(max_length=50)
address_3 = models.CharField(max_length=50,blank=True)
address_4 = models.CharField(max_length=50,blank=True)
postcode = models.CharField(max_length=10)
property_type =
models.CharField(max_length=30,choices=TYPES,default='House')
bedrooms = models.IntegerField()
reception_rooms = models.IntegerField(null=True,blank=True)
summary = models.CharField(max_length=200)
description = models.TextField(blank=True)
lease_years = models.IntegerField(null=True,blank=True)
ground_rent =
models.DecimalField(null=True,max_digits=10,decimal_places=2,blank=True)
service_charge =
models.DecimalField(null=True,max_digits=10,decimal_places=2,blank=True)
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
class HIP(models.Model):
hip = models.FileField(upload_to='/tmp',core=True)
property =
models.ForeignKey(Property,edit_inline=models.TABULAR,num_in_admin=10,ma
x_num_in_admin=10,min_num_in_admin=10)
#END
If I change the upload_to to ='/full/path/to/tmp', (so long as
MEDIA_ROOT = '') it works fine!
As soon as I switch to MEDIA_ROOT = '/full/path/to/' and upload_to =
'/tmp' (all slash permutation tried!) it's 'Please correct the error
below'.....
Maybe this will be of help: the MEDIA_URL is: 'http://example.com/tmp/
(there is a further tmp subdir within that) and when the files save
correctly the admin form shows the link as the absolute path that was
written in upload_to clicking to http//example.com +appended with the
same absolute path 'http://www.example.com/absolute/path/to/file.txt'.
-----Original Message-----
From: django...@googlegroups.com
[mailto:django...@googlegroups.com] On Behalf Of Kenneth Gonsalves
Sent: 05 May 2008 14:29
To: django...@googlegroups.com
Subject: Re: Filefield upload_tol
--
--
> hip = models.FileField(upload_to='/tmp',core=True)
try upload_to='tmp' <----------- no '/'
edit_inline is known to be buggy - some validation faliures on models
that are being edited inline aren't rendered, but the user is told
there is an error. I think there are a number of tickets logged, but
the official word is to wait until newforms-admin is complete. (I
think, anyone know better?)
Cheers,
Mike
-----Original Message-----
From: django...@googlegroups.com
[mailto:django...@googlegroups.com] On Behalf Of Kenneth Gonsalves
Sent: 05 May 2008 15:14
To: django...@googlegroups.com
Subject: Re: Filefield upload_tol
--
--
Thanks for your attention on this.
Kg solved this a few moments back. As suspected, a bit of basic muppetry
on my part.
Solution was only to change:
Upload_to = '/tmp'
TO:
Upload_to = 'tmp'
Nice.