[Django]-Django ModelForm has no model class specified

71👍

It should be model instead of Model:

class PickForm(ModelForm):
    class Meta:
        model = Car

12👍

my error was because I wrote meta instead of Meta.

9👍

Just do this method your page will run:

class PickForm(ModelForm):
  class Meta:
    model = Car
    fields = "__all__"

5👍

In my case, the error occurs because I wrote
class META
instead, it should be
class Meta

3👍

In my case the error was due to me wirting :

models = User

instead of :

model = User

1👍

class PickForm(ModelForm):
    class Meta:
        Model = Car`

Here the Model is case sensitive, so use model instead of Model.

so the code becomes

class PickForm(ModelForm):
    class Meta:
        model = Car

0👍

If this is a copy and past, you have a typo. I would highly recommend you use an IDE or something with error checking. Eclipse is what I use. It will save you a ton of time from little annoyances like this.

class PickForm(ModelForm):
    class Meta:
        Model = Car`

Your typo is right on the end of Car. The little apostrophe thing.

0👍

see your code in your defined form code area.there may be error either with =,: and meta,Meta .so please look carefully if case sensitive error or any signs over there

0👍

I got this error just by writing model: Comment instead of model = Comment 🤦‍♂️

-1👍

You missed the basic step of registering your model to the admin. Please do that and that should work for you.

In the admin.py file of your app add these lines:

from yourapp.models import yourmodel
admin.site.register(yourmodel)

Here yourapp and yourmodel needs to be replaced with the correct names for your app and model.

Leave a comment