Hi! In my project, I'm doing a .save() but nothing is being saved and I cant figure out why... The code is:
[models.py] class LevelForm(forms.Form): level_Name=RegexField('^level\d[a-b]?$', required=True, max_length=20, initial='level', error_message='Blah') instrument_Name=ChoiceField(required=False, choices=[(i.instrument_name,i.instrument_name) for i in Instrument.objects.all()]) available=ChoiceField(required=False, choices=[('Y','Yes'), ('N','No')], initial='Y') table_Name=RegexField('^[a-zA-Z]+$', required=False, max_length=20, error_message='Blah') class Level(models.Model): level_name = models.CharField(primary_key=True, maxlength=20) instrument_name = models.CharField(primary_key=True, maxlength=20) available = models.TextField() tablename = models.CharField(blank=True, maxlength=20) def __str__(self): stringue='level_name - '+self.level_name+' instrument_name - '+self.instrument_name+' available - '+str(self.available)+' tablename - ' if self.tablename== None: stringue=stringue+str(self.tablename) else: stringue=stringue+self.tablename return stringue class Meta: db_table = 'Level' [views.py] level=Level() level.level_name=form.clean_data.get('level_Name') level.instrument_name=form.clean_data.get('instrument_Name') level.available=form.clean_data.get('available') level.tablename=form.clean_data.get('tabelname') level.save() #when I do this instruction to test if anything was inserted num=Level.objects.filter(Q(level_name__exact=level.level_name) & Q(instrument_name__exact=level.instrument_name)).count() #returns 0L lvl=Level.objects.filter(Q(level_name__exact=level.level_name) & Q(instrument_name__exact=level.instrument_name)) #returns [] (empty list) I have tested with the assert False thingy and everything that I insert in the forms is in the level variable: level <Level: level_name - level5 instrument_name - GOME available - Y tablename - fgdfg> So I don't understand why nothing happens... I can't insert a register into the database. I also can't figure out what is going wrong during the save since it returns nothing.. Has anyone got any clue why this is happening? I have done 2 other modules and they work fine, only this one I'm not being able to get working. Thanks! Ana --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---