Django调用或转入其他工程view页面的方法

3812阅读 0评论2012-06-19 wdove
分类:系统运维


首先,在B工程中的urls.py为被调用的view取一个名字:

  1. === modified file 'dashboard_app/urls.py'
  2. --- dashboard_app/urls.py    2012-06-13 10:46:00 +0000
  3. +++ dashboard_app/urls.py    2012-06-19 08:57:07 +0000
  4. @@ -35,7 +35,8 @@
  5.      url(r'^reports/(?P[a-zA-Z0-9-_]+)/$', 'report_detail'),
  6.      url(r'^tests/$', 'test_list'),
  7.      url(r'^tests/(?P[^/]+)/$', 'test_detail'),
  8. - url(r'^notification/$', 'notification_pref'),
  9. + url(r'^notification/$', 'notification_pref',
  10. + name='dashboard_app.views.notification'),
  11.      url(r'^xml-rpc/$', linaro_django_xmlrpc.views.handler,
  12.          name='dashboard_app.views.dashboard_xml_rpc_handler',
  13.          kwargs={
在A工程中调用这个view的名字:

  1. === modified file 'lava_server/templates/me.html'
  2. --- lava_server/templates/me.html    2011-11-22 16:58:50 +0000
  3. +++ lava_server/templates/me.html    2012-06-19 08:42:45 +0000
  4. @@ -9,6 +9,8 @@
  5.      >{% trans "Sign out" %}</a></li>
  6.    <li><a href="{% url django.contrib.auth.views.password_change %}"
  7.      >{% trans "Change your password" %}</a></li>
  8. + <li><a href="{% url dashboard_app.views.notification %}"
  9. + >{% trans "Notification Type Definition" %}</a></li>
  10.  </ul>
  11.  {% endblock %}
即可在me页面转到那个view,前提是两个工程已经集成在了一起。

上一篇:IP反查hostname
下一篇:flock -- shell script的并发控制