Hi again, Thanks for the suggestion, but this still isn't working... the difference between this module and the others that I have already made is that (besides the fact that the others actually work) this one involves a table with two primary keys. If it had just one I bet there would be no problem. I don't know why this doesn't save the object. All the inserted data is saved in the Level object correctly as you can see from the output of the error page (because of the assert False I put in the code): level <Level: level_name - level5 instrument_name - GOME available - Y tablename - fgdfg>
The model file 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' I really don't know how to make this work and I need to make this work :( Ana On Jul 3, 7:55 pm, RajeshD <[EMAIL PROTECTED]> wrote: > Hi Ana, > > > > > [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 > > Try that without the Q object like this: > > num=Level.objects.filter(level_name__exact=level.level_name, > instrument_name__exact=level.instrument_name).count() > > -Rajesh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---