The value of 'form' must inherit from 'BaseModelForm'

intelis

I am trying to add dynamic choice field to adimin form, but I get an error:

The value of 'form' must inherit from 'BaseModelForm'.

What am I doing wrong?

(part of admin.py)

class ReservationForm(forms.Form):

    class Meta:
        model = Reservation

    def __init__(self,*args, **kwargs):
        super(ReservationForm, self).__init__(*args, **kwargs)

        if not self.request.user.is_superuser:
            self.fields['status'] = forms.ChoiceField(STATUS_CHOICES = ( (PENDING,'Pending'),(APPROVED, 'Approved'), (CANCELED, 'Canceled') ))

# Reservation

class ReservationAdmin(admin.ModelAdmin):
    form = ReservationForm
Selcuk

Your ReservationForm does not extend BaseModelForm or any of its subclasses. Change it to:

class ReservationForm(forms.ModelForm):

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

“ form”的值必须继承自“ BaseModelForm”

来自分类Dev

“ form”的值必须继承自“ BaseModelForm”

来自分类Dev

Inherit from std::ostringstream

来自分类Dev

Cannot Inherit from final Snackbar

来自分类Dev

Player won't inherit from CardHolder in JavaScript

来自分类Dev

How to empty a numeric value from a form built with WTForm

来自分类Dev

Updating model data from form value ruby on rails

来自分类Dev

Any possible way to get the value from form1 to form2 before submitting form2

来自分类Dev

Should class Square publicly inherit from class Rectangle?

来自分类Dev

Why does a <h2> inside a <h1> not inherit the value of color property?

来自分类Dev

Capybara form value set with cocoon

来自分类Dev

switch over value of enum: case expressions must be constant expressions

来自分类Dev

Yii2 SluggableBehavior "attribute" or "value" property must be specified error

来自分类Dev

Change/clear form value on validation error

来自分类Dev

Use jQuery to set value of hidden field in a form and submit the value

来自分类Dev

Return value from BroadcastReceiver

来自分类Dev

Passing a Image from a html form to Go

来自分类Dev

Windows Form: Play sound, but not from beginning

来自分类Dev

在使用 angular 6 实现条纹时,我收到错误错误:mat-form-field must contain a MatFormFieldControl

来自分类Dev

openpyxl 无法追加列表数据类型,一直显示 TypeError: Value must be a list

来自分类Dev

Request.Form has no value when previous page is a secure page?

来自分类Dev

.value和.setValue在Form Angle 7+中的区别

来自分类Dev

Angular 2 form.value属性未定义

来自分类Dev

Remove value from array if value is a substring of another value

来自分类Dev

Take (value from this week) - (value from the last week) PowerPivot Dax

来自分类Dev

Append frequency value from data

来自分类Dev

Ajax get value from php

来自分类Dev

Search Value from range of an array

来自分类Dev

import React, {PropTypes} from 'react' 导致 Uncaught TypeError: Super expression must be null or a function, not undefined

Related 相关文章

  1. 1

    “ form”的值必须继承自“ BaseModelForm”

  2. 2

    “ form”的值必须继承自“ BaseModelForm”

  3. 3

    Inherit from std::ostringstream

  4. 4

    Cannot Inherit from final Snackbar

  5. 5

    Player won't inherit from CardHolder in JavaScript

  6. 6

    How to empty a numeric value from a form built with WTForm

  7. 7

    Updating model data from form value ruby on rails

  8. 8

    Any possible way to get the value from form1 to form2 before submitting form2

  9. 9

    Should class Square publicly inherit from class Rectangle?

  10. 10

    Why does a <h2> inside a <h1> not inherit the value of color property?

  11. 11

    Capybara form value set with cocoon

  12. 12

    switch over value of enum: case expressions must be constant expressions

  13. 13

    Yii2 SluggableBehavior "attribute" or "value" property must be specified error

  14. 14

    Change/clear form value on validation error

  15. 15

    Use jQuery to set value of hidden field in a form and submit the value

  16. 16

    Return value from BroadcastReceiver

  17. 17

    Passing a Image from a html form to Go

  18. 18

    Windows Form: Play sound, but not from beginning

  19. 19

    在使用 angular 6 实现条纹时,我收到错误错误:mat-form-field must contain a MatFormFieldControl

  20. 20

    openpyxl 无法追加列表数据类型,一直显示 TypeError: Value must be a list

  21. 21

    Request.Form has no value when previous page is a secure page?

  22. 22

    .value和.setValue在Form Angle 7+中的区别

  23. 23

    Angular 2 form.value属性未定义

  24. 24

    Remove value from array if value is a substring of another value

  25. 25

    Take (value from this week) - (value from the last week) PowerPivot Dax

  26. 26

    Append frequency value from data

  27. 27

    Ajax get value from php

  28. 28

    Search Value from range of an array

  29. 29

    import React, {PropTypes} from 'react' 导致 Uncaught TypeError: Super expression must be null or a function, not undefined

热门标签

归档