EL problea no es el status si no que no peudo guardar el dato de un select aqui dejo mi codifgo
class Sangre(models.Model):
tipo = models.CharField(max_length=20)
def __unicode__(self):
return self.tipo
class paciente(models.Model):
nombre = models.CharField(max_length=50)
fechaNac = models.DateField(auto_now=False, blank=False,)
fechaCons = models.DateField(auto_now=False, blank=False)
telefonocasa = models.CharField(null=True, max_length=10)
direccion = models.CharField(max_length=100)
email = models.EmailField(null=True)
ocupacion = models.CharField(null=False, max_length=10)
sangre = models.ForeignKey(Sangre)
nombreEsposo = models.CharField(max_length=50)
telAviso = models.CharField(max_length=10)
telcasa = models.CharField(null=True, max_length=10)
movil_id = models.CharField(null=True, max_length=10)
rfc = models.CharField(null=True, max_length=20)
nomFiscal = models.CharField(null=True, max_length=50)
dirFiscal = models.CharField(null=True, max_length=50)
concepto = models.CharField(null=True, max_length=10)
importe = models.DecimalField(max_digits=10, decimal_places=2)
status = models.BooleanField(default=True)
def __unicode__(self):
return self.nombre
from django.forms import ModelForm, IntegerField
from ginecologia.apps.paciente.models import paciente
class AltaPacienteFrom(forms.ModelForm):
sangre = forms.IntegerField(label='Sangre')
class Meta:
model = paciente
fields = ['sangre']
exclude = {'status',}
def alta_paciente_view(request):
if request.user.is_authenticated():
info = " "
if request.method == "POST":
formulario = AltaPacienteFrom(request.POST)
if formulario.is_valid():
add = formulario.save()# que mantenga en stand by el formulario
add.status = True
add.save() # guardamos la info
formulario.save_pk()
info = "guardado satisfactoriamente"
else:
info = "datos incorrectos"
else:
formulario = AltaPacienteFrom()
tipoSangre = Sangre.objects.all()
mensaje = "Alta Paciente."
ctx = {'form' : formulario,'msj' : mensaje, 'info':info, 'sangre':tipoSangre}
return render_to_response('ginecologo/altanuevopaciente.html', ctx, context_instance=RequestContext(request))