标签:pre size role static art day lis dmi content
1.显示用户名
<li><a href="#">{{ request.user }}</a></li>
2.添加menu
urlpatterns = [ url(r‘^$‘, views.index,name=‘sales_index‘), #ctrl + b 跳转 url(r‘^customers/$‘,views.customer_list,name=‘custmoer_list‘), ]
def index(request): return render(request,‘index.html‘) def customer_list(request): return render(request,‘sales/customers.html‘)
3.添加role
4.实现效果
{% for role in request.user.userprofile.roles.all %} {% for menu in role.menus.all %} <li class=""><a href="{% url menu.url_name %}">{{ menu.name }}</a></li> {% endfor %} {% endfor %}
1.添加学生app
D:\PycharmProjects\PerfectCRM2>python manage.py startapp student
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘crm‘, ‘student‘, ]
2.url
from django.conf.urls import url,include from django.contrib import admin urlpatterns = [ url(r‘^admin/‘, admin.site.urls), url(r‘^crm/‘, include(‘crm.urls‘)), url(r‘^student/‘, include(‘student.urls‘)), #添加url ]
#student中 urls.py from django.conf.urls import url from student import views urlpatterns = [ url(r‘^$‘,views.index,name=‘student_index‘), ]
#student中views.py def index(request): return render(request,‘student/index.html‘)
3.实现效果
标签:pre size role static art day lis dmi content
原文地址:http://www.cnblogs.com/venicid/p/7788869.html