Using the model below, I am trying to extend User. And with the related
view I am trying to reach the method of AnkediDolduran model.
authonticate() gives me a User instance, right? How can I reach the method
of the model AnketiDolduran using this instance of User?

Thanks in advance.


class AnketiDolduran(models.Model):
    '''Anketi dolduran kişilere ait bilgileri saklar.'''
    UNVANLAR = (
        ('AR', 'Araştırma Görevlisi'),
        ('OK', 'Okutman'),
        ('OG', 'Öğretim Görevlisi'),
        ('YR', 'Yardımcı Doçent Doktor'),
        ('DO', 'Doçent Doktor'),
        ('PR', 'Profesör Doktor'),
    )
    title = models.CharField('ünvan', max_length=2,
                                      choices=UNVANLAR,
                                      default='Yardımcı Doçent Doktor',
                                      help_text = 'Lütfen ünvanınızı
giriniz')
    university = models.CharField('üniversite', max_length = 100, help_text
= 'Görev yaptığınız üniversiteyi belirtiniz')
    department = models.CharField('bölüm', max_length = 100, help_text =
'Görev yaptığınız bölümü belirtiniz')
    # Using this I am extending user model, I guess. Am I right?
    user = models.OneToOneField(User)

    def __unicode__(self):
        return u'%s %s' % (self.user.first_name, self.user.last_name)

    def arastirma_gorevlisi_mi(self):
        '''Anketi dolduran kişi araştırma görevlisiyse TRUE döndürüyor.'''
        return self.title in ('AR', )

    def ogretim_uyesi_mi(self):
        '''Anketi dolduran araştırma görevlisinden başka bir şeyse TRUE
döndürüyor.'''
        return self.title in ('OK', 'OG', 'YR', 'DO', 'PR')


def giris(request):
    context_instance = RequestContext(request)
    if request.method == 'POST':
        username = request.POST['user']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                login(request, user)
                #how can I reach this object through user?
                if user.anketidolduran_set.arastirma_goverlisi_mi():
                    print 'arastirma_gorevlisi_mi()'
                    return redirect('anketler/bke_olcegi')
                if anketidolduran.ogretim_uyesi_mi():
                    print 'ogretim_uyesi_mi()'
                    return redirect('anketler/performans_degerlendirme')
            else:
                pass

    else:
        return render_to_response('registration/login.html',
context_instance=context_instance)


*Mehmet Gültaş | Research Assistant | Department of Psychology | Middle
East Technical University *

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABYYfXNB2Ffz4anqRtVrFoV6u5mv%2B0Q0PJWxYTfjpK%2BA9877Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to