2006年11月15日 星期三 09:40
ÎÒµÄmodels.pyÈçÏ£º class MatchTest(models.Model): adddate = models.DateTimeField() # test¿ªÊ¼µÄÈÕÆÚ comment = models.TextField() # testµÄcomment class MatchTask(models.Model): test = models.ForeignKey(MatchTest) # taskÊôÓÚÄÄ×étest parameter = models.TextField() # ²âÊÔµÄpatternµÄ²ÎÊý MatchTestºÍMatchTaskµÄ¹ØϵÊÇ£¬Ò»¸ö²âÊÔÖУ¬¿ÉÄÜÓжà¸öÈÎÎñ¡£ ÎÒµÄurls.pyÈçÏ£º urlpatterns = patterns('', (r'^test/(?P\d+)/$', 'website.patterntest.views.showtest'), (r'^task/(?P \d+)/$', ' django.views.generic.list_detail.object_detail', {'queryset': MatchTask.objects.all()}), (r'^task/(?P \d+)/deletetask/$', ' django.views.generic.create_update.delete_object', { 'model': MatchTask, 'post_delete_redirect': '..' } ), ) ÎÒÏëʵÏֵŦÄÜÊÇ£¬ÔÚɾ³ýij¸öÈÎÎñºó£¬·µ»Øµ½ÈÎÎñËùÔڵIJâÊÔµÄÐÅÏ¢ÁбíÖС£ post_delete_redirect¾ÍÓ¦¸ÃÀàËÆÓÚ£º 'post_delete_redirect': '/test/%d' % (MatchTask.objects.get (id=object_id).test.id) µ«Êµ¼ÊÉϺÃÏñ²»ÄÜÕâÑùÓá£ÇëÎÊÈçºÎÔÚ'post_delete_redirect'ÖÐʹÓÃobject_idµÄÐÅÏ¢£¿ лл¡£ -- Best Regards, Leo Jay -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061115/30c764a1/attachment.html
Zeuux © 2025
京ICP备05028076号