No thumbnail migrations appear - Django 2.2 version

59 views Asked by At

I did step by step to implement sorl-thumbnail in my Django project. But no migrations thumbnail created so images do not get added via sending form but still get added by admin interface.

I use:

  • Python 3.9
  • Django 2.2.16
  • Pillow 9.3.0
  • sorl-thumbnail 12.9.0

What I did.

pip install pillow, sorl-thumbnail

In INSTALLED_APPS added 'sorl.thumbnail'

In template

1

There are 1 answers

0
Emelian Pugachev On BEST ANSWER

Fixed this problem: I had to add this files=request.FILES or None, in the view function

    form = PostForm(
        request.POST or None,
        files=request.FILES or None,)

    if form.is_valid():
        form.instance.author = request.user
        form.save()
        return redirect("posts:profile", request.user.username)

    return render(request, 'posts/create_post.html', {'form': form})```