skip to Main Content

Html – How to create instance of a django model

views.py def create_post(request): profile_inst = Profile.objects.filter(author_real=request.user).first() print(profile_inst) if request.method == 'POST': print('POST request') form = CreatePost(request.POST,request.FILES) if form.is_valid(): print(request.FILES) form.save() else: print('JUST a VISIT!') form=CreatePost(initial={'author':profile_inst}) return render(request,'create_post.html',{'form':form}) ValueError at /create_post/ Cannot assign "'username | admin'": "Post.author" must be a "Profile"…

VIEW QUESTION
Back To Top
Search