from django.db import models
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=256)
pub_date = models.DateTimeField()
image = models.ImageField(upload_to='media/')
body = models.TextField()
def __str__(self):
return self.title
def pub_date_pretty(self):
return self.pub_date.strftime('%A %d %B %Y @ %-I:%M:%S %p')
def summary(self):
return self.body[:350]
primary :: 91-907 529 6235
I didn’t do a very good job explaining. Let me try again.
If you take a look at this image of Blogger, the red arrow points to the formatting bar. The formatting is a helpful feature in Blogger which allows blog posters to add an essay worth of content, and then alter the appearance of the Lorem Ipsum essay content with bold, italics, underline and a few dozen other buttons and options.
Then when you click the HTML button in the Blogger dashboard, it shows you the same Lorem Ipsum content, but just the raw HTML source.
Thank you, Jason. The WYSIWYG editor like ckeditor is precisely what I am looking for.
I have set out to run ckeditor. I am following along with the instructions on how to install it.
Inside my virtual environment I invoke pip install django-ckeditor.
Then I add ckeditor to INSTALLED_APPS in settings.py.
But then my shell is telling me that I have improperly configured static root in the files app even though my settings.py does include a line: STATIC_URL = '/static/'
The installation doc linked to above does refer to the official Django doc on how to manage static files, which I find to be helpful but isn’t really very applicable to my particular situation because I do not have any image files that I am working with in my case at this point.
When I run python3 dobbs_portal_blog/manage.py collectstatic, I get this error:
$ python3 dobbs_portal_blog/manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings.
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "dobbs_portal_blog/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 199, in handle
collected = self.collect()
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 124, in collect
handler(path, prefixed_path, storage)
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 354, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 260, in delete_file
if self.storage.exists(prefixed_path):
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/core/files/storage.py", line 392, in exists
return os.path.exists(self.path(name))
File "/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/subgenius-blog-env/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 50, in path
raise ImproperlyConfigured("You're using the staticfiles app "
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
(subgenius-blog-env) gnull at gnosis in
$
The official Django docs specify that STATIC_ROOT is indicated in settings.py at the STATIC_URL variable (which is near the bottom). The official Django docs says:
Configure your web server to serve the files in STATIC_ROOT under the URL STATIC_URL.
(link)
I’m not running Apache. My Django serving is running locally. The absolute path in my file tree to my Django root directory is:
/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/dobbs_portal_blog/
Inside dobbs_portal_blog is where I placed the static folder. Therefore, the line in my settings.py where I declare the variable, I changed from the default:
STATIC_URL = '/static/'
STATIC_URL = '/home/gnull/Dropbox/TECH/python/2017/django-experiment-with-nick/dobbs_portal_blog/static/'
That is my best guess at attempting resolve the “pretty obvious” error message:
You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
Yet I am still doing something wrong because invoking python3 dobbs_portal_blog/manage.py collectstatic, I still get the same message:
Hello,
First of all: If you are just starting to learn, and because the amount you have to learn can be overwhelming, I'd suggest to not care about the wysiwyg editor at this stage. Pretend that your users can enter HTML in the field, and do all the rest. After you get some understanding of static files, only then come back to this issue.
But to (prematurely) answer your question, if you have DEBUG=True and running django with manage.py runserver, you shouldn't need to care about STATIC_ROOT and STATIC_URL and collectstatic. Just forget about them. When the time comes to deploy your application and turn DEBUG off, then you will need to understand how static files work in production.
Regards,
Antonis
Antonis Christofides http://djangodeployment.com
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/58a7a563-48a2-415e-9cb2-d59330129745%40googlegroups.com.
<h1>Lorem Ipsum</h1>
<strong>Hello and welcome to my first blog post</strong>
> <mailto:django-users+unsub...@googlegroups.com>.