It looks like maybe a slight change to your models and schema would make 
this a bit cleaner if I'm understanding your overall schema correctly.  I 
would split this up into two different models with a ManyToMany 
relationship in there.  I am assuming you have students and then an Egitim 
instance is one instance of a student taking one class, correct?

class Student(models.Model):
    first_name = models.CharField(max_length=200)
    surname =  models.CharField(max_length=20)
    email = models.EmailField(max_length=75)
    courses = models.ManyToManyFIeld('Course', blank=True)

class Course(models.Model):
    course_name =  models.CharField(max_length=300)

Then if you need the count you can do one of these:
student = Student.objects.get(email=email_address)
student.courses.all().count()

Course.objects.filter(student__email=email_address).count()


On Sunday, July 28, 2013 8:06:28 AM UTC-4, Murat Bilal wrote:
>
> Hi all,
> I have a model like this
> class Egitim(models.Model):
>     name = models.CharField(max_length=200)
>     surname =  models.CharField(max_length=20)
>     email = models.EmailField(max_length=75)
>     course_name =  models.CharField(max_length=300)
>     num_of_courses_taken = models.IntegerField(max_length=100)
>     def __unicode__(self):
>       return self.course_name
>  
> class EgitimForm(ModelForm):
>     class Meta:
>       model=Egitim
>       fields=('name','surname','email','course_name')
> I want to increment num_of_courses_taken value according to email 
> addresses.For example if there are 3 aa@example .com mail is submitted in 
> ModelForm.it means the user aa have taken 3 courses.
>  
> Please Help
>

-- 
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to