This wouldn't work. It will work for updates, but when a new Decision
object is created, "get_file_path" runs before the object is saved and
self.id will be None.
On Sep 5, 6:51 pm, Bingimar wrote:
> try this
>
> def get_file_path(instance, filename):
> path = 'your upload directory'
> ex
try this
def get_file_path(instance, filename):
path = 'your upload directory'
extension = filename.split('.')[-1].lower()
new_file_name = self.id
return '%(path)s/%(filename)s.%(extension)s' %
{
Hello,
I have a model that includes a FileField. When the user uploads a file
via the admin interface, I want the file to be saved as 'upload_to/
primary_key/original_filename'. Since the object will not be saved in
the database when the user uploads the file, it will not have a
primary key at tha
I forgot to mention that i have imported models like this:
import django.db.models as m
This should explain the first two lines.
On Mon, Sep 5, 2011 at 12:28 PM, Stratos Moros wrote:
> Hello,
>
> I have a model that includes a FileField. When the user uploads a file
> via the admin interface, I
4 matches
Mail list logo