当前位置: 首页>>代码示例>>Python>>正文


Python Entry.get_dates方法代码示例

本文整理汇总了Python中blog.models.Entry.get_dates方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.get_dates方法的具体用法?Python Entry.get_dates怎么用?Python Entry.get_dates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blog.models.Entry的用法示例。


在下文中一共展示了Entry.get_dates方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detail

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def detail(request, entry_id):
    if request.method == "POST":
        form = CommentForm(request.POST, error_class=DivErrorList)
        if form.is_valid():
            author = request.user
            text = request.POST['text']
            entry = entry = Entry.objects.get(pk=entry_id)
            pub_date = timezone.now()
            comment = Comment(author=author,
                              entry=entry,
                              text=text,
                              pub_date=pub_date)
            comment.save()

    dates = Entry.get_dates()
    form = CommentForm()

    try:
        entry = Entry.objects.get(pk=entry_id)
    except Entry.DoesNotExist:
        raise Http404
    comments = Comment.objects.filter(entry=entry)
    context = {'entry': entry, 'dates': dates,
               'comments': comments, 'form': form}
    return render(request, 'blog/detail.html', context)
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:27,代码来源:views.py

示例2: index

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def index(request):
    entries_list = Entry.objects.all().order_by('-pub_date')
    paginator = Paginator(entries_list, 5)  # Show 5 entries per page
    entries = request.GET.get('page')
    try:
        entries = paginator.page(entries)
    except PageNotAnInteger:
        entries = paginator.page(1)
    except EmptyPage:
        entries = paginator.page(paginator.num_pages)

    dates = Entry.get_dates()
    context = { 'dates': dates, 'entries': entries}
    return render(request, 'blog/index.html', context)
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:16,代码来源:views.py

示例3: login

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def login(request):
    if request.user.is_authenticated():
        return redirect('index')

    if request.method == "POST":
        form = LoginForm(request.POST, error_class=DivErrorList)
        if form.is_valid():
            user = form.login(request)
            if user:
                auth_login(request, user)
                return redirect('index')
    else:
        form = LoginForm()

    dates = Entry.get_dates()
    context = {'dates': dates, 'form': form}

    return render(request, 'blog/login_form.html', context)
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:20,代码来源:views.py

示例4: edit_user_profile

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def edit_user_profile(request):
    user = request.user
    if not user.is_authenticated():
        return redirect('login')

    try:
        about = UserProfile.objects.get(user=user).about
    except UserProfile.DoesNotExist:
        about = UserProfile.objects.create(user=user)

    dates = Entry.get_dates()

    update_email_form = UpdateEmailForm()
    update_about_form = UpdateAboutForm(initial={'about': about})

    return render(request, 'blog/edit_profile.html', {
                           'update_email_form': update_email_form,
                           'user': user,
                           'dates': dates,
                           'update_about_form': update_about_form})
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:22,代码来源:views.py

示例5: user_profile

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def user_profile(request, username):

    dates = Entry.get_dates()
    logged_in_user = request.user

    try:
        instance = User.objects.get(username=username)
    except ObjectDoesNotExist:
        raise Http404

    try:
        user_profile = UserProfile.objects.get(user=instance)
    except ObjectDoesNotExist:
        user_profile = None

    context = {'view_user': instance,
               'user_profile': user_profile,
               'logged_in_user': logged_in_user,
               'dates': dates}

    return render(request, 'blog/user_profile.html', context)
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:23,代码来源:views.py

示例6: signup

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def signup(request):
    dates = Entry.get_dates()
    if request.method == "POST":
        form = SignupForm(request.POST, error_class=DivErrorList)

        if form.is_valid():
            username = request.POST['username']
            email = request.POST['email']
            password = request.POST['password']
            User.objects.create_user(username=username,
                                     email=email,
                                     password=password)
            new_user = authenticate(username=request.POST['username'],
                                    password=request.POST['password'])
            auth_login(request, new_user)

            return redirect('index')
    else:
        form = SignupForm()
    return render(request, 'blog/signup.html', {
                           'form': form,
                           'dates': dates})
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:24,代码来源:views.py

示例7: new_post

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get_dates [as 别名]
def new_post(request):
    if not request.user.is_authenticated():
        return redirect('login')
    if request.method == "POST":
        form = PostForm(request.POST, error_class=DivErrorList)
        if form.is_valid():
            title = request.POST['title']
            post = request.POST['post']
            p = Entry(author=request.user,
                      title=title,
                      post=post,
                      pub_date=timezone.now())
            p.save()
            entry_id = p.pk
            return redirect('detail', entry_id=entry_id)
    else:
        form = PostForm

    dates = Entry.get_dates()
    context = {'dates': dates, 'form': form}

    return render(request, 'blog/new_post.html', context)
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:24,代码来源:views.py


注:本文中的blog.models.Entry.get_dates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。