Skip to content
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

Merged
merged 2 commits into from
Dec 30, 2020
Merged

增加文章置顶 #23

merged 2 commits into from
Dec 30, 2020

Conversation

JiehuiSun
Copy link
Contributor

最简单的一个置顶设置

Copy link
Owner

@gojuukaze gojuukaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有几个地方需要修改下

{% else%}
置顶
{% endif %}
</a>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 置顶和前面样式一样,用 | 分割
  • url用 {% url %} 动态生成

article_obj.save()
except:
raise ObjectDoesNotExist()
return HttpResponseRedirect("/admin/app/article/")
Copy link
Owner

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):
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view函数的函数名以 view 结尾

@JiehuiSun
Copy link
Contributor Author

检查很细,已更正~

article_obj.save()
except:
raise ObjectDoesNotExist()
return HttpResponseRedirect(request.headers["Referer"])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里最好是用 reverse 生成url

@gojuukaze gojuukaze merged commit b3ee084 into gojuukaze:dev Dec 30, 2020
@gojuukaze gojuukaze mentioned this pull request Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants