[英]Django Url structure for a Site
So I ran through a lot of Django tuts and I seem to understand the basics. 因此,我经历了很多Django tut,并且似乎了解了基础知识。
I know everything about the urls.py. 我知道有关urls.py的一切。
But now I need to design the urls for the whole site. 但是现在我需要为整个网站设计网址。
It seems not as easy as I imagined. 这似乎没有我想象的那么容易。
I would like to achieve the following. 我想实现以下目标。
overall structure: 整体结构:
main-site/
main_site/projects/
main_site/projects/project1
/project2
/project3
/projectn
Project structure: 项目结构:
Every project has components that every Project shares:
projectn/description
projectn/criteria_to_participate
projectn/other
And components that just that project has.
projectn/section1/paginatorgallery1
projectn/section2/paginatorgallery2
projectn/final_summary/
If somebody lands in projectn/section1/paginatorgallery1 如果有人落在projectn / section1 / paginatorgallery1中
So my questions: 所以我的问题是:
So if the user would just manually take away urls: 因此,如果用户只是手动删除网址:
eg He is actually is on: 例如,他实际上在:
/main_site/project1/gallery / main_site / project1 / gallery
and manually takes away gallery in the browser. 并在浏览器中手动删除图库。
/main_site/project1/ / main_site / project1 /
Can I say that is forbidden? 我可以说这是禁止的吗? How can I achieve this?
我该如何实现?
And how can I achieve a url system that deals with the logged in user different? 以及如何实现与登录用户不同的url系统?
In other words how do I have to design the urls if I have a login and a non login part? 换句话说,如果我有登录名和非登录名,我该如何设计网址?
I know a lot of questions. 我知道很多问题。
But I hope that everybody had to go through this part sooner or later and might be able to share some insights.. 但是我希望每个人迟早都要经历这部分,并且也许能够分享一些见解。
Thanks 谢谢
Is this a good structure?
这是一个好结构吗?
This is a subjective question. 这是一个主观的问题。 You project layout looks OK to me but that doesn't mean much.
您的项目布局对我来说还可以,但这并不意味着什么。 I suggest that you use this as a starting point and change if and when you find it inadequate.
我建议您以此为起点,并在发现不足时进行更改。
Is there a site, resource to get some nice overview of django site structures for certain purposes?
是否有站点和资源可以为某些目的很好地了解Django站点结构? eg Webgallery, Photosite, Blog, Professional Site etc..
例如Webgallery,Photosite,Blog,Professional网站等。
There a bunch of good Django projects out there (take this listing of blog engines for instance). 那里有很多优秀的Django项目(例如,此博客引擎列表 )。 A Google search should yield some nice examples.
Google搜索应该会提供一些很好的例子。
Is there a way to prevent people to go back eg to main_site, once in one project?
有没有一种方法可以防止人们回到一个项目中,例如回到main_site?
Why do you want to do this? 为什么要这样做? Giving specific reasons for this would help people provide better answers.
给出具体原因可以帮助人们提供更好的答案。
In other words how do I have to design the urls if I have a login and a non login part?
换句话说,如果我有登录名和非登录名,我该如何设计网址?
One way to achieve this would be to decorate the views that require login with the appropriately named login_required
decorator. 实现此目的的一种方法是使用适当命名的
login_required
装饰器修饰需要登录的视图。 Other views that do not need logging in can be left alone. 不需要登录的其他视图可以保留。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.