6๐
In the videoโs comments you can get the answer. Modify the next files:
models.py
from django_markdown.models import MarkdownField
...
body = MarkdownField()
settings.py
...
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
# Markdown
MARKDOWN_EDITOR_SKIN = 'simple'
urls.py
...
from yourapp import settings
if settings.DEBUG:
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
In shell run:
python manage.py collectstatic
1๐
I have same problem. However, when I add Mr. iago1460โs code without the urls.py
part,after I run:
python manage.py collectstatic,
the django_markdown
can work ,I use python 2.7 and django 1.8 version
the urls.py code here
from django.conf.urls import include, url
from django.contrib import admin
#import settings
#if settings.DEBUG:
#from django.conf.urls.static import static
#urlpatterns += static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
urlpatterns = [
# Examples:
# url(r'^$', 'cblog.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^markdown/', include("django_markdown.urls")),
url(r'^',include('blog.urls')),
]
here is my project files ,my project name is cblog ,app is blog:
djtest/cblog/cblog:
__init__.py __init__.pyc settings.py settings.pyc urls.py urls.pyc wsgi.py wsgi.pyc
djtest/cblog:
blog cblog db.sqlite3 manage.py static
- [Django]-Django on CentOS
- [Django]-Logging Django Haystack search keyword
- [Django]-Generating a date relative to another date in Django template
- [Django]-File Upload in Django modelForm
1๐
Yeah i found this problem too when i was trying qblog tutorial. iโm using Python 3.4 and Django 1.8.1, But on the step to install markdown package, i decide to change the package into Django CKEditor.
Visit https://pypi.python.org/pypi/django-ckeditor to install.
After CKEditor has been installed properly, if you find the problem in import forms.util flattat when you are running the server.
Change your widgets.py under ckeditor folder (on windows environment the directory is under C:\Python34\Lib\site-packages\ckeditor), then change the line :
from django.forms.util import flatatt
to
from django.forms.utils import flatatt
Follow in how to use CKEditor then implement it on your qblog.
The result will be like this :
- [Django]-Django query for all items from today
- [Django]-Unit Testing Django Model Save Function
- [Django]-Invalid block tag: 'endblock' django
- [Django]-How to do something when I change a field in Django admin for a model?
1๐
Try this easier way:
in admin.py :
from django_markdown.admin import MarkdownModelAdmin
from django_markdown.widgets import AdminMarkdownWidget
from django.db.models import TextField
class EntryAdmin(MarkdownModelAdmin):
... #your_code
formfield_overrides = {TextField: {'widget': AdminMarkdownWidget}}
admin.site.register(models.Entry, EntryAdmin)
0๐
This happens when you are using python 2x
Now,what happens is that the stylesheets and javascript are not loaded
So what you can do is:
from django_markdown.widgets import AdminMarkdownWidget
from django.db.models import TextField
class EntryAdmin(MarkdownModelAdmin):
list_display = ("title", "created")
prepopulated_fields = {"slug": ("title",)}
# Next line is a workaround for Python 2.x
formfield_overrides = {TextField: {'widget': AdminMarkdownWidget}}
and this will work!!!!!!!!!!!!!
0๐
Python 2.x You need add that:
formfield_overrides = {TextField: {โwidgetโ: AdminMarkdownWidget}}
- [Django]-TypeError: add() argument after * must be a sequence, not Subscribers
- [Django]-Serve media files with Django on production server
- [Django]-Djangoโ Deactivate User account instead of deleting it