首页 \ 问答 \ 动态子导航(Dynamic sub nav)

动态子导航(Dynamic sub nav)

我为自己创建了一个投资组合网站,有一个用户可以进入的图库,点击缩略图然后转到一个新的html页面,其中包含完整的图像和描述。 现在在这个完整的图像页面上,我有一个项目2,3,4,5等的其他全图页面列表。

但显然手动更新project2.html以获得子导航中的所有其他项目minius项目2的列表非常繁琐,当我必须为所有12个页面执行此操作时将出现错误。 因此,在人们观看的页面之后我不会出现在该子导航中。

我的问题是..我是否废弃自定义html网站并转移到cms ..这种动态导航的逻辑步骤。 或者如果可能的话我尝试包含php。 任何人都可以建议最好的方法,我知道它可能在longrun更容易运行cms但我喜欢控制我得到和知识我手工制作我的HTML。

谢谢你


Ive created a portfolio website for myself, there is a gallery which users can enter, click on a thumbnail and then go to a new html page with the full image and description. Now on this full image page i have a list of other fullimage pages for project 2,3,4,5, etc..

But obviously manually updating project2.html to have a list of all other projects minius project 2 in the sub nav is very tedious and mistakes will occus when i have to do it for all 12 plus pages. So im after the page people are viewing not to appear in that sub nav.

My problem is.. Do i scrap the custom html site and move onto a cms.. The logical step for this sort of dynamic nav. Or do i try and include php if possible. Can anyone suggest the best approach for this, im aware it might in the longrun be easier to run off a cms but i do like the control i get and knowledge i hand crafted my html.

Thanks Mat


原文:https://stackoverflow.com/questions/9177060
更新时间:2024-03-11 20:03

最满意答案

在django文档中的multi-db(手动选择数据库)

# This will run on the 'default' database.
Author.objects.all()

# So will this.
Author.objects.using('default').all()

# This will run on the 'other' database.
Author.objects.using('other').all()

The 'default' and 'other' are aliases for you databases.
In your case it would could be 'default' and 'remote'.

当然你可以用你想要的任何东西替换.all()。

Example: System.objects.using('remote').get(id=123456)

In the django documentation multi-db (manually-selecting-a-database)

# This will run on the 'default' database.
Author.objects.all()

# So will this.
Author.objects.using('default').all()

# This will run on the 'other' database.
Author.objects.using('other').all()

The 'default' and 'other' are aliases for you databases.
In your case it would could be 'default' and 'remote'.

of course you could replace the .all() with anything you want.

Example: System.objects.using('remote').get(id=123456)

相关问答

更多
  • 这可以帮助你: 我完全同意使用数据库路由器。 我所做的是,我用单一的管理界面来处理多个数据库。 请注意,所有应用程序的身份验证都存储在默认数据库中。 Settings.py # Define the database manager to setup the various projects DATABASE_ROUTERS = ['manager.router.DatabaseAppsRouter'] DATABASE_APPS_MAPPING = {'app1': 'db1', ...
  • 您有一个语法错误,因为您缺少一个逗号: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'testdatabase', 'USER': 'root', 'PASSWORD': 'Xma47data', 'HOST': 'localhost', 'PORT': '3306', }, # <-- HERE 'vnosdatabase': { 'ENG ...
  • 您需要在settings.py定义两个数据库。 您应该阅读设置多个数据库文档 。 这很直接。 配置和同步数据库后,可以手动为QuerySet选择数据库,如下所示: Model.objects.using('database').all() 更新: 要为模型指定连接,可以按如下方式定义Router 。 from django.db import connections class MyRouter(object): """ This router object will take care ...
  • Django Project正致力于多数据库支持 。 最近还有一篇(2009年11月10日)关于“MultiDB状态(在Django中)”的博客文章。 更新:自Django v1.2 (2010年5月发布)以来支持多个数据库 。 Django Project is working on Multiple Database Support. There is also a recent (Nov 10 2009) blog post about "The state of MultiDB (in Django ...
  • 正如评论中所发现的 - 这是一篇描述如何设置服务器实例并随时选择数据库的文章,因此其作者应该获得所有学分。 重申基本方法: 创建表示数据库连接的模型类: class Database(models.Model): name = models.CharField(max_length=256, unique=True) config = JSONField() 添加label属性以区分db连接实体。 这里,它需要在django设置中设置字符串DYNAMIC_DATABASES_PREFIX和 ...
  • 您如何存储它们取决于您需要如何查询它们。 例如,如果您只需要查找父项的直接子项,则邻接列表模型可能是最简单的。 如果你想枚举整个子树,祖先列表或嵌套集合运行良好 - 尽管我会避免App Engine上的嵌套集合。 如果您需要树中所有对象的事务完整性 - 并且不会每秒更新一次,那么您应该查看App Engine对实体组和祖先的支持。 How you store them depends on how you need to query them. For example, if you only need t ...
  • 您的问题实际上并不清楚您的实际期望,但无论如何,这里有一些提示: 首先,模型实例(假设它们是相同模型的实例)比较它们的主键值,该键值也用作字典和集合的哈希值,因此如果要比较基础数据库记录,则不应使用模型实例,但将原始数据库值视为元组或列表的列表。 您可以使用(或) Queryset.values_list()或Queryset.values()来获得这些内容 - 不要忘记list()它们,以便您真正获得list而不是查询集。 这将我们带到了第二个重要的地方:虽然将自己呈现为列表类(在它们支持len() ,迭 ...
  • Django 支持多个数据库 。 你可以保留你的scraping程序/数据库,并直接通过Django访问数据库。 像平常一样设置模型 - 但在META字段中设置managed = False 。 这将阻止Django将迁移应用到数据库。 如果您发现您确实想通过Django模型管理数据库,则需要设置一个路由类,以确保您的应用只针对预期的数据库。 Django supports multiple databases. You can leave your scraping program/database as ...
  • 在django文档中的multi-db(手动选择数据库) # This will run on the 'default' database. Author.objects.all() # So will this. Author.objects.using('default').all() # This will run on the 'other' database. Author.objects.using('other').all() The 'default' and 'other' are ...
  • 最后我设法解决了这个问题。 我使用创建表 manage.py syncdb --all manage.py migrate --fake 由于完整性问题,使用loaddata加载转储不起作用。 (例如,破坏外键约束) 所以我不得不改变我的桌子。 我删除了破坏的约束,然后我可以毫无问题地运行loaddata 。 但是,当然我的数据库仍然被打破,因为我放弃了一些约束。 因此,我只需要使用psql shell再次更改我的表。 pgAdmin派上用场,因为在用户友好的界面上显示相关的转储查询,分别针对每个不同的约 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)