django - Overriding url() from ImageField -
i have image field
avatar = models.imagefield(upload_to="avatar", null=true, blank=true)
and using view
class editview(successmessagemixin, updateview): model = mysiteuser form_class = mysiteuserform pk_url_kwarg = 'pk' template_name = 'update_form.html' success_url = '/myprofile/' success_message = "zmiany zostaĆy wprowadzone." def form_valid(self, form): image_to_del = mysiteuser.objects.get(username=form.instance) print("na dysku plik", image_to_del.avatar) print("formularz pole 'avatar'", form.instance.avatar) if form.instance.avatar != self.request.user.avatar: self.request.user.avatar.delete() return super().form_valid(form)
in template form
<form action="" method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="save" /> </form>
i want change link below
<p><label for="id_avatar">zdjecie:</label> now: <a href="/media/avatar/n.jpg">avatar/n.jpg</a>
on image, how can this?
Comments
Post a Comment