Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Problem with form.save() #21

Closed
iraycd opened this issue Dec 10, 2012 · 2 comments
Closed

Problem with form.save() #21

iraycd opened this issue Dec 10, 2012 · 2 comments

Comments

@iraycd
Copy link

iraycd commented Dec 10, 2012

def form_valid(self, form):
    self.object = form.save()
    f = self.request.FILES.get('file')

I'm changing my file name. so i get the "INTERNAL SERVER ERROR".
Can you tell a better way where i can get the changed name in the next step.

Instead of requesting the file. I want to request the DB.

@sigurdga
Copy link
Owner

I'm not sure of what you are trying to accomplish. I hope you have sorted it out one way or another. Sorry for my very late answer.

Here I have a view that is setting the filename before saving the object.

    if form.is_valid():
        uploaded_file = form.save(commit=False)
        uploaded_file.user = request.user
        uploaded_file.filename = request.FILES['file'].name
        uploaded_file.save()

@iraycd
Copy link
Author

iraycd commented Jan 26, 2013

👍
But, i solved the issue long back. what i was trying to do is i changed the name of the file.
Because if the file name of 2 files is the same it returns back the old picture.

@iraycd iraycd closed this as completed Jan 26, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants