Ja!! That is it...
Changed the view function name and it works...

Very nice... thank you to everybody.

Regards

On Oct 10, 2:27 am, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sat, Oct 10, 2009 at 2:04 AM, LuisC <lcapri...@gmail.com> wrote:
>
> > Hi!!!
> > I am having troubles saving my first model using a form:
>
> > My Model:
> > Class Clientes(models.Model):
> >    'Clase para Clientes'
> >    ClienteCodigo = models.IntegerField('Codigo Cliente')
> >    ClienteNombre = models.CharField('Nombre Cliente',max_length=40)
> >    ClienteFechaCreacion = models.DateField('Fecha Actualizacion')
>
> >    def __str__(self):
> >        return self.ClienteNombre
>
> > My Form:
>
> (What you have below isn't a form, it's a view function.)
>
>
>
> > def Clientes(request):
> >    if request.method == 'POST': # If the form has been submitted...
> >        form = ClientesForm(request.POST) # A form bound to the POST
> > data
> >        if form.is_valid(): # All validation rules pass
> >            # Process the data in form.cleaned_data
> >            ClienteCodigo = form.cleaned_data['ClienteCodigo']
> >            ClienteNombre = form.cleaned_data['ClienteNombre']
> >            ClienteFechaCreacion = form.cleaned_data
> > ['ClienteFechaCreacion']
> >            BDbuff = Clientes
> > (ClienteCodigo,ClienteNombre,ClienteFechaCreacion)
> >            BDbuff.save()
> >            return HttpResponseRedirect(reverse
> > ('mysite.ControlHoras.views.index')) # Redirect after POST
> >        else:
> >            return render_to_response('ControlHoras/Clientes.html',
> > {'form': form,}) # Invalid data
> >    else:
> >        form = ClientesForm() # An unbound form
> >        return render_to_response('ControlHoras/Clientes.html',
> > {'form': form,}) # Invalid data
>
> > The forms displays ok, but when submit it I get the following error...
> > Exception Value:  Clientes() takes exactly 1 argument (3 given)
>
> You gave your view function the same name as your model, effectively hiding
> your model.  The code is trying to call Clientes as you have redefined it,
> but the view only takes one argument (request).  You need to use a different
> name for your view function.
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to