Home>

I have a form based on UpdateViewclass:

class UserUpdateView(UpdateView):
    model= user
    fields= ['name', 'text', 'tel', 'adress', 'img', 'name_link_1',
        'link_1','name_link_2', 'link_2','name_link_3', 'link_3',
        'name_link_4', 'link_4','name_link_5', 'link_5',]
    template_name_suffix= '_update_form'
    def get_context_data(self, **kwargs):
        context= super(UserUpdateView, self).get_context_data(**kwargs)
        if not self.request.user.pk== self.object.pk:
            return redirect('login')
        return context

There is only one image in the form, which is associated with one specific user. I want to give it the name of the pkof the user instead of the name of the uploaded image. The question is, how can I do this?

models.py:

img= models.ImageField('Your avatar', upload_to='images/', blank=True)