# 'WSGIRequest' object has no attribute 'form\_class'

**URL:** <https://forum.djangoproject.com/t/wsgirequest-object-has-no-attribute-form-class/33389>\
**Category:** Forms & APIs\
**Created:** [July 29, 2024, 4:29pm UTC](https://forum.djangoproject.com/t/wsgirequest-object-has-no-attribute-form-class/33389 "2024-07-29T16:29:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliRamezani](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/aliramezani/32/22907_2.png) [@AliRamezani](https://forum.djangoproject.com/u/AliRamezani)\
**Post date:** [July 29, 2024, 4:29pm UTC](https://forum.djangoproject.com/t/wsgirequest-object-has-no-attribute-form-class/33389/1 "2024-07-29T16:29:48Z")

</div>

hey there  
i’m working on a social media project for practice and i keep getting an error

i have created views and Forms to create an update the posts

i get the WSGIRequest for the line of 64  
and i wonder why i dont get the error for i just did in line 52

 ![11](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/0/5/0533df98971da8f147aa436630bc75929f8fe842.png)

---

<div class="post-metadata">

**Author:** ![leandrodesouzadev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/leandrodesouzadev/32/8981_2.png) [@leandrodesouzadev](https://forum.djangoproject.com/u/leandrodesouzadev)\
**Post date:** [July 29, 2024, 4:56pm UTC](https://forum.djangoproject.com/t/wsgirequest-object-has-no-attribute-form-class/33389/2 "2024-07-29T16:56:34Z")

</div>

Please don’t post image of code, post the code itself using the tools for formatting code.

If you look closely on line 68, you’ll see that you have misarranged the parameters on their positions, and they ended up swapped.  
You probably want to have `self` as the first parameter for that function.

---

<div class="post-metadata">

**Author:** ![AliRamezani](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/aliramezani/32/22907_2.png) [@AliRamezani](https://forum.djangoproject.com/u/AliRamezani)\
**Post date:** [July 30, 2024, 1:05pm UTC](https://forum.djangoproject.com/t/wsgirequest-object-has-no-attribute-form-class/33389/3 "2024-07-30T13:05:57Z")

</div>

thanks for answer  
but i rearranged them the way you said but the same error occured

```auto
class PostCreateView(LoginRequiredMixin , View):
    form_class = PostCreateUpdateForm
    def get(request , self , *args , **kwargs):
        form = self.form_class
        
        return render(request , 'home/post_create.html' , {'form':form})

    def post(self , request , *args , **kwargs):
        form = self.form_class(request.POST)
        if form.is_valid():
            new_post = form.save(commit = False)
            new_post.slug = slugify(form.cleaned_data['body' ,][:30])
            new_post.user = request.user
            new_post.save()
            messages.success(request , 'new post created' , 'success')
            return redirect('home:page_detail' , new_post.id , new_post.slug)

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 30, 2024, 1:09pm UTC](https://forum.djangoproject.com/t/wsgirequest-object-has-no-attribute-form-class/33389/4 "2024-07-30T13:09:30Z")

</div>

> [@AliRamezani](#):
>
> ```auto
> def get(request , self , *args , **kwargs):
> form = self.form_class
> 
> ```

- This order of the parameters in the `get` definition is still not correct.
- The second line is getting a reference to the `form_class` class, and is not creating an instance of the form.

Notice the difference between your definition above, and this:

> [@AliRamezani](#):
>
> `form = self.form_class(request.POST)`

This reference is creating an instance of the `form_class` object.
