a problem about the custom login form with a verify code filed.

2011-06-26 Thread Korobase
I want to add a verify code field in the login form.
So, I write a authentication_form which added a charField to generate a
verify code and the verify code saved to the request.session.
But When I send login form request,I find in my authentication_form, I can't
campare the session's verify code and the clean_data["verifycode"],
Because the request in Null when invoke my authentication_form.

code below and the question in line highlighted like *###HERE*

class MyAuthenticationForm(AuthenticationForm):

verifyimg=forms.CharField(label="verifycode",widget=vericonf.CaptchaWidget)


def __init__(self, request=None,*args, **kwargs):
self.request=request
kwargs_new = {'error_class': DivErrorList}
kwargs.update(kwargs_new)
#elf.error_class = DivErrorList
super(MyAuthenticationForm,self).__init__(*args, **kwargs)


def as_div(self):
"Returns this form rendered as HTML div."
return self._html_output(
normal_row = u'%(label)s%(field)s%(help_text)s%(errors)s',
error_row = u'%s',
row_ender = u'',
help_text_html = u'%s',
errors_on_separate_row = False)

def clean_verifyimg(self):
pass

def clean(self):
vericode=""
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')

if self.request and self.request.session and
self.request.session.get("verifyimg"):
vericode = self.request.session.get("verifyimg")

print vericode  *###HERE request.session is Null then I can't
compare vericode and verify now.How to do it?*

verify=self.cleaned_data.get('verifyimg')
print verify

if username and password:
self.user_cache = authenticate(username=username, password=password)
if self.user_cache is None:
raise forms.ValidationError(_("Please enter a correct
username and password. Note that both fields are case-sensitive."))
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
if verify and vericode:
if verify != vericode:
raise forms.ValidationError("verify code is wrong.pls
Try again!")

self.check_for_test_cookie()

return self.cleaned_data



-- 
"OpenBookProject"-开放图书计划邮件列表
详情: http://groups.google.com/group/OpenBookProject
维基: http://wiki.woodpecker.org.cn/

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



a problem about the custom login form with a verify code filed.

2011-06-26 Thread Korobase
I want to add a verify code field in the login form.
So, I write a authentication_form which added a charField to generate a
verify code and the verify code saved to the request.session.
But When I send login form request,I find in my authentication_form, I can't
campare the session's verify code and the clean_data["verifycode"],
Because the request in Null when invoke my authentication_form.

code below and the question in line highlighted like *###HERE*

class MyAuthenticationForm(AuthenticationForm):

verifyimg=forms.CharField(label="verifycode",widget=vericonf.CaptchaWidget)


def __init__(self, request=None,*args, **kwargs):
self.request=request
kwargs_new = {'error_class': DivErrorList}
kwargs.update(kwargs_new)
#elf.error_class = DivErrorList
super(MyAuthenticationForm,self).__init__(*args, **kwargs)


def as_div(self):
"Returns this form rendered as HTML div."
return self._html_output(
normal_row = u'%(label)s%(field)s%(help_text)s%(errors)s',
error_row = u'%s',
row_ender = u'',
help_text_html = u'%s',
errors_on_separate_row = False)

def clean_verifyimg(self):
pass

def clean(self):
vericode=""
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')

if self.request and self.request.session and
self.request.session.get("verifyimg"):
vericode = self.request.session.get("verifyimg")

print vericode  *###HERE request.session is Null then I can't
compare vericode and verify now.How to do it?*

verify=self.cleaned_data.get('verifyimg')
print verify

if username and password:
self.user_cache = authenticate(username=username, password=password)
if self.user_cache is None:
raise forms.ValidationError(_("Please enter a correct
username and password. Note that both fields are case-sensitive."))
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
if verify and vericode:
if verify != vericode:
raise forms.ValidationError("verify code is wrong.pls
Try again!")

self.check_for_test_cookie()

return self.cleaned_data



-- 
"OpenBookProject"-开放图书计划邮件列表
详情: http://groups.google.com/group/OpenBookProject
维基: http://wiki.woodpecker.org.cn/

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django template extends and include problem.

2011-06-12 Thread Korobase
test case as below:

1.base.html


{% block t1 %}
t
{% endblock %}



2.temp.html
{% block t2 %}
zzz
{% endblock %}

3.index.html
{% extends "base.html" %}
{% block t1 %}
kk
{% include "temp.html" %}
{% endblock %}

4.other.html
{% extends "index.html" %}
{% block t2 %}
qq
{% endblock %}


then,in the other.html,why I can't change the block t2?
how to implement this extends and modify its included block?

Thanks.


--

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [help]django's FloatField can't insert the mysql's double type data.

2011-05-20 Thread Korobase
OK,Thank you for your reply.

I have resolved this problem, That a fileld name in my models.py is "save"
resulting this problem.

But I don't know why. the "save" can't be used as the filed name? because
it's not within Python keywords and just be a method name in django.

I 'll keep it in mind.

Thanks to all.

2011/5/20 Karen Tracey 

> The error is occurring on the same line of code as it was before, only now
> it's reporting that a decimal isn't callable where before it was saying that
> a float isn't callable. So whatever was causing that problem is still
> afflicting the project, changing float to decimal didn't fix that. I don't
> know what it is because I don't recall anyone reporting this kind of error
> before and all you've posted of your code is your model and model admin
> definitions. If you take just those definitions and cut-and-paste them into
> a new project, they work fine. So I suspect there is something beyond what
> you have posted that is causing this.
>
> I'd start with what I just said: take that code you posted and verify that
> if you cut-and-paste it into a new test project, it works. Then start adding
> bits from the project you have that shows the weird error and see when it
> breaks. If it isn't immediately obvious then why that newly-added bit causes
> the error, if you post the code in question here someone will likely be able
> to help with the why of it.
>
>
> Karen
> --
> http://tracey.org/kmt/
>
>  --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
"OpenBookProject"-开放图书计划邮件列表
详情: http://groups.google.com/group/OpenBookProject
维基: http://wiki.woodpecker.org.cn/

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [help]django's FloatField can't insert the mysql's double type data.

2011-05-19 Thread Korobase
I change the floatField to DecimalField and the error also out show:
And from django debug information I can't location which field resulting
this error!!

TypeError at /admin/main/myitem/add/


'Decimal' object is not callable

 Request Method:POST Request URL:
http://localhost:8000/admin/main/myitem/add/ Django Version:1.3 Exception
Type:TypeError Exception Value:


'Decimal' object is not callable

 Exception 
Location:C:\Python26\lib\site-packages\django\contrib\admin\options.py
in save_model, line 665 Python Executable:C:\Python26\python.exe Python
Version:2.6.6 Python Path:


['D:\\eclipse\\carveout\\d1d2d3\\src\\d1d2d3',
 'C:\\Python26\\lib\\site-packages\\markdown-2.0.3-py2.6-win32.egg',
 'C:\\Python26\\lib\\site-packages\\html5lib-0.90-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\cheetah-2.4.4-py2.6-win32.egg',
 'C:\\Python26\\lib\\site-packages\\tenjin-1.0.2-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\tornado-1.2.1-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\transifex-1.0.0-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\python_magic-0.4.0-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\pygooglechart-0.3.0-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\django_addons-0.6.4-py2.6.egg',
 'C:\\Python26\\lib\\site-packages\\feedparser-5.0.1-py2.6.egg',
 'C:\\WINDOWS\\system32\\python26.zip',
 'C:\\Python26\\DLLs',
 'C:\\Python26\\lib',
 'C:\\Python26\\lib\\plat-win',
 'C:\\Python26\\lib\\lib-tk',
 'C:\\Python26',
 'C:\\Python26\\lib\\site-packages',
 'C:\\Python26\\lib\\site-packages\\PIL']

 Server time:Fri, 20 May 2011 00:32:12 +0800
2011/5/15 Karen Tracey <kmtra...@gmail.com>

> On Sat, May 14, 2011 at 9:10 PM, Korobase <boyee...@gmail.com> wrote:
>
>>
>>
>> 2011/5/15 Andy McKay <a...@clearwind.ca>
>>
>>>
>>> > Exception Type: TypeError at /admin/main/learndjango/add/
>>> > Exception Value: 'float' object is not callable
>>>
>>>
>>> Please paste your model that is having the problem.
>>>
>>
>> class MyItem(models.Model):
>> title=models.CharField(max_length=1024)
>> description=models.CharField(max_length=1024)
>> price=models.FloatField(default=0.0)
>> time=models.DateTimeField()
>> name=models.CharField(max_length=256)
>> detail=models.CharField(max_length=1024)
>> address_city=models.CharField(max_length=36)
>> address_area=models.CharField(max_length=36)
>>
>>
>> def __unicode__(self):
>> return self.title
>>
>> and the ModelAdmin:
>>
>> class MyItemAdmin(admin.ModelAdmin):
>> list_display=('name','title','price','address_city',)
>>
>> admin.site.register(MyItem, MyItemAdmin)
>>
>>
>>
> The traceback indicates that the new object being added is not an instance
> of MyItem, but rather a simple float. How that has happened is a mystery; it
> is not due to anything you have posted so far. If you cut-and-paste just the
> model and model admin definitions you show here into a new 1.3 project, the
> admin works fine to add items. There is something more to your code that you
> have not shown yet that is causing the problem. Really, Django can insert
> float data into a MySQL table (although as Andy notes, using a float field
> for something named "price" is likely really really really not what you want
> to be doing.
>
> Karen
> --
> http://tracey.org/kmt/
>
>  --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



--

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [help]django's FloatField can't insert the mysql's double type data.

2011-05-14 Thread Korobase
2011/5/15 Andy McKay 

>
> > Exception Type: TypeError at /admin/main/learndjango/add/
> > Exception Value: 'float' object is not callable
>
>
> Please paste your model that is having the problem.
>

class MyItem(models.Model):
title=models.CharField(max_length=1024)
description=models.CharField(max_length=1024)
price=models.FloatField(default=0.0)
time=models.DateTimeField()
name=models.CharField(max_length=256)
detail=models.CharField(max_length=1024)
address_city=models.CharField(max_length=36)
address_area=models.CharField(max_length=36)


def __unicode__(self):
return self.title

and the ModelAdmin:

class MyItemAdmin(admin.ModelAdmin):
list_display=('name','title','price','address_city',)

admin.site.register(MyItem, MyItemAdmin)

Thanks.


> --
>  Andy McKay
>  a...@clearwind.ca
>  twitter: @andymckay
>
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


--

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[help]django's FloatField can't insert the mysql's double type data.

2011-05-14 Thread Korobase
Hi,all!
I use the django admin interface to insert a record to the mysql database,
While the field is FloatField in django and the mysql field show a double
type,
But when I click the save button,it tell me that:

Environment:


Request Method: POST
Request URL: http://localhost:8080/admin/main/learndjango/add/

Django Version: 1.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'tuang.main',
 'django.contrib.admin',
 'django.contrib.admindocs']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'learndjango.middleware.GetUserLoactionMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  111. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in
wrapper
  307. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in
_wrapped_view
  93. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py" in
_wrapped_view_func
  79. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in inner
  197. return view(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in _wrapper
  28. return bound_func(*args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in
_wrapped_view
  93. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in
bound_func
  24. return func(self, *args2, **kwargs2)
File "C:\Python26\lib\site-packages\django\db\transaction.py" in inner
  217. res = func(*args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in
add_view
  882. self.save_model(request, new_object, form,
change=False)
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in
save_model
  665. obj.save()

Exception Type: TypeError at /admin/main/learndjango/add/
Exception Value: 'float' object is not callable

Any reply is appreciated.Thanks.


--

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Korobase
Does django 1.3 has a ubuntu deb package released !
I have googled but get none,Any one have done this?
Thanks.

--

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.