0

Look I have a problem with displaying photos after updating.

I have a function from my views.py

def addHW(request):
    if request.user.is_authenticated:
        obj = Profile.objects.get(user=request.user.id)
    else:
        obj = ''
    profile = request.user.profile
    form = CustomerForm(instance=profile)
    template = 'HW/add.html'
    context = {'form': form, 'profile': obj}

    if request.method == 'POST':
        form = CustomerForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            Profile.objects.get(user=request.user.id).photo.delete()
            form.save()

    return render(request, template, context)

and after deleting previous photo and saving of new photo, page must be reloaded. And page shows visual reloading, but HTML shows src of previous image. And after manual refreshing page displays new src of photo. How i can resolve it?

suhailvs
  • 20,182
  • 14
  • 100
  • 98

1 Answers1

-1

In case of a successful post, you need to make a redirect to implement the Post/Redirect/Get pattern.