2007年01月19日 星期五 01:26
°´ÕÕchapter3ÖеIJ½Ö裺 views.py£º from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "It is now %s." % now return HttpResponse(html) urls.py£º from django.conf.urls.defaults import * from mysite.views import current_datetime urlpatterns = patterns('', (r'^now/$', current_datetime), ) Ö´ÐÐÒ³ÃæºóÈ´³öÏÖ£º AttributeError at /now/ 'function' object has no attribute 'rindex' Request Method: GET Request URL: http://192.168.0.220:8000/now/ Exception Type: AttributeError Exception Value: 'function' object has no attribute 'rindex' Exception Location: /usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/urlresolvers.py in get_mod_func, line 23 ÎÒµÄdjango°æ±¾£º >>> import django >>> django.VERSION (0, 96, 'pre') ÕâÊÇΪʲô£¿°æ±¾Ì«µÍ£¿ÎÒ¿´chapter2Öеİ汾ÊÇ£º >>> import django >>> django.VERSION (1, 0, 'official') ÎÒʹÓõÄÊÇFreeBSD£¬PortsÄܰ²×°µ½µÄ×îоÍÊÇÉÏÃæµÄÄǸö0.96 pre°æÁË -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070119/8cfb3a73/attachment.html
2007年01月19日 星期五 07:45
在07-1-19,hlddn <hlddn.python at gmail.com> 写道: > > from django.conf.urls.defaults import * > > from mysite.views import current_datetime > > urlpatterns = patterns('', > (r'^now/$', current_datetime), > > ) > > 我记得除非是开发版本,上边标红色的地方要用字符串的: (r'^now/$', 'current_datetime'), -- I like Python & Linux. Blog: http://recordus.cublog.cn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070119/bed2a591/attachment.html
2007年01月19日 星期五 08:18
On 1/19/07, Xupeng Yun <recordus在gmail.com> wrote: > 在07-1-19,hlddn <hlddn.python在gmail.com> 写道: > > from django.conf.urls.defaults import * > > from mysite.views import current_datetime > > > > urlpatterns = patterns('', > > (r'^now/$', current_datetime), > > > > > > ) > > > 我记得除非是开发版本,上边标红色的地方要用字符串的: > (r'^now/$', 'current_datetime'), > 不错,不能是0.95版本,需要开发版。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年01月19日 星期五 10:50
On 1/19/07, Xupeng Yun <recordus在gmail.com> wrote: > > ÔÚ07-1-19£¬hlddn <hlddn.python在gmail.com> дµÀ£º > > > > from django.conf.urls.defaults import * > > > > from mysite.views import current_datetime > > > > urlpatterns = patterns('', > > (r'^now/$', current_datetime), > > > > > > ) > > > > ÎҼǵóý·ÇÊÇ¿ª·¢°æ±¾£¬Éϱ߱êºìÉ«µÄµØ·½ÒªÓÃ×Ö·û´®µÄ£º > (r'^now/$', 'current_datetime'), лл¸÷λ£¬Ê¹ÓÃÉÏÃæµÄ·½Ê½Ò²²»ÐУ¬¿ÉÄܾÍÊǰ汾ÎÊÌâ¡£ÄѵÀ´ó¼ÒÓõͼÊÇ¿ª·¢°æ±¾£¿ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070119/edfcd940/attachment.htm
2007年01月19日 星期五 21:21
On 1/19/07, hlddn <hlddn.python在gmail.com> wrote: > > On 1/19/07, Xupeng Yun <recordus在gmail.com> wrote: > > > > ÔÚ07-1-19£¬hlddn <hlddn.python在gmail.com> дµÀ£º > > > > > > from django.conf.urls.defaults import * > > > > > > from mysite.views import current_datetime > > > > > > urlpatterns = patterns('', > > > (r'^now/$', current_datetime), > > > > > > > > > > > > ) > > > > > > ÎҼǵóý·ÇÊÇ¿ª·¢°æ±¾£¬Éϱ߱êºìÉ«µÄµØ·½ÒªÓÃ×Ö·û´®µÄ£º > > (r'^now/$', 'current_datetime'), > > > лл¸÷λ£¬Ê¹ÓÃÉÏÃæµÄ·½Ê½Ò²²»ÐУ¬¿ÉÄܾÍÊǰ汾ÎÊÌâ¡£ÄѵÀ´ó¼ÒÓõͼÊÇ¿ª·¢°æ±¾£¿ > ¸Ä³ÉÕâÑù¾Í¿ÉÒÔÁË from django.conf.urls.defaults import * # from mysite.views import current_datetime urlpatterns = patterns('', (r'^now/$', 'mysite.views.current_datetime'), ) -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070119/048b954d/attachment.htm
2007年01月19日 星期五 21:32
> 改成这样就可以了 > > from django.conf.urls.defaults import * > # from mysite.views import current_datetime > > urlpatterns = patterns('', > (r'^now/$', > 'mysite.views.current_datetime'), > ) > 这就是老的用法,你看django的文档就是这样举例的。url dispatch的文档。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年01月19日 星期五 22:02
ллÁË On 1/19/07, limodou <limodou在gmail.com> wrote: > > > ¸Ä³ÉÕâÑù¾Í¿ÉÒÔÁË > > > > from django.conf.urls.defaults import * > > # from mysite.views import current_datetime > > > > urlpatterns = patterns('', > > (r'^now/$', > > 'mysite.views.current_datetime'), > > ) > > > > Õâ¾ÍÊÇÀϵÄÓ÷¨£¬Äã¿´djangoµÄÎĵµ¾ÍÊÇÕâÑù¾ÙÀýµÄ¡£url dispatchµÄÎĵµ¡£ > > > -- > I like python! > UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070119/13864457/attachment.html
Zeuux © 2025
京ICP备05028076号