Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide example (or support?) for using an EnumField directly in a form #64

Closed
johnthagen opened this issue Jul 30, 2016 · 3 comments
Closed

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Jul 30, 2016

Django provides Form fields that can be used directly in Form objects.

Does django-enumfields provide an EnumField that can be used directly in a form like:

from django import forms
import enumfields

class MyForm(forms.Form):
    my_enum = enumfields.  # ... ?

I can get it to work if I put an enumfields.EnumIntegerField into a Model and then use a ModelForm, but if I just want to create a Form without a Model I couldn't figure out how to do this.

I'm happy to submit a PR with an example if someone could teach me how to do this. :)

@akx
Copy link
Contributor

akx commented Jul 31, 2016

enumfields.EnumField(MyEnum).formfield() should work. :)

@johnthagen
Copy link
Contributor Author

@akx Thanks! If I submitted a PR with a small example on how to use enumfields directly in a Form, would you accept? I think this is something that could help others in the future.

@akx
Copy link
Contributor

akx commented Jul 31, 2016

Of course! There's no such thing as too much documentation!

(Provided the documentation is correct -- documentation-wise, can't think of a worse thing than docs that outright lie, but that usually happens due to rot, so not the point here. :-) )

@akx akx closed this as completed in 04484dd Aug 1, 2016
akx added a commit that referenced this issue Aug 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants