Hi Aptem,

Your questions is not clearly what exactly do you want, where are you 
stuck, specifically,
Check this it might assist you 
https://docs.djangoproject.com/en/1.7/topics/forms/

this is a very basic example if you have an organization mode below

models.py

> class Organization(models.Model):
>
name = models.CharField(max_length=25) 

create a forms module and add this
form.py
class NameForm(form.Form):
name = forms.CharField(max_length=25)
 

>  view.py

import the model and form to you view

> def organization_save(request):
>     # if this is a POST request we need to process the form data
>     if request.method == 'POST':
>         # create a form instance and populate it with data from the request:
>         form = NameForm(request.POST)
>         # check whether it's valid:
>         if form.is_valid():
>             # process the data in form.cleaned_data as required
>
> cleaned_name = form.cleaned_data['name'] 

>             # save form if its new organization creation
>
>  organization = Organization.objects.create(name=cleaned_name)
        # if its an existing organizanization
organization = Organization.objects.get(id='the id of the organization')
organization .name = cleaned_name
organization .save()

>             # redirect to a new URL:
>             return HttpResponseRedirect('/thanks/')
>
>     # if a GET (or any other method) we'll create a blank form
>     else:
>         form = NameForm()
>
>     return render(request, 'name.html', {'form': form})
>
>

there is an easier way of doing this by use of modelforms check this out  
https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/

Hope it assists you.

Regards,
Eddilbert Macharia.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/29ee3516-d1a2-4840-85e7-018c1c7d8c1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to