any help? On 28 Mart, 15:00, H.İbrahim Yılmaz <prehisto...@gmail.com> wrote: > Hi, > I Have a model and ModelForm I want to learn how i can filter areas? > You can see my model below. > > from django.db import models > from yenicrm.musteri.models import * > from django.forms import ModelForm > from django.contrib.auth.models import User > class Ziyaret(models.Model): > tarih = models.DateField() > musteri = models.ForeignKey(Musteri) > temsilci = models.ForeignKey(User) > gorusler = models.TextField() > > class ZiyaretForm(ModelForm): > class Meta: > model = Ziyaret > exclude = ("temsilci",) > > I wan to filter my musteri area like musteri = > Musteri.objects.filter(temsilci = request.user) you can see my wiev.py > below. I can't do this. I am a newbie :) > > from django.shortcuts import render_to_response > from yenicrm.musteri.models import * > from yenicrm.ziyaret.models import * > from django.contrib.auth.decorators import login_required > from django.template import Context, RequestContext > from django.http import HttpResponse > > @login_required > def index(request): > ziyaretler = Ziyaret.objects.filter(temsilci = request.user) > return render_to_response('ziyaret.html', {'ziyaretler': ziyaretler}) > > @login_required > def ziyaret_ekle(request): > if request.POST: > zform = ZiyaretForm(request.POST) > if form.is_valid(): > yeni_ziyaret_objesi = form.save(commit = False) > yeni_ziyaret_objesi.temsilci = request.user > yeni_ziyaret_objesi.save() > return HttpResponse("Veritabanina kaydedildi. Yeni > ziyaretin id'si : %d" % yeni_ziyaret_objesi.pk) > else: > render_to_response('ziyaret_kaydet.html', {'zform': > zform}, context_instance=RequestContext(request)) > return render_to_response('ziyaret_kaydet.html', {'zform': > ZiyaretForm()}, context_instance=RequestContext(request)) > > Kind Regards. > --http://www.arkeoloji.web.tr
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.