First, you need a model to store the data in the database.
Then, you can use a CreateView as explained at [1].
You should have something like that at the end.
models.py:
from django.db import models
class User(models.Model):
name = models.CharField(max_length=128)
newsletter = models.BooleanField()
views.py:
from django.views.generic.edit import CreateView
from .models import User
class UserCreate(CreateView):
model = User
fields = ['name', 'newsletter']
urls.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^user/create/$', views.UserCreate.as_view(), name="user_create"),
]
If you have more question, like how all that fit together, I suggest
strongly to do at least one django tutorial. There are several of high
quality. If the official one is too rough for you, django girls [2]
offer an alternative for beginner.
[1] https://docs.djangoproject.com/en/1.9/topics/class-based-views/generic-editing/#model-forms
[2] http://tutorial.djangogirls.org/
2016-07-10 18:05 GMT+02:00 Aida <aidahaliti@gmail.com>:
> Hello,
>
> I want to create a form to apply in, this form will contain fields for
> name, surname, e-mail, text area and also i want it to contain checkbox-es.
> Data that will be inserted in those areas to be saved in db. How can i come
> up with this?
>
> --
> 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+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/36850358-c3f6-4acf-b50b-25a4602baca2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
Cordialement, Coues Ludovic
+336 148 743 42
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTbB8wh_cgOjo55iC6QL4A4Vf0AdLHZ1NngX%2Buuxsz%3DiOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment