Skip to content

ListField fails to display in form if "null=True" set in model. #41

Open
@OneOfMany07

Description

@OneOfMany07

I've been having a ton of trouble getting a ListField to work, even after following the very useful example at https://gist.github.com/jonashaag/1200165

I finally traced it down to adding "null=True" to my list of attributes in the models.py file. If I remove that entry I can see the form fine, but if I add it back in the "form.as_p" call returns nothing in the template.

Looking in the debugger the form object looks different too. The text representation is the python default object ID when the form is broken. When it would display I see the HTML code that would get output for the items in my form.

Now I'm not sure this will show up in the example above, but the code change I'd make would be...

categories = CategoryField()

becomes...

categories = CategoryField(null=True)

I had added that to work around existing documents that didn't have my new ListField value. I assumed the model verification would fail somewhere if there were existing documents without a value in a field that can't be null or blank.

My app is really long and I'm hoping this is enough to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions