Re: Tip:decorator and urls.py

2007-08-21 Thread !( 08)
I think do like below maybe more simple

from django.shortcuts import render_to_response
from django.template.context import RequestContext

def template_name(func):
def _template_name(request,template_name,*args,**keys):

result=func(request,*args,**keys)

if type(result)!=dict:
return result

return render_to_response(
template_name,
result,
context_instance=RequestContext(request, result)
)

return _template_name

__
use like this
@template_name
def video(request,id):
return  {
'video':Video.objects.get(id=id)
}


2006/12/29, limodou <[EMAIL PROTECTED]>:
>
> > -8<--
> > @template('template.html')
> > def list(request):
> > if success:
> > #return HttpResponseRedirect('url')
> > raise HttpRedirectException
> > else:
> > return errorinfo
> > ->8--
>
> I'm sorry, here has a bug, the
>
> raise HttpRedirectException
>
> should be:
>
> raise HttpRedirectException 'url'
>
> --
> I like python!
> UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
> My Blog: http://www.donews.net/limodou
>
> >
>


-- 
我的博客:http://zsp.javaeye.com/

-- 张沈鹏(ZhangShen Peng)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about upload / FileField

2007-08-03 Thread !( 08)
In there , my filefield is required . Yes , you must upload a file .
How can I reach this aim ?

2007/8/3, Thomas Guettler <[EMAIL PROTECTED]>:
>
> Am Freitag, 3. August 2007 15:34 schrieb ZhangshenPeng:
> > Question 1:
> >
> > When I removed "blank=True" from FileField ,then use below method
> > to upload file , but no matter whether your choosed file , the from
> > valid will report error "This field is required."
>
> All newforms Fields habe a keyword argument called "required".
> Use required=False
>
> >
>


-- 
欢迎访问我的博客:
http://zsp.javaeye.com/

--张沈鹏

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---