# syntax django forms

**URL:** <https://forum.djangoproject.com/t/syntax-django-forms/34211>\
**Category:** Forms & APIs\
**Created:** [August 27, 2024, 12:29am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211 "2024-08-27T00:29:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![frank6282](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/frank6282/32/23491_2.png) [@frank6282](https://forum.djangoproject.com/u/frank6282)\
**Post date:** [August 27, 2024, 12:29am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211/1 "2024-08-27T00:29:55Z")

</div>

I have a table of butterfly names. I want to have a custom form in django forms to create a select statement with the butterfly name as a select option. I copied this from the django documentation

#### `Select` [¶](https://docs.djangoproject.com/en/5.1/ref/forms/widgets/#select)

_class_ `Select` [[source]]

- `template_name`: `'django/forms/widgets/select.html'`
- `option_template_name`: `'django/forms/widgets/select_option.html'`
- Renders as: `<select><option ...>...</select>`

I have to admit I don’t have a clue what this is telling me. Any help would be appreciated. Thank

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 27, 2024, 12:35am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211/2 "2024-08-27T00:35:09Z")

</div>

Welcome @frank6282 !

Part of the answer to your question depends upon what you’re going to do with that selection when submitted.

Specifically, is this selection being used to set a ForeignKey value of a different model? If so, the answer is going to be different than if you’re using this selection for a different purpose.

As a side note, how familiar are you with Django? Is this part of your first project, or have you worked with other projects?

---

<div class="post-metadata">

**Author:** ![frank6282](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/frank6282/32/23491_2.png) [@frank6282](https://forum.djangoproject.com/u/frank6282)\
**Post date:** [August 27, 2024, 12:53am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211/3 "2024-08-27T00:53:14Z")

</div>

First. I am learning django following various tutorials on the web. I have crated a website that actually works. What I want to do is take the users choice of butterfly name and apply it to a creation form. Thank for the quick reponse. Sorry I forgot to mention this is not a foreign key

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 27, 2024, 1:13am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211/4 "2024-08-27T01:13:17Z")

</div>

> [@frank6282](#):
>
> Sorry I forgot to mention this is not a foreign key

Then the simplest method is to use a [`ChoiceField`](https://docs.djangoproject.com/en/5.1/ref/forms/fields/#choicefield) in the form, where the `choices` attribute is a reference to a callable that retrieves the butterfly names.  
(Also see the related docs in [the `choices` attribute](https://docs.djangoproject.com/en/5.1/ref/models/fields/#choices) for models.)

---

<div class="post-metadata">

**Author:** ![frank6282](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/frank6282/32/23491_2.png) [@frank6282](https://forum.djangoproject.com/u/frank6282)\
**Post date:** [August 27, 2024, 1:27am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211/5 "2024-08-27T01:27:21Z")

</div>

thanks ken. I was wondering if ChoiceField would be the best for me because the list is 158 name. I will do the CoiceField though if that is what I should do. What are your thoughts on this?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 27, 2024, 1:39am UTC](https://forum.djangoproject.com/t/syntax-django-forms/34211/6 "2024-08-27T01:39:50Z")

</div>

> [@frank6282](#):
>
> I was wondering if ChoiceField would be the best for me because the list is 158 name.

If you’re looking for something like a filtered select list, you could take a look at [django-select2](https://django-select2.readthedocs.io/en/latest/).
