I use django-wiki app :
https://django-wiki.readthedocs.io/en/main/
I try to replace the base editor.
The default param for editor is :
wiki.conf.settings.EDITOR = 'wiki.editors.markitup.MarkItUp'
I installed Martor (Markdown Editor plugin for Django) :
https://github.com/agusmakmun/django-markdown-editor
I don't know how properly load it.
I tried
import martor
wiki.conf.settings.EDITOR = 'martor'
and catch this error :
ImportError: Could not import 'martor'. The path must be fully qualified.
I tried also many things and catch differents errors.
How properly change the django-wiki editors config ?
Thanks for reading.
ps: I use the last version of all packages (in a virtualenv)
Linux Mint 21
Python 3.10.4
django 4.0.7
Markdown==3.3.7
martor==1.6.14
wiki==0.9
EDIT
regarding the documentation of django-wiki :
The following settings are available for configuration through your
project. All settings are customized by prefixing WIKI_, so for
instance URL_CASE_SENSITIVE should be configured as
WIKI_URL_CASE_SENSITIVE. For plugins the prefix is WIKI_PLUGINNAME_,
e.g. WIKI_IMAGES for the images plugin.
the param must be :
WIKI_EDITOR = 'SOMETHING'
But the error steal the same with this way of import.
Related
Am new to Flask development and am using an IDE like Pycharm for the first time, so please pardon the ignorance.
So while playing around with a project that I am working on to understand Flask, I created a virtual environment by the name venv. So the tree of my project would look something like :
my_project_directory
Project_specific_directories_and_files
requirements.txt
venv
To activate the virtual env, I used to do venv/bin/activate and my project would run as needed.
I came across virtualevnwrapper later and decided to use that. After installing it and setting it up, I moved over to the virtualenvwrapper way of working with virtual envs and completely removed(deleted) the venv directory from my project structure. The new project structure after deleting venv is as :
my_project_directory
Project_specific_directories_and_files
requirements.txt
Everything works fine. The project runs as expected.
However, now after the venv directory was removed, when I open my project in Pycharm, for my import statements like :
from flask import Flask, render_template, redirect, url_for, request, session, flash # , g
from flask_sqlalchemy import SQLAlchem
all the packages that I try importing gets underlined as error in the Pycharm IDE. I opened the Python console, in Pycharm, trying to debug the error and it gives the following error :
Error:Cannot run program "/Users/my_user_name/Desktop/some_parent_directory/my_project_directory/venv/bin/python" (in directory "/Users/my_user_name/Desktop/some_parent_directory/my_project_directory"): error=2, No such file or directory
Now I thought that apparently Pycharm is still using it's cache. So I tried invalidating the cache and restarting Pycharm as explained here, but the problem was still there.
Now I have 2 questions:
Why is Pycharm behaving this way? I removed the venv directory completely etc. Why is it still referencing the old (venv) location?
If it really is not able to resolve the dependencies, how exactly then is my project running all fine? Shouldn't it break the app?
Ok. After some further digging now, I was able to get the errors flagged in Pycharm rectified. I went to Pycharm -> Preferences -> Project: my_project_directory -> Project Interpreter & found that it was 'for some reason' still pointing to the older venv directory. From the drop down of the 'Project Interpreter:' section, I chose the path to my virtualenv created by virtualenvwrapper & saved the changes by Apply->Ok. This removed the error indications from the code in Pycharm. Although solved, the mystery of what/why was this happening is still unsolved for me. – qre0ct Jul 12 at 17:13
Moreover, I also removed the unused/deleted interpreters from the list of project interpreters by going to the 'more' section in the 'Project Interpreter' part and using the '-' at the bottom to remove the ones not needed.
I've just started developing a new application using Flask and PyCharm as my IDE.
I've encountered a problem which is driving me crazy.
Here is the code. I'll spare use all the import part and so on, I'll show only the routes that cause problems.
#app.route("/")
def home():
return render_template("home.html")
#app.route("/login/")
def login():
return "foo"
The first route works without a problem. However on the first line of the second route, PyCharm gives me an error message '"#" or "def" expected'. This breaks the autoindent and the auto completion features.
But the code runs without a problem.
Can anyone tell me how to fix this?
Thank you
This is because PyCharm is not able to recognize the flask package or version.
Once you add new project to PyCharm -
Go to File menu item
Click on Settings option
This will open-up the pop-up window.
In the left-hand-side link list - click on the project name
Click on the Project Interpreter link
In the right-hand-side pane select Flask and related packages that your project needs and add/install the same.
What worked for me was (I was missing pycharm's python environment dependencies for python)
If you don't already have a requirements file for your project.
Navigate to your project & this on your command line (as I used a venv virtual environment):
(venv)$ pip freeze > requirements.txt
Then Open your pycharm and open the requirements file, wait a second or two and a pop up notification will show up at the top showing you are missing dependencies and will provide you a click here to install.
After that I had no issues.
I'm trying to get an existing Django project to work on my mac.
I managed to configure everything and opening the project in PyCharm.
When I run I get the error:
TemplateSyntaxError at /
Caught BundleError while rendering: 'stylesheets' not found (using staticfiles finders)
We use Django 1.3 and Webassets 0.7 (just updated from earlier versions).
I have an assets.py defined in my application folder defining the various bundles.
Any suggestions on solving this?
EDIT: Ok, a bit further ... I added my project.assest to settings and now I don't have the Bundle error. I do still have another problem:
Caught BundleError while rendering: 'styles/libs/jquery-ui-timepicker-addon.css' not found
Path look ok, collectstatic works, copies, file is in place ...
any suggestions?
A project-wide assets.py (as opposed to one in an app-directory) is no longer automatically read, you need to define such files through a ASSETS_MODULES setting now.
If you are using staticfiles, pay attention to the fact that the staticfile finders will not be used unless Django is in debug mode (settings.DEBUG=True). In production mode, webassets will assume that collectstatic has been run first.
In settings.DEBUG=True mode, the reverse is true: ONLY the Django staticfile finders will be used. You could try opening a shell (./manage.py shell) and see if the following finds your file:
from django.contrib.staticfiles import finders
finders.find('styles/libs/jquery-ui-timepicker-addon.css')
If it does, then so should webassets.
I had a similar error arise
'[BUNDLE_NAME]' not found (using staticfiles finders)
This wasn't a very helpful message, so ended up looking into ./manage.py shell and running
>>> from django.conf import settings
>>> from [ASSETS_FILE_PATH.assets] import [BUNDLE_NAME]
>>> [BUNDLE_NAME]
If this isn't there it may give you another message.
I've upgraded to PyCharm 2.5 and in the meantime upgraded django-templated-email to version 0.4.3.
Now, Django unit tests do not longer work through PyCharm, as I'm getting the error ImportError: cannot import name send_templated_mail in the test console output.
When running the same test in the console, this error does not appear. I have the feeling that it has something to do with send_templated_email being part of templated_email\__init__.py (I vaguely remember a similar issue once, but cannot for the life of me remember how I fixed it).
The settings in the test dialog are:
Target: <django app name>
Custom settings: <path to dev settings>
Environment variables: PYTHONPATH: <path as set in virtualenv>
Python interpreter: <virtualenv Python interpreter>
Interpreter options: None
Working directory: <path to Django project (where manage.py resides)>
The strange thing is that the code inspection inside the IDE does not complain and loads the templated_email module correctly through from templated_email import send_templated_mail.
I'm using Windows 7, and my Django app is running inside a virtualenv (which is correctly being recognized by PyCharm).
I would suggest upgrading to version 4.5.x if you haven't already. It fixes lots of bugs and has several improvements.
Also, if you think this is a bug in PyCharm, check out their bug tracking/filing site:
https://youtrack.jetbrains.com/issues
I am trying to move a django project to google appengine. So I followed http://code.google.com/appengine/articles/django.html . But
django.dispatch.dispatcher.connect(
log_exception, django.core.signals.got_request_exception)
django.dispatch.dispatcher.disconnect(
django.db._rollback_on_exception,
django.core.signals.got_request_exception)
was giving me error saying can't find dispatcher.connect/dispatcher.disconnect . So I changed the code as
django.dispatch.dispatcher.Signal.connect(
log_exception, django.core.signals.got_request_exception)
But now , when I am running the application , I am getting following error
*File "C:\Program
Files\Google\google_appengine\google\appengine\tools\dev_appserver.py",
line 2208, in ExecuteOrImportScript
exec module_code in script_module.dict File
"C:\Personal\Study\Python\twtApp\src\main.py",
line 23, in
import django.dispatch.dispatcher.Signal
ImportError: No module named Signal*
As it's said the google article , I have copied django folders to top level folder of my projects .
Is there anything I am missing ?
Pls help ..
Your issue lies in Python being unable to import the Signal module. Make sure it's properly in your path, and that it isn't somehow missing from your Django install.
I would strongly recommend that you use the google-app-engine-django project instead. You'll have a lot more luck.
http://code.google.com/p/google-app-engine-django/