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

Should class Square publicly inherit from class Rectangle?

来自分类Dev

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

来自分类Dev

Append frequency value from data

来自分类Dev

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

来自分类Dev

Inherit from std::ostringstream

来自分类Dev

Updating model data from form value ruby on rails

来自分类Dev

Search Value from range of an array

来自分类Dev

Player won't inherit from CardHolder in JavaScript

来自分类Dev

Change/clear form value on validation error

来自分类Dev

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

来自分类Dev

Passing a Image from a html form to Go

来自分类Dev

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

来自分类Dev

Windows Form: Play sound, but not from beginning

来自分类Dev

Capybara form value set with cocoon

来自分类Dev

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

来自分类Dev

Return value from BroadcastReceiver

来自分类Dev

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

来自分类Dev

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

来自分类Dev

Cannot Inherit from final Snackbar

来自分类Dev

Ajax get value from php

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

来自分类Dev

Angular 2 form.value属性未定义

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

Related 相关文章

  1. 1

    Should class Square publicly inherit from class Rectangle?

  2. 2

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

  3. 3

    Append frequency value from data

  4. 4

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

  5. 5

    Inherit from std::ostringstream

  6. 6

    Updating model data from form value ruby on rails

  7. 7

    Search Value from range of an array

  8. 8

    Player won't inherit from CardHolder in JavaScript

  9. 9

    Change/clear form value on validation error

  10. 10

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

  11. 11

    Passing a Image from a html form to Go

  12. 12

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

  13. 13

    Windows Form: Play sound, but not from beginning

  14. 14

    Capybara form value set with cocoon

  15. 15

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

  16. 16

    Return value from BroadcastReceiver

  17. 17

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

  18. 18

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

  19. 19

    Cannot Inherit from final Snackbar

  20. 20

    Ajax get value from php

  21. 21

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

  22. 22

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

  23. 23

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

  24. 24

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

  25. 25

    Angular 2 form.value属性未定义

  26. 26

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

  27. 27

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

  28. 28

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

  29. 29

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

热门标签

归档