The below is a way to troubleshoot a potential error that may stop to continuation of the course. Mitch will address this in a future video of this playlist If you are using an newer version of Django (mine is 3.2.16) than the one presented in this tut and encounter this error: "SuspiciousFileOperation at /admin/blog/blogpost/add/ Detected path traversal attempt" You can solve by using this snippet: from django.core.files.storage import default_storage import os def upload_location(instance, filename): base_path = 'blog' author_id = str(instance.author.id) title = str(instance.title) file_path = os.path.join(base_path, author_id, title, filename) return default_storage.path(file_path)
Hi Mitch, First of all thank you for such a great content. I have one doubt regarding how can we use multiple images in a single Blog Post. I know some of the WYSIWYG editor like ckeditor or tinymce but I want to know other alternative ways of doing the same. Looking forward for your reply on this.
yeah found a workaround, probably not the best way, but just pass string as variable to template and use {{variable_name | safe}} for parse it as html you will have to hard code links of stylesheets or JS or images of this html page to static folder yourself
i have followed the same steps and but i can't see the blog in my admin page and i have applied all the migrations and don't see any error while running the server
Great content, thank you! I am interested in joining your channel as a "Member", but please tell me first: is there a possibility of asking questions for tips and advice about django, in that plan?
Woow. Great man. I am just following your since a few hours but you are just great. There is nothing more to say.
The below is a way to troubleshoot a potential error that may stop to continuation of the course. Mitch will address this in a future video of this playlist
If you are using an newer version of Django (mine is 3.2.16) than the one presented in this tut and encounter this error:
"SuspiciousFileOperation at /admin/blog/blogpost/add/
Detected path traversal attempt"
You can solve by using this snippet:
from django.core.files.storage import default_storage
import os
def upload_location(instance, filename):
base_path = 'blog'
author_id = str(instance.author.id)
title = str(instance.title)
file_path = os.path.join(base_path, author_id, title, filename)
return default_storage.path(file_path)
thanks
Your "preseave" receiver is very interesting, keep it up! forsenScoots :thump-up:
Hi Mitch,
First of all thank you for such a great content.
I have one doubt regarding how can we use multiple images in a single Blog Post. I know some of the WYSIWYG editor like ckeditor or tinymce but I want to know other alternative ways of doing the same.
Looking forward for your reply on this.
i am looking for the same answer, if u find anything, pls let me know
yeah found a workaround, probably not the best way, but just pass string as variable to template and use
{{variable_name | safe}} for parse it as html
you will have to hard code links of stylesheets or JS or images of this html page to static folder yourself
Really helpful.
i have followed the same steps and but i can't see the blog in my admin page and i have applied all the migrations and don't see any error while running the server
Make sure...u have registered it in your admin.py
same
Great content, thank you! I am interested in joining your channel as a "Member", but please tell me first:
is there a possibility of asking questions for tips and advice about django, in that plan?
Sir....I m getting integrity error...Foreign key constraint failed
Can you post the entire error? Then I might be able to help.
my image file is not getting displayed.a bunch of numbers are getting instead.help me out .thanks.
1st