当我尝试使用request.Files时,我收到以下错误
WSGIRequest' object has no attribute 'Files'
继承人我的观点.py
from django.contrib import messages
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404, redirect
from .forms import PostForm
from .models import Post
def post_create(request):
form = PostForm(request.POST or None, request.Files or None)
if form.is_valid():
instance = form.save(commit=False)
instance.save()
messages.success(request, "Created !!")
return HttpResponseRedirect(instance.get_absolute_url())
else:
messages.error(request, "not Created !!")
context = {
"form": form,
"title": "Create Form"
}
return render(request, "posts/post_form.html", context)
但在教程中,我正在观看他毫无障碍地使用它。我该如何解决这个问题?
答案 0 :(得分:2)
我认为你拼错了,Getting the Advertising Identifier
而不是request.FILES
request.Files