I have heard it might not be made for this, but I’d really like to have it just take the file’s name for the slug and title.
class RandomAdmin(admin.ModelAdmin):
prepopulated_fields = {
'slug': ('image',),
'title': ('image',)
}
where ‘image’ is an ImageField…
image = models.ImageField(upload_to="random_uploads")
If the files name is ‘abc_123.jpg’, I get ‘cfakepathabc_123jpg’. I’d like to get ‘abc_123jpg’ or ‘abc_123’.
Any tips for me? 🙂
Cannot be done trivially, without modifying prepopulated_fields_js.html, since it just looks for the value of the dependent fields.
In otherwords, you can’t just do it by changing something in the ModelAdmin. You’d have to override prepopulated_fields_js.html and make some specific exceptions.