django-adminlte3 – part 3 django-adminlte3와 django-mptt로 사이드바 tree 메뉴 만들기 django-mptt 설치와 설정은 django-mptt로 tree구조 만들기(https://blog.boxcorea.com/wp/archives/2605)를 참고하면 된다. 관리자페이지에서 아래와같은 tree구조를 만들었고, 이것을 사이드바에 tree 구조로 보이도록 view를 만들어본다. project/app/urls.py에 url을 등록한다.
1 2 3 4 |
urlpatterns = [ path('category', CategoryView.as_view(), name='category'), path('test/', TestView.as_view(), name='test'), ] |
project/app/views.py 에 아래와 같이 view를 만든다.
1 2 3 4 5 6 7 8 |
class CategoryView(View): template_name = 'chaser/category.html' def get(self, request): context = { 'categories': Category.objects.all(), } return render(request, self.template_name, context) |