django-fluent / django-fluent-contents Goto Github PK
View Code? Open in Web Editor NEWA widget engine to display various content on Django pages
Home Page: http://django-fluent.org/
License: Apache License 2.0
A widget engine to display various content on Django pages
Home Page: http://django-fluent.org/
License: Apache License 2.0
When objects are deleted their content is not deleted, it is orphaned in the database. This seems to break django-reversion and clutters the database with garbage. Is there a good reason for this behaviour? If it is needed perhaps a setting to disable this behaviour would be ok?
By default, plugin output is cached. The setting FLUENT_CONTENTS_CACHE_OUTPUT
is True
by default to test the live situation.
For developers in DEBUG mode, it would make sense to stat()
the template file, and clear the cache when it's updated. This makes it much easier to edit templates.
While WYSIWYG editors provide image support already, a picture plugin could provide:
The slug field is not checked for uniqueness across all sites when the is_cross_site
is enabled. This causes the MultipleObjectsReturned
errors when displaying the object.
When running manage.py runserver
, if I access twice to a page using the {% render_placeholder %}
tag, I get an error. I need to restart the server to fix the problem and if I ask for the page a second time, the error shows up again.
Traceback (most recent call last):
File "....../lib/python3.4/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "....../lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
response = self.get_response(request)
File "....../lib/python3.4/site-packages/django/core/handlers/base.py", line 218, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "....../lib/python3.4/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "....../lib/python3.4/site-packages/django_extensions/management/technical_response.py", line 5, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "....../lib/python3.4/site-packages/six.py", line 659, in reraise
raise value
File "....../lib/python3.4/site-packages/django/core/handlers/base.py", line 164, in get_response
response = response.render()
File "....../lib/python3.4/site-packages/django/template/response.py", line 158, in render
self.content = self.rendered_content
File "....../lib/python3.4/site-packages/django/template/response.py", line 135, in rendered_content
content = template.render(context, self._request)
File "....../lib/python3.4/site-packages/django/template/backends/django.py", line 74, in render
return self.template.render(context)
File "....../lib/python3.4/site-packages/django/template/base.py", line 209, in render
return self._render(context)
File "....../lib/python3.4/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "....../lib/python3.4/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "....../lib/python3.4/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "....../lib/python3.4/site-packages/django/template/loader_tags.py", line 135, in render
return compiled_parent._render(context)
File "....../lib/python3.4/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "....../lib/python3.4/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "....../lib/python3.4/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "....../lib/python3.4/site-packages/django/template/loader_tags.py", line 135, in render
return compiled_parent._render(context)
File "....../lib/python3.4/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "....../lib/python3.4/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "....../lib/python3.4/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "....../lib/python3.4/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "....../lib/python3.4/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "....../lib/python3.4/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "....../lib/python3.4/site-packages/tag_parser/basetags.py", line 110, in render
return self.render_tag(context, *tag_args, **tag_kwargs)
File "....../lib/python3.4/site-packages/tag_parser/basetags.py", line 311, in render_tag
return self.get_value(context, *tag_args, **tag_kwargs)
File "....../lib/python3.4/site-packages/fluent_contents/templatetags/fluent_contents_tags.py", line 290, in get_value
fallback_language=fallback_language
File "....../lib/python3.4/site-packages/fluent_contents/rendering.py", line 141, in render_placeholder
output = _render_items(request, placeholder, items, parent_object=parent_object, template_name=template_name, cachable=cachable)
File "....../lib/python3.4/site-packages/fluent_contents/rendering.py", line 267, in _render_items
if _is_template_updated(request, contentitem, cachekey):
File "....../lib/python3.4/site-packages/fluent_contents/rendering.py", line 446, in _is_template_updated
if plugin.get_render_template.__func__ is not ContentPlugin.get_render_template.__func__:
AttributeError: 'function' object has no attribute '__func__'
Some informations from the Werkzeug command-line :
>>> plugin.__class__
<class 'fluent_contents.plugins.text.content_plugins.TextPlugin'>
>>> hasattr(plugin.get_render_template, '__func__')
True
>>> hasattr(ContentPlugin.get_render_template, '__func__')
False
I've come across an issue where I can't delete an object with a placeholder field.
update or delete on table "fluent_contents_placeholder" violates foreign key constraint "placeholder_id_refs_id_8e1f1b78" on table "fluent_contents_contentitem"
DETAIL: Key (id)=(9) is still referenced from table "fluent_contents_contentitem".
It seems like the delete doesn't cascade properly to the fluent_contents_contentitem.
using django 1.5.1
latest fluent-contents via git
Let me know what other information I need to provide.
For fluent contents plugin, is admin.TabularInline implemented? For bookmark example, for 'title, url' model, do admin.TabularInline multiple bookmark entries and then do 'for' loop in the template. Wondered if this is something implented or if not any work around? or a good time consuming work?
Hey,
Just wanted to know your thoughts on dealing with an issue that resulted from an upgrade of fluent-contents 0.8.3 to 0.9. There was some changes in your code with the Markup plugin in going to the newer version that results in an error on saving.
The error I get is
/local/lib/python2.7/site-packages/fluent_contents/extensions/pluginpool.py", line 144, in get_plugin_by_model
raise PluginNotFound("No plugin found for model '{0}'.".format(model_class.__name__))
PluginNotFound: No plugin found for model 'MarkupItem'.
I was tracing the root of the problem and it seems that the original pieces of content were pointing to a content type called "markupitem.markupitem" and when I create a new piece of textile it is related to "markupitem.textilemarkupitem" instead. Adjusting the foreign key in the database on the content item manually to point to the new content type seems to resolve the issue. However, I don't know if this will have repercussions elsewhere and whether this is isolated to the markup plugin only.
I had a peak at the history of the markup plugin and I can see that there was some code added that dynamically created new markup content types on the v0.9 tag, so I'm fairly positive that's where the upgrade breaks.
Just wanted to know your thoughts as to resolving the issue safely as there are thousands of content items to adjust.
Thanks,
Ashia
As reported at django-fluent/django-fluent-pages#9 the {% page_placeholder %}
tag could use a configuration of allowed plugins.
This could happen both in:
settings.py
variable, like Djang CMS does (http://docs.django-cms.org/en/2.2/getting_started/configuration.html#cms-placeholder-conf)page_placeholder
tag.As of 1d6472a it's already possible to limit the plugins for a PlaceholderField
. Hence, this feature needs to be extended to the named placeholders too.
To implement form processing in a content item, it is desirable to redirect the page afterwards.
Since the plugins do not return a response by design (as they are part of a greater whole), the should "request a redirect" instead. This could be implemented via a raise RequestHttpRedirect(url)
or return self.request_redirect(request, url)
method, which is handled in a PluginRedirectRequest
object.
Thanks for django-fluent-[contents|pages], here is my small contribution https://github.com/bashu/fluentcms-filer
PS: fluentcms-suit (django-suit integration) will be ready soon =)
Images displayed with the "picture" plugin should be scaled automatically to a restricted size. Preferably, the plugin knows what the maximum allowed size of the "placeholder" is.
When a plugin is only a foreign key to an existing model, it would be nice to open that model somewhere inline (e.g. in a lightbox) instead of only offering the pulldown field to select a model.
Thanks for django-fluent-[contents|pages], here is my small contribution https://github.com/bashu/fluentcms-file
PS: fluentcms-teaser and fluentcms-filer will be ready soon =)
Adding as reference for myself.
Changing the slot name in a PlaceholderField
causes it to point to both the new and old name in the template at rendering, thereby causing script errors.
Not sure who's responsible for this really - Suit or fluent contents, however in
plugins/text/static/fluent_contents/plugins/text/text_admin.js - line 20 & 31 - jQuery is searching for [id=prefix] when I believe it should be [id=prefix]. Flipping the "=~" solves the issue, and the text item loads the wysiwyg without issue.
(if I am submitting this issue request erroneously, or breaking github community standards, I apologize. This is my first contribution ;))
To dump data, one has to specify a lot of app names (all apps which have plugins) and use the -n
option. This should be simplified by a management command.
Current situation:
./manage.py dumpdata -n fluent_contents text oembeditem rawhtml picture myapp
Desired situation:
./manage.py dumpdata_placeholder myapp
If you will enable this repo for travis-ci, I am glad to provide a pull-request.
Thanks for django-fluent-[contents|pages], here is my small contribution https://github.com/bashu/fluentcms-link
PS: fluentcms-twitterfeed will be ready soon =)
The text plugin could benefit from filtering hooks, e.g. to:
­
)Being a noob here, I've been trying to run your app and example. Even using the unmodified code provided in the example, I couldn't save more than one ContentItem(s) in a model. Is there some trick to this? How do I save multiple ContentItem(s)?
Thank you, I would really appreciate your answer.
Add a plugin for maps (perhaps supporting various backends?), e.g. Google Maps, OpenLayers, Leaflet.
Suggested features:
When users don't have permission to all inline models, the content may still be edited, or cause errors.
For example, when users have no permission on the Placeholder model, the inline will try to re-create the object while it already exists. Error:
IntegrityError: duplicate key value violates unique constraint "fluent_contents_placeholde_parent_type_id_451c85966d08dedf_uniq"
DETAIL: Key (parent_type_id, parent_id, slot)=(29, 52, blog_contents) already exists.
When the ContentItem
inlines don't have edit permission, the elements should still be displayed, but not made editable.
If you have the setup:
class A(ContentItem):
<fields here>
class B(A):
<fields here>
When you save an instance of item B in a region then it will show populated values for A and B.
It will also not allow deletion of the content item as it will have the suffix a_ptr
instead of contentitem_ptr
which is required by get_formset_dom_info
and the line id_field: $("#" + field_prefix + "-contentitem_ptr"),
.
I have two fixes which could be applied here:
Change the line id_field: $("#" + field_prefix + "-contentitem_ptr"),
to id_field: $("[id^=" + field_prefix + "-][id$=_ptr]")
which would allow deletion.
Also in the function cp_data.init
after $fs_items
are calculated perform some cleaning up:
cp_data.init = function()
{
// Find all formset items.
var $all_items = $(".inline-contentitem-group > .inline-related");
var $empty_items = $all_items.filter(".empty-form");
var $fs_items = $all_items.filter(":not(.empty-form)");
var $fs_non_content_items = $fs_items.filter(":not(:has([id$=contentitem_ptr]))");
for (var i = 0; i < $fs_non_content_items.length; i++) {
var item = $fs_non_content_items.eq(i);
var itm_name = item.find('input[id$=_ptr]').attr('id').replace('id_' + item.attr('id') + '-', '').replace('_ptr', '');
var related_items = $fs_items.filter('[id^=' + itm_name + ']');
for(var j = 0; j < related_items.length; j++) {
if(
item.children('input').attr('value') == related_items.eq(j).children('input').attr('value') &&
item.find('.cp-formset-item-fields > [id$=placeholder]').attr('value') == related_items.eq(j).find('.cp-formset-item-fields > [id$=placeholder]').attr('value') &&
item.find('.cp-formset-item-fields > [id$=sort_order]').attr('value') == related_items.eq(j).find('.cp-formset-item-fields > [id$=sort_order]').attr('value')
) {
$fs_items = $fs_items.not('#' + related_items.eq(j).attr('id'));
break;
}
}
}
// Group all formset items by the placeholder they belong to.
// This administration is used as quick lookup, to avoid unneeded DOM querying.
if( cp_data.placeholders )
.
.
.
Which remove the duplicate content items list.
I would like to get thoughts on this approach? Is this something of interest or not too bother? If it is I can clean up my code a little before submitting a pull request.
Since Django 1.5, django.contrib.markup
is deprecated. (see https://docs.djangoproject.com/en/1.5/releases/1.5/#django-contrib-markup) It needs to be replaced with proper calls to docutils
, textile
and markdown
.
As suggested at django-fluent/django-fluent-pages#9, it's valuable to limit how many instances of a plugin can be created in a placeholder. Django CMS also has this feature (see http://docs.django-cms.org/en/2.2/getting_started/configuration.html#cms-placeholder-conf)
This feature is related to #3
When I have a lot of content items, and I add a new one it goes to the bottom of the list. I have to click the little up arrow many times to get it near the top, and ever time I click the error the item jumps away and I have to scroll to find it and click again. This is very tedious.
It would be great if fluent-contents
included some JS in the placeholder editor admin to auto-scroll the page so that content item being moved is still in the same position, with the same arrow button perfectly aligned under the mouse cursor, so I can just click it again :)
The reStructuredText support in the markup
plugin doesn't generate the first header in the HTML output, unless there is some plain text above it. This can likely be solved by using the proper docutils
API's.
This can be picked up with #13
We are using fluent-contents
(without fluent-pages
). We are using the "CMS system" style with dynamic layout switching. A particular layout's template initially had only one placeholder defined in it. Objects using this layout have already been saved to the database and it is working as expected.
We need to add a second placeholder to the existing layout's template. When we do, the new placeholder is detected and rendered in the form, but when we save the form, we get a ValidationError: '' value must be an integer."
originating in fluent_contents.admin.genericextensions.BaseInitialGenericInlineFormSet._construct_form
.
While digging through the code, we noticed what looks like a related bug in BaseInitialGenericInlineFormSet.__get_form_instance()
. The code assumes that the number of forms in the formset equals the number of Placeholder
objects already saved in the database and that their sequence is a match. We fixed that problem with the following code:
def __get_form_instance(self, i):
instance = None
try:
# Editing existing object. Make sure the ID is passed.
instance = self.get_queryset().filter(slot=self._initial[i]['slot'])[0]
except IndexError:
try:
# Adding new object, pass initial values
# TODO: initial should be connected to proper instance ordering.
# currently this works, because the client handles all details for layout switching.
queryset_count = self.get_queryset().count()
values = self.__initial_minus_queryset()[i - queryset_count]
values[self.ct_field.name] = ContentType.objects.get_for_model(self.instance)
values[self.ct_fk_field.name] = self.instance.pk
instance = self.model(**values)
instance.save()
except IndexError:
pass
return instance
This code does two things differently:
It gets the Placeholder
by slot name instead of by index, in case they are out of order (e.g. the template is updated and their positions are reversed).
It calls instance.save()
to persist the new Placeholder
object to the database as soon as it is needed by the frontend, when the change form page is rendered.
This fixed the ValidationError
, but on save we got a different error, instead...
IntegrityError: duplicate key value violates unique constraint "fluent_contents_placeholde_parent_type_id_451c85966d08dedf_uniq"
DETAIL: Key (parent_type_id, parent_id, slot)=(10, 100607, main) already exists.
It seems that fluent-contents
is trying to create a Placeholder
that already exists. Perhaps because we already created it earlier in __get_form_instance()
?
@sjdines and I spent a couple hours trying to debug this, and it seems pretty complex. Perhaps this would be an easy fix for you, @vdboor, or you could shed some light on it for us.
Should we be trying to create and save a Placeholder
object as soon as the frontend needs one, or only when content items are saved to a placeholder?
Or should we be trying to fix the ValidationError
another way?
In the CMS interface, the placeholder "add" combobox shows all possible plugins. Only after saving the page the list is shortened to the allowed number of plugins.
The policy of FLUENT_CONTENTS_PLACEHOLDER_CONFIG
is not applied dynamically to the form. This is visible in the PlaceholderEditorAdmin
which django-fluent-pages also uses.
When I run manage.py migrate picture
I get this error :
ImportError: No module named 'any_urlfield'
fluent_contents.plugins.picture
is in my INSTALLED_APPS but I didn't installed the django-any-urlfield
package. Migrations souldn't import any_urlfield
...
I had to delete the file plugins/picture/migrations/0001_initial.py
to fix it.
The picture plugin has no support for a "lightbox" to show the larger image.
Either this feature should be part of the plugin, or a new "gallery" like plugin should be written.
Plugins should be able to specify that they need additional JavaScripts in the frontend to function.
The main template could include a {% plugin_media %}
tag or something alike.
This can't be done using django-sekizai yet because template rendering is skipped when output is cached.
Thanks for django-fluent-[contents|pages], here is my small contribution https://github.com/bashu/fluentcms-campaign (work in-progress)
The markup and HTML plugins could use a custom editor, e.g.:
http://markitup.jaysalvat.com/home/
http://codemirror.net/
http://www.cdolivet.com/editarea/
When migrating from 1.6 to 1.7 I hit such errors. All generated calling manage.py validate
.
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/apps/config.py", line 197, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/fluent_contents/models/__init__.py", line 23, in <module>
from fluent_contents.models.fields import PlaceholderField, PlaceholderRelation, ContentItemRelation
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/fluent_contents/models/fields.py", line 2, in <module>
from django.contrib.contenttypes.generic import GenericRelation, GenericRel
ImportError: cannot import name GenericRel
According to django 1.7 release notes some changes were applied to content types application.
Digging a bit, it looks like although GenericRelation
class was moved, some steps were made to sustain possibility of importing it the old way. GenericRel
wasn't treated that way and can't be imported from django.contrib.contenttypes.generic
anymore.
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 23, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/fluent_pages/pagetypes/fluentpage/admin.py", line 6, in <module>
from fluent_contents.analyzer import get_template_placeholder_data
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/fluent_contents/analyzer.py", line 4, in <module>
from template_analyzer.djangoanalyzer import get_node_instances
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/template_analyzer/__init__.py", line 1, in <module>
from .djangoanalyzer import get_node_instances
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/template_analyzer/djangoanalyzer.py", line 11, in <module>
from django.template.loader_tags import ConstantIncludeNode, ExtendsNode, BlockNode
ImportError: cannot import name ConstantIncludeNode
Looks like ConstantIncludeNode (and its base class BaseIncludeNode) was removed, I can't find them anywhere in Django code.
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x7f44e830a1b8>
Traceback (most recent call last):
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 222, in wrapper
fn(*args, **kwargs)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 105, in inner_run
self.validate(display_num_errors=True)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 362, in validate
return self.check(app_configs=app_configs, display_num_errors=display_num_errors)
File "/home/tomek/htdocs/isivi/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 414, in check
raise CommandError(msg)
django.core.management.base.CommandError: System check identified some issues:
ERRORS:
<class 'fluent_pages.admin.pageadmin.DefaultPageParentAdmin'>: (admin.E016) The value of 'form' must inherit from 'BaseModelForm'.
Django 1.7 came with some new project check framework and some code breaks one of this spec rules.
BTW
Thx a lot for nice group of fluent apps!
Custom content items currently have to provide a JavaScript file to enable a WYSIWYG editor. The default editors don't work, as new elements can be added dynamically.
This module should provide a simple model-field that displays a WYSIWYG editor by default, to address this common use case.
Thanks for django-fluent-[contents|pages], here is my small contribution https://github.com/bashu/fluentcms-twitterfeed
PS: fluentcms-file and fluentcms-teaser will be ready soon
Hello, I am working with mezzanine and they have a nice drag and drop interface for models that require it, in their admin. It would be nice if a similar drag and drop feature applicable to ContentItems in a Placeholder.
Whenever I try and remove a fluent contents form from an admin page I get this uncaught error thrown in cp_plugins.js:596. It seems it can't find id_field property on the content_item object.
I've traced the source of the problem to where that object is created in cp_data.js:310 :
id_field: $("#" + field_prefix + "-contentitem_ptr"),
I can't see anywhere an element with an id like that. What is it trying to find there? I've experienced the same issue using default Django Admin and Django Suit admin.
Using fluent contents 1.9 and Django 1.6.2
The twitterfeed
plugin is no longer working properly, as the implementation we've used (http://tweet.seaofclouds.com/) no longer works. Quoting:
Important note about Twitter's API changes
Twitter has discontinued its unauthenticated v1.0 API, so this widget has stopped working as of 2013-06-11.
Twitter wants your only option for on-page widgets to be their own Embedded Timelines, but there are workarounds which involve installing server-side code to support this widget. Please see this discussion for more details.
The twitterfeed would have to use Twitter's own widgets, or use a server-side solution instead.
Thanks for django-fluent-[contents|pages], here is my small contribution https://github.com/bashu/fluentcms-teaser
PS: fluentcms-filer (django-file integration) and fluentcms-suit (django-suit integration) will be ready soon =)
During migrations, Django tries to evaluate the default value for the site
field in order to create the model.
The default is a callable that returns Site.objects.get_current().pk
. On a fresh database, no Site
object exists.
If django-fluent-pages
is also installed, its migrations will actually create a default Site
object if none exist. But when django-fluent-contents
is used on its own, this doesn't happen.
Perhaps the make_site
code from django-fluent-pages
should be abstracted into django-fluent-utils
and called by fluent_contents.plugins.sharedcontent.utils.get_current_site_id()
?
I can't figure out from the docs how go do this (or if this is possible). I have models like so:
class Slider(models.Model):
name = models.CharField(max_length=128)
class Slide(models.Model):
parent_type = models.ForeignKey(ContentType)
parent_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
content = PlaceholderField("slide_content")
and an admin.py file:
class SlideInline(PlaceholderEditorInline):
model = Slide
extra = 1
class SliderAdmin(PlaceholderFieldAdmin):
inlines = [SlideInline, ]
(I've left out the imports and registration), but this doesn't seem to work. Is this possible?
In a new virtualenv:
pip install Django==1.7.8
mkdir example.com
django-admin.py startproject "myexample" "example.com" -e "py,rst,example,gitignore" --template="https://github.com/edoburu/django-project-template/archive/django-fluent.zip"
cd example.com
pip install -r requirements.txt
Then I edit settings.py to set the DB to sqlite because I don't have a handy PostgreSQL. Then:
cd example.com
python manage.py migrate
does a bunch of init and migrations until it errors with:
Applying rawhtml.0001_initial... OK
Applying redirectnode.0001_initial... OK
Applying sessions.0001_initial... OK
Applying sharedcontent.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/nobackup/rowlings/Env/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
Then more lines of traceback, ending with:
TypeError: int() argument must be a string or a number, not 'Site'
I don't know if this is because I'm using the sqlite DB backend, or some other problem...
Given a url https://soundcloud.com/vvv/faded-inscription-feat-bvitae
, the following error is raised: ValueError: invalid literal for int() with base 10: '100%'
.
The underlying issue seems to be that soundcloud's oembed implementation[0] differs from the spec[1], and they return a string which cannot be coerced to an int.
They return 100%
for the width
field, unfortunately the respective field on the fluent-contents model is an IntegerField
and the coercing fails.
[0] https://developers.soundcloud.com/docs/oembed#introduction
[1] http://oembed.com/#section2 2.3.4.4.
The rich type
Using Django 1.5 (I had separate problems with 1.6).
I'm not sure what you are expecting to compare here, but these libraries are all returning basestring types which will never be an instance of SafeData.
Both Markdown and reStructuredtext are raising the ImproperlyConfigured error, but both are installed correctly and returning the rendered string as they should.
fluent_contents.plugins.text.appsettings
was removed. We were importing this in our code, which broke with the latest version, and there's no mention in the changelog.
Looks like these were moved to fluent_contents.appsettings
, but at least a mention in the docs and ideally keeping it available at the old location with a deprecation warning would be great.
Besides Pygments, other backends can also be supported. e.g.
The task I'm working on naturally leads me to desire to have nested content items.
It is not difficult to change base class for
class ContentItemMetaClass(PolymorphicMPTTModelBase)
and
class ContentItem(with_metaclass(ContentItemMetaClass, CachedModelMixin, PolymorphicMPTTModel))
but then there is a problem to set relationship between page's contentitems in admin
also, MPTTModel adds it's own 'parent' field so there is either need to completely replace ContentItem placeholder parent field or to combine this field with mpttmodel parent field so that
mptt parent field is used to track tree relations of ContentItems for output for real world page and placeholder parent field is used to keep admin page presentation of ContentItem blocks )
after combining placeholder field mptt parent field also appears in ContentItemForm in admin page, but apparently without additional efforts is non-funtional such that mptt works as usual linear container for ContainerItems
And I have a question to the author, if he considers viable addition of tree relationships to ContentItems and how he would approach setting root node for the page and setting specific relations between ContenItems via setting parents for ContenItems using 'mptt parent' drop down which appears in admin blocks ( maybe providing queryset to dropdown which consists of all objects in given placeholder )
As a first attempt
I tried to add children to 'root' tree content Items via form ModelMultipleChoiceField by adding to derived Form from ContentItemForm
with lines like
localchildren = forms.ModelMultipleChoiceField(widget=FilteredSelectMultiple("Children", is_stacked=False),queryset= ...)
but failed to find a way to pass to Form required queryset which could consist of ContentItems in current placeholder and which could allow to build trees manually from selected data
(edit: one afterthought here is that the solution would be easier if there was way to connect model and form directly in content plugin code )
But still seems setting mptt parent to ContentItem via autogenerated ContentItemForm field might provide a relatively easy way to build a tree of ContentItems -
the question is - how better to approach this task.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.