Hi

I'm trying to make a simple crud applicatio and learn from it. I wonder why 
my form can't save the data. Here cames my view:

from django.shortcuts import render
from saeed.forms import SmodelForm  
from saeed.models import Smodel
from django.shortcuts import render, redirect  



# Create your views here.
def emp(request):  
    if request.method == "POST":  
        form = SmodelForm(request.POST)  
        if form.is_valid():  
            try:  
                form.save()  
                return redirect('/show')  
            except  AssertionError as error:
                
                print(error)
                pass

     
                

                
    else:  
        form = SmodelForm()  
    return render(request,'saeed/index.html',{'form':form})  
#----------------------------------------
def show(request):  
    smodels = Smodel.objects.all()  
    return render(request,'saeed/show.html',{'smodels':smodels}) 
#----------------------------------------

def edit(request, id):  
    smodels = Smodel.objects.get(id=id)  
    return render(request,'saeed/edit.html', {'smodels':smodels})  
#-------------------------------------------

def update(request, id):  
    smodels = Smodel.objects.get(id=id)  
    form = SmodelForm(request.POST, instance = smodels)  
    if form.is_valid():  
        form.save()  
        return redirect("/show")  
    return render(request,'saeed/edit.html',{'smodels':smodels})  

#---------------------------------------------
def destroy(request, id):  
    smodels = Smodel.objects.get(id=id)  
    smodels.delete()  
    return redirect("/show")  


and here cames the complete app:


https://ln.sync.com/dl/1bf7658d0/pw69mf37-yk85kjaa-qprd4xdx-m8em4rxk

can you please inform me where is wrong?

thanks

thanks

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/83aa34e2-2da1-432d-94ba-ec0beea90608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to