Django ModelForm has no model class specified

后端 未结 9 441
误落风尘
误落风尘 2021-02-02 08:36

I am trying to use ModelForm:

from django.db import models
from django.forms import ModelForm

class Car(models.Model):
    carnumber = models.CharField(max_leng         


        
相关标签:
9条回答
  • 2021-02-02 09:27

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

    0 讨论(0)
  • 2021-02-02 09:32

    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.

    0 讨论(0)
  • 2021-02-02 09:34

    some times writing

    'class Meta:' works and in some cases 'class meta:' works and i think it varies from different ide's.

    0 讨论(0)
提交回复
热议问题