M
M
maxclax2014-12-21 22:47:08
Django
maxclax, 2014-12-21 22:47:08

ImageField not to change names?

I have a field in the model:
icon = models.ImageField(upload_to='icon')
In my situation, many entries can have the same icon. When creating an entry and adding an icon to it through the admin panel, if there is no such icon, it does not change the name and everything is as it should be. When I add it with the same icon, the script renames it and it turns out that there is a duplicate on the server.
How to make it so that it does not change the name of the icon, and well, if there is already one, let it just overwrite it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey K, 2014-12-22
@mututunus

In my situation, many entries can have the same icon.

Make the icon a foreign key.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question