Django-MPTT, how to - django-admin

Hey, I have just installed the django-mptt lib, but i don't know how to get it to work :(
I have added
from mptt.models import MPTTModel
class Category(MPTTModel):
slug = models.SlugField(max_length=200, unique=True)
name = models.CharField(max_length=100)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
It that works fine
-
But when i go to the Django Admin page of my site i got an error:
TemplateDoesNotExist at /admin/search/category/
admin/mptt_change_list.html

Googling this error message brought me here.
In my case solution was to simply add 'mptt' to INSTALLED_APPS for template loader to find admin/mptt_change_list.html

pip install django-mptt --upgrade solved the problem for me. There is a closed issue about this here: https://github.com/django-mptt/django-mptt/issues/23

Had the same problem whith mptt installed with easy_install. Had to force unzipping:
easy_install --always-unzip django-mptt-0.5.5.tar.gz

I managed to get the same error (0.5.5). You also have to add 'django_mptt_admin' to INSTALLED_APPS.
Phillip.

In settings.py from Django 1.4, TEMPLATE_LOADERS had eggs.Loader commented out by default.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
Uncommenting eggs.Loader allowed the four admin templates stored in
python/virtenv/lib/python2.7/site-packages/django_mptt-0.7.4-py2.7.egg
to be found.

Related

TYPO3 dependency injection with mpdf/mpdf

I'm currently upgrading a TYPO3 extension from v9 to v10 which uses mpdf/mpdf.
In Services.yaml I've added
mPDF\:
resource: '../../../../../vendor/mpdf/mpdf/'
But now I end up with this error message:
Expected to find class "mPDF\MpdfException" in file
"/var/www/xxxx/vendor/mpdf/mpdf/MpdfException.php" while importing
services from resource "../../../../../vendor/mpdf/mpdf/*", but it was
not found! Check the namespace prefix used with the resource.
The problem is, that the class is MpdfException and not mPDF\MpdfException.
I tried to add
MpdfException\:
resource: '../../../../../vendor/mpdf/mpdf/'
This didn't work.
Next I tried to add this to the global composer.json:
"autoload": {
"psr-4": { "mPDF\\": "vendor/mpdf/mpdf/" }
}
but that didn't work either.
Many thanks for your effort to help me, Julian! Much appreciated! It turned out that the extension had a requirement for an outdated version of mPDF. After using the latest version of mPDF it now works. Nevertheless I still need Services.yaml.

OperationalError: no such module: fts4

Hi I´ve tried to run a fuzzymatcher code and the error below pops up:
OperationalError: no such module: fts4
Any suggestions? Thanks in advance
Edit: I've already tried downloading the sqlite zip from the website and saving it in DLLs files but it still does not work. Do I have to activate it somehow?
I´m using Anaconda3 64 bit.
Thanks
Confirm that the DLL files have been added in the correct place; if you are using Windows it will be C:\ProgramData\Anaconda3\DLLs.
you can try to load the extensions:
import sqlite3
conn = sqlite3.connect(':memory:')
cur = conn.cursor()
conn.enable_load_extension(True)
for (val,) in cur.execute('pragma compile_options'):
print (val)
It will show some results similar to these:
COMPILER=msvc-1500
ENABLE_BYTECODE_VTAB
ENABLE_COLUMN_METADATA
ENABLE_DBSTAT_VTAB
ENABLE_FTS3
ENABLE_FTS4
ENABLE_FTS5
ENABLE_GEOPOLY
ENABLE_JSON1
ENABLE_RTREE
ENABLE_STMTVTAB
MAX_TRIGGER_DEPTH=100
TEMP_STORE=1
THREADSAFE=1
As mentioned by #Ahmed and #Jeremy in the previous answer,
Confirm that the DLL files have been added in the correct place
However, make sure that it is indeed the correct place. For example, if you're working in a virtual environment, the location is not C:\ProgramData\Anaconda3\DLLs.
Check where python is installed to find the correct place.
You can copy the downloaded sqlite files in C:\Users\ (usernamefolder)\anaconda3\DLLs and check for the enabled extensions using the following syntax in jupyter notebook.
import sqlite3
conn = sqlite3.connect(':memory:')
cur = conn.cursor()
conn.enable_load_extension(True)
for (val,) in cur.execute('pragma compile_options'):
print (val)
This will give the list of extensions which are enabled and FTS-4 will be one of them. In case you tried and it still hasn't been enabled you can uninstall and reinstall anaconda package and try repeating the procedure.
This is what worked for me
install this in anacoda prompt using the comand below
conda install -c conda-forge sqlite-fts4

Has anyone figured out setting up custom snippets on AWS Cloud9?

I've come across a few posts online but still befuddled and nothing concrete. Maybe someone can decode the below for me, seems like they figured it out but I've never made a plugin before so not sure where to start. Maybe can outline a file structure and I can take it from there? Thanks in advance
https://community.c9.io/t/snippets-not-working-in-c9/19215/3
I could not get plugins to load using the external url method, but loading plugins locally works.
You need to create a new plugin
mkdir -p ~/.c9/plugins/myPlugin/snippets;
cd ~/.c9/plugins/myPlugin/snippets;
printf '# scope: javascript\nsnippet test\n\tif (${1:true}) {\n\t\t${2}\n\t}\n\t$0' > javascript.snippets;
echo '{"name":"myPlugin", "plugins": {}}' > ../package.json
Then open your init script (click on AWS Cloud9 > Open Your Init Script in the menu bar) and add code for loading the plugin
services["language.complete"] = services["languageComplete"];
services.pluginManager.loadPackage([
"~/.c9/plugins/myPlugin/package.json",
])
To add more snippets edit ~/.c9/plugins/myPlugin/snippets/javascript.snippets
NOTE: snippet file needs to be indented with tabs not spaces
I pieced this together from the two links below.
How to load plugins locally: https://community.c9.io/t/snippets-not-working-in-c9/19215/3
Fix for AWS not loading snippets: https://forums.aws.amazon.com/thread.jspa?threadID=299949&tstart=0

Angular 4+ 3rd party module import 404 error with base tag

I am putting an angular portion into my MVC app. As such, I have added a tag to my layout view to find the Angular source code, and this is working great.
My issue arises in trying to add a 3rd party module to my project. I added it through the package.json with no problem, and added the module to my app.module.ts as follows:
import { FileUploadModule } from 'primeng/fileupload';
The reference is found, Visual Studio is happy, everything is fine. However, when I run the project locally, I get the following 404 error:
GET http://localhost:59911/src/primeng/fileupload 404 (Not Found)
It seems to me likely that the tag is causing the issue, but I can't remove it without killing the rest of the Angular functionality. Any hints? Can I add an override to the imports call?
Thanks, Mike
On PrimeNG's official website they suggested using import { FileUploadModule } from 'primeng/fileupload'; but it doesn't work any more. I guess they didn't update the docs.
You need { FileUploadModule } from 'primeng/primeng';
The structure is
In the primeng.d.ts file PrimeNG re-exported all modules.
export * from './components/fileupload/fileupload';
For now, no matter which PrimeNG module is used, it is all from primeng/primeng. Here's the imported modules in my project:
import {
ButtonModule,
CodeHighlighterModule,
ConfirmDialogModule,
FieldsetModule,
FileUploadModule,
GrowlModule,
MessagesModule
} from 'primeng/primeng';
The version I use is "primeng": "^4.2.1"
The issue was that primeng was not in the mapping, so it was looking for it in src.
I added the following to systemjs.config.js:
in maps:
'primeng': 'npm:primeng',
in packages:
primeng: {
defaultExtension: 'js'
}
Thanks for the help everyone!

Pylons + mod_wsgi -> ImportError: No module named paste.deploy

I'm following the example here: http://code.google.com/p/modwsgi/wiki/IntegrationWithPylons
however, it doesn't work - I get "ImportError: No module named paste.deploy" in the apache error log. Googling in this case helps not - I see some stuff about permissions, but all my permissions are fine. Where does paste.deploy really come from? It comes from PasteDeploy-1.3.4-py2.6.egg in site-packages, installed in my pylonsdevenv directory, right? Well, then how is apache supposed to know about that directory? Does the actual pylons project have to be in the pylonsdevenv directory?
thanks!
I added:
import site
site.addsitedir('/<yadayada>/pylonsdevenv/lib/python2.6/site-packages')
to the top of my wsgi file, and then set debug = False in my development.ini file (and later, deployment.ini file, I presume), that seemed to work...
If you can import (from paste.deploy import loadapp) manually it has to be a problem with sys.path. Also make sure that apache uses proper python interpreter. I have something like this in my "passanger_wsgi.py" on Dreamhost:
INTERP = "/home/myuser/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
cwd = os.getcwd()
sys.path.append(os.getcwd())
sys.path.append('/home/myuser/blog')
You can try put some debug and check which paths are inside "sys.path".
Hope this helps.

Resources