3 | | >>> import os |
4 | | >>> from django.conf import settings |
5 | | >>> initial_path = car.photo.path |
6 | | >>> car.photo.name = 'cars/chevy_ii.jpg' |
7 | | >>> new_path = settings.MEDIA_ROOT + car.photo.name |
8 | | >>> # Move the file on the filesystem |
9 | | >>> os.rename(initial_path, new_path) |
10 | | >>> car.save() |
11 | | >>> car.photo.path |
| 3 | {{{ |
| 4 | import os |
| 5 | from django.conf import settings |
| 6 | initial_path = car.photo.path |
| 7 | car.photo.name = 'cars/chevy_ii.jpg' |
| 8 | new_path = settings.MEDIA_ROOT + car.photo.name |
| 9 | # Move the file on the filesystem |
| 10 | os.rename(initial_path, new_path) |
| 11 | car.save() |
| 12 | car.photo.path |