create a forms.py file

add into the file

import from django.forms import ModelForm
from .models import *

#the asterisk means you are importing everything from the models

class name_of_form(models.ModelForm):
         class Meta:
               model = your_model
               fields='__all__'

or

   class name_of_form(models.ModelForm):
         class Meta:
               model = your_model
               fields=['field']


then in your templates you can render the form by

<form>
{{name_of_form}}
</form>


and you must add the form in the views.py file

from .forms import *

#this is where your you want your form to be i.e under the function or class

form=name_of_your_form()

context={'form':form,}

the render it together with your template





On Tue, May 16, 2023 at 9:54 PM Michael Starr <michaelstarr.cod...@gmail.com>
wrote:

> I am having difficulty rendering a form. Does anyone have a CONCISE
> tutorial for me?
>
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/045cd9f2-20c2-4ecd-b5fe-409604d249fdn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/045cd9f2-20c2-4ecd-b5fe-409604d249fdn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMJ3z%3D1ajFQ8mqHLqi6WjGEFFQwcx1rJ63NVz_vNCkDvUk8Nyw%40mail.gmail.com.

Reply via email to