import json

from django.conf.urls import url, include
from django.core.paginator import Paginator
from django.shortcuts import render

import xadmin as admin

from art.models import Category, Art
from api_ import api_router


def index(request):
    # 查询所有的一级分类
    cates = Category.objects.filter(parent=None).all()

    # 查询所有文章Art
    # 获取请求参数的p_cate  一级分类
    p_cate = request.GET.get('p_cate', '')
    if p_cate:
        p_cate = int(p_cate)
        arts = Art.objects.filter(category__parent_id=p_cate).all()
    else:
        arts = Art.objects.all()

    # 实现Art文章的分页
    # 获取请求参数的page页码
    page = request.GET.get('page', '1')

    paginator = Paginator(arts, 10)  # 分页器
    pager = paginator.page(int(page))  # 读取第一页的数据

    # 查询登录用户信息
    if 'login_user' in request.session:
        login_user = json.loads(request.session.get('login_user'))

    return render(request, 'index.html', locals())


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^ueditor/', include('DjangoUeditor.urls')),
    url(r'^user/', include('user.urls')),
    url(r'^art/', include('art.urls')),
    url(r'^api-auth/', include('rest_framework.urls')),
    url(r'^api/', include(api_router.urls)),
    url(r'', index),
]

872aa079cf8c6c2109bc617920e9dfc095dfd7d5
<mask token>

<mask token>


def index(request):
    cates = Category.objects.filter(parent=None).all()
    p_cate = request.GET.get('p_cate', '')
    if p_cate:
        p_cate = int(p_cate)
        arts = Art.objects.filter(category__parent_id=p_cate).all()
    else:
        arts = Art.objects.all()
    page = request.GET.get('page', '1')
    paginator = Paginator(arts, 10)
    pager = paginator.page(int(page))
    if 'login_user' in request.session:
        login_user = json.loads(request.session.get('login_user'))
    return render(request, 'index.html', locals())


<mask token>

<mask token>


def index(request):
    cates = Category.objects.filter(parent=None).all()
    p_cate = request.GET.get('p_cate', '')
    if p_cate:
        p_cate = int(p_cate)
        arts = Art.objects.filter(category__parent_id=p_cate).all()
    else:
        arts = Art.objects.all()
    page = request.GET.get('page', '1')
    paginator = Paginator(arts, 10)
    pager = paginator.page(int(page))
    if 'login_user' in request.session:
        login_user = json.loads(request.session.get('login_user'))
    return render(request, 'index.html', locals())


urlpatterns = [url('^admin/', admin.site.urls), url('^ueditor/', include(
    'DjangoUeditor.urls')), url('^user/', include('user.urls')), url(
    '^art/', include('art.urls')), url('^api-auth/', include(
    'rest_framework.urls')), url('^api/', include(api_router.urls)), url('',
    index)]

import json
from django.conf.urls import url, include
from django.core.paginator import Paginator
from django.shortcuts import render
import xadmin as admin
from art.models import Category, Art
from api_ import api_router


def index(request):
    cates = Category.objects.filter(parent=None).all()
    p_cate = request.GET.get('p_cate', '')
    if p_cate:
        p_cate = int(p_cate)
        arts = Art.objects.filter(category__parent_id=p_cate).all()
    else:
        arts = Art.objects.all()
    page = request.GET.get('page', '1')
    paginator = Paginator(arts, 10)
    pager = paginator.page(int(page))
    if 'login_user' in request.session:
        login_user = json.loads(request.session.get('login_user'))
    return render(request, 'index.html', locals())


urlpatterns = [url('^admin/', admin.site.urls), url('^ueditor/', include(
    'DjangoUeditor.urls')), url('^user/', include('user.urls')), url(
    '^art/', include('art.urls')), url('^api-auth/', include(
    'rest_framework.urls')), url('^api/', include(api_router.urls)), url('',
    index)]

import json

from django.conf.urls import url, include
from django.core.paginator import Paginator
from django.shortcuts import render

import xadmin as admin

from art.models import Category, Art
from api_ import api_router


def index(request):
    # 查询所有的一级分类
    cates = Category.objects.filter(parent=None).all()

    # 查询所有文章Art
    # 获取请求参数的p_cate  一级分类
    p_cate = request.GET.get('p_cate', '')
    if p_cate:
        p_cate = int(p_cate)
        arts = Art.objects.filter(category__parent_id=p_cate).all()
    else:
        arts = Art.objects.all()

    # 实现Art文章的分页
    # 获取请求参数的page页码
    page = request.GET.get('page', '1')

    paginator = Paginator(arts, 10)  # 分页器
    pager = paginator.page(int(page))  # 读取第一页的数据

    # 查询登录用户信息
    if 'login_user' in request.session:
        login_user = json.loads(request.session.get('login_user'))

    return render(request, 'index.html', locals())


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^ueditor/', include('DjangoUeditor.urls')),
    url(r'^user/', include('user.urls')),
    url(r'^art/', include('art.urls')),
    url(r'^api-auth/', include('rest_framework.urls')),
    url(r'^api/', include(api_router.urls)),
    url(r'', index),
]
