-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
增加文章置顶 #23
增加文章置顶 #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有几个地方需要修改下
{% else%} | ||
置顶 | ||
{% endif %} | ||
</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 置顶和前面样式一样,用
|
分割 - url用
{% url %}
动态生成
app/views/views.py
Outdated
article_obj.save() | ||
except: | ||
raise ObjectDoesNotExist() | ||
return HttpResponseRedirect("/admin/app/article/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 移除 print
- return的url同样动态生成(使用
reverse
)
|
||
@permission_required('app', raise_exception=True) | ||
def set_acticle_top(request, article_id): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
view函数的函数名以 view
结尾
检查很细,已更正~ |
article_obj.save() | ||
except: | ||
raise ObjectDoesNotExist() | ||
return HttpResponseRedirect(request.headers["Referer"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里最好是用 reverse
生成url
最简单的一个置顶设置