Django 官方教程翻译项目Django 产生于一个公众页面和内容发布者页面完全分离的新闻类站点的开发过程中。站点管理人员使用管理系统来添加新闻、事件 和体育时讯等,这些添加的内容被显示在公众页面上。Django 通过为站点管理人员创建统一的内容编辑界面解决了这个问题。 管理界面不是为了网站的访问者,而是为管理者准备的。 首先,我们得创建一个能登录管理页面的用户。请运行下面的命令: 1. $ python manage.py createsuperuser question.choice_set.all %} 6.- {{ choice.choice_text }}
7. {% endfor %} 8. 模板系统统一使用「点」符号来访问变量的属性。在示例 {{ question.question_text }} 中,首先 Django 尝试对 Question 对象使用字典查找(也就是使用obj.get(str)操作),如 特别是由好几个应用组成的大项目中,处理不同应用所需要的 静态文件的工作就显得有点麻烦了。 这就是 django.contrib.staticfiles 存在的意义:它将各个应用的静态文件(和一些你指明的 目录里的文件)统一收集起来,这样一来,在生产环境中,这些文件就会集中在一个便于分发的地 方。 首先,在 polls 目录下创建一个 static 目录。 Django 将会从这里收集静态文件,就像 Django0 码力 | 103 页 | 1.86 MB | 1 年前3
django cms 4.1.x DocumentationWarning: Django CMS 3.x used a different way of integrating placeholders. It’s PlaceholderField("slot_name") needs to be changed into a PlaceholderRelationField (available since django CMS 4.x). Get models.fields import PlaceholderRelationField from cms.utils.placeholder import get_placeholder_from_slot class MyModel(models.Model): # your fields placeholders = PlaceholderRelationField() (continues previous page) @cached_property def my_placeholder(self): return get_placeholder_from_slot(self.placeholders, "slot_name") # your methods The PlaceholderRelationField can reference more than one field0 码力 | 357 页 | 1.99 MB | 1 年前3
django cms 4.1.1 Documentation
Warning: Django CMS 3.x used a different way of integrating placeholders. It’s PlaceholderField("slot_name") needs to be changed into a PlaceholderRelationField (available since django CMS 4.x). Get models.fields import PlaceholderRelationField from cms.utils.placeholder import get_placeholder_from_slot class MyModel(models.Model): # your fields placeholders = PlaceholderRelationField() (continues previous page) @cached_property def my_placeholder(self): return get_placeholder_from_slot(self.placeholders, "slot_name") # your methods The PlaceholderRelationField can reference more than one field0 码力 | 361 页 | 2.00 MB | 1 年前3
Django CMS 4.1.x Documentationplaceholders. Warning Django CMS 3.x used a different way of integrating placeholders. It’s PlaceholderField("slot_name") needs to be changed into a PlaceholderRelationField (available since django CMS 4.x). Get started models.fields import PlaceholderRelationField from cms.utils.placeholder import get_placeholder_from_slot class MyModel(models.Model): # your fields The PlaceholderRelationField can reference more specific placeholders. The utility function get_placeholder_from_slot() retrieves a placeholder object based on its slot name. The slot is used in templates, to determine where the placeholder’s plugins0 码力 | 518 页 | 1.66 MB | 7 月前3
Django CMS 3.11.10 Documentationplaceholders. Warning Django CMS 3.x used a different way of integrating placeholders. It’s PlaceholderField("slot_name") needs to be changed into a PlaceholderRelationField (available since django CMS 4.x). Get started models.fields import PlaceholderRelationField from cms.utils.placeholder import get_placeholder_from_slot class MyModel(models.Model): # your fields The PlaceholderRelationField can reference more specific placeholders. The utility function get_placeholder_from_slot() retrieves a placeholder object based on its slot name. The slot is used in templates, to determine where the placeholder’s plugins0 码力 | 493 页 | 1.44 MB | 7 月前0.03
django cms 3.4.x DocumentationPlugins embedded in Text should remain unchanged in order not to break output if placeholder.slot != 'main' or (instance._render_meta.text_enabled and instance.parent): return rendered_content MypluginTests(TestCase): def test_plugin_context(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin, assertEqual(context['key'], 'value') def test_plugin_html(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin,0 码力 | 395 页 | 1.64 MB | 1 年前3
django cms 3.6.x Documentationunchanged # Plugins embedded in Text should remain unchanged in order not to break output if placeholder.slot != 'main' or (instance._render_meta.text_enabled and instance. ˓→parent): return rendered_content MypluginTests(TestCase): def test_plugin_context(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin, 'en', ) plugin_instance = model_instance assertEqual(context['key'], 'value') def test_plugin_html(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, (continues on next page) 96 Chapter 4. Software0 码力 | 278 页 | 1.63 MB | 1 年前3
django cms 3.10.x Documentationunchanged # Plugins embedded in Text should remain unchanged in order not to break output if placeholder.slot != 'main' or (instance._render_meta.text_enabled and instance. ˓→parent): return rendered_content MypluginTests(TestCase): def test_plugin_context(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin, 'en', ) plugin_instance = model_instance assertEqual(context['key'], 'value') def test_plugin_html(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin, 'en', ) renderer = ContentRenderer(re0 码力 | 296 页 | 1.79 MB | 1 年前3
django cms 3.5.x DocumentationPlugins embedded in Text should remain unchanged in order not to break output if placeholder.slot != 'main' or (instance._render_meta.text_enabled and instance.parent): return rendered_content MypluginTests(TestCase): def test_plugin_context(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin, assertEqual(context['key'], 'value') def test_plugin_html(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin,0 码力 | 403 页 | 1.69 MB | 1 年前3
django cms 3.7.x DocumentationPlugins embedded in Text should remain unchanged in order not to break output if placeholder.slot != 'main' or (instance._render_meta.text_enabled and instance.parent): return rendered_content MypluginTests(TestCase): def test_plugin_context(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin, assertEqual(context['key'], 'value') def test_plugin_html(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, MyPlugin,0 码力 | 409 页 | 1.67 MB | 1 年前3
共 76 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8













