Opened 6 years ago

Closed 3 years ago

#19193 closed New feature (duplicate)

Save only one field to database which refereced to FieldFile

Reported by: 3dflex@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Łukasz Rekucki)


def save(self, name, content, save=True):
    if save:[])


def save(self, name, content, save=True, **kwargs)
    if save:**kwargs)

So, we get rid of re-saving fields when updating

Change History (11)

comment:1 Changed 6 years ago by Łukasz Rekucki

Description: modified (diff)
Triage Stage: UnreviewedDesign decision needed

Option 1 is highly backwards incompatible and option 2 looks like an API bloat - passing save=False and calling does exactly the same and avoids potential kwargs naming conflict.

comment:2 Changed 6 years ago by 3dflex@…

This is useful when you need to update the field contains id in the name(path), which can be obtained after the save. Now we can do:

def get_files_path(instance, filename):
    return os.path.join('files', str(, filename)

class MyFile(models.Model):
    file = models.FileField(upload_to=get_files_path), content)

The second query repeatedly update all fields, which is not acceptable when the data and fields to save is more.

Sorry for my English :)

comment:3 Changed 6 years ago by anonymous

Triage Stage: Design decision neededUnreviewed
Version: master

comment:4 Changed 6 years ago by anonymous

Version: master1.5-alpha-1

comment:5 Changed 6 years ago by Anssi Kääriäinen

Triage Stage: UnreviewedDesign decision needed

comment:6 Changed 6 years ago by Jacob

Resolution: duplicate
Status: newclosed

This ticket's effectively obsoleted by update_fields in Django 1.5 (

comment:7 Changed 6 years ago by 3dflex@…

Resolution: duplicate
Status: closednew

comment:8 Changed 6 years ago by anonymous

Version: 1.5-alpha-11.5

comment:9 Changed 6 years ago by Alex Gaynor

Triage Stage: Design decision neededAccepted

Marking as accepted, the ability to not save all the things makes sense. Not sure if it should be the default or an option yet.

comment:10 Changed 6 years ago by anonymous

Keywords: django 1.5 removed
Version: 1.5master

As the expected release of Django 1.6, can we see this feature in it?

comment:11 Changed 3 years ago by Tim Graham

Resolution: duplicate
Status: newclosed

The reason this was originally closed is because you can do this:, content, save=False)['file'])

This seems acceptable to me.

Note: See TracTickets for help on using tickets.
Back to Top