我正在 Django 中创建一个 wiki,用户应该能够注册、登录、创建页面,其他登录的用户应该能够查看所有创建的页面,然后创建新页面或编辑现有页面。
我已经创建了注册和登录页面,并且可以在页面上创建和编辑内容。我的问题是 - 你们中有人(了解 Django)知道如何在我的网站中实现创建新页面吗?我认为它将采用“表单”形式,您可以在其中指定新页面的 URL、标题和内容,但是如何实际创建新页面并能够向任何用户查看所有创建的页面呢?
我被困在这堵墙上,任何帮助将不胜感激!
I am creating a wiki in Django where users should be able to register, login, create pages and other users who also login should be able to see all created pages and then either create new pages or edit existing ones.
I have already created registration and login pages and I am fine with creating and editing content on pages. My question is - do any of you (who know Django) know how I can implement the create new pages into my site? I think it will be in a "form" form where you then specify the URL, title, and content of the new page, but how do you actually create the new pages then and be able to view all created pages to any user?
I am stuck at this wall and any help would be appreciated!
发布评论
评论(2)
在使用您提到的表单创建页面时,如果用户已登录,您将希望将用户 ID 作为外键存储在页面模型中。然后,当您显示为特定用户创建的页面时,您只需遵循该关系即可。
这是很久以前发布的,所以你可能只想使用这个 Django 应用程序,因为它在一个漂亮的包中为你解决了所有这些问题:
https://github.com/benjaoming/django-wiki
At the time of page create with the form that you mentioned, if the user is logged in, you will want to store the user ID as a foreign key in your page Model. Then when you go to display created pages for a specific user, you just follow the relationship.
This was posted a long time ago, so you will probably just want to use this Django App as it solves all of this for you, in one beautiful package:
https://github.com/benjaoming/django-wiki
你看过这里的教程吗? http://showmedo.com/videotutorials/video?name=1100000
我用该教程建立了一个维基 - 我认为即使它没有回答你的问题仍然可能为你指明正确的方向。希望有帮助!
Have you seen the tutorial here? http://showmedo.com/videotutorials/video?name=1100000
I built a wiki with that tutorial - I think even if it doesn't answer your question may still point you in the right direction. Hope it helps!