Hi all,
Thanks it works! But, i have another question about my view. When i
use my view (as seen below) i can't get see the form.
Thanks!
@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))
02 Nisan 2010 19:03 tarihinde H.İbrahim Yılmaz <[email protected]> yazdı:
> Hi all,
> Thanks it works! But, i have another question about my view. When i
> use my view (as seen below) i can't get see the form.
> Thanks!
>
> 2010/4/2 Benjamin Welton <[email protected]>:
>> def __init__(temsilci = None, *args, **kwargs)
>>
>> should include self as the first argument.
>>
>> def __init__(self, temsilci = None, *args, **kwargs)
>>
>> Ben
>>
>>
>> H.İbrahim Yılmaz wrote:
>>>
>>> Hi all,
>>> I get "global name 'self' is not defined" error what is the problem?
>>> Thanks.
>>>
>>> from django.db import models
>>> from django.forms import *
>>> from yenicrm.musteri.models import *
>>> from django.contrib.auth.models import User
>>> from django.forms.extras.widgets import *
>>>
>>> # Create your models here.
>>> class Ziyaret(models.Model):
>>> tarih = models.DateField()
>>> temsilci = models.ForeignKey(User)
>>> musteri = models.ForeignKey(Musteri)
>>> gorusler = models.TextField()
>>>
>>> class ZiyaretForm(ModelForm):
>>> tarih = DateField(widget=SelectDateWidget())
>>> musteri = ModelChoiceField(queryset = Musteri.objects.none())
>>>
>>> def __init__(temsilci = None, *args, **kwargs):
>>> super(ZiyaretForm, self).__init__(*args, **kwargs)
>>> self.fields["musteri"] = Musteri.objects.none() if temsilci is
>>> None else Musteri.objects.filter(temsilci = temsilci)
>>>
>>> class Meta:
>>> model = Ziyaret
>>> exclude = ("temsilci",)
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to [email protected].
>> 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.
>>
>>
>
>
>
> --
> http://www.arkeoloji.web.tr
>
--
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 [email protected].
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.