Dajaxice Autodiscover in Django App (cannot import name dajaxice_autodiscover) - python

I was following the directions at http://django-dajaxice.readthedocs.org/en/latest/installation.html to install Dajaxice for simple AJAX support and I ran into an error I can't quite figure out. The lines:
from dajaxice.core import dajaxice_autodiscover
#dajaxice_autodiscover()
in urls.py seem to be causing an error (cannot import name dajaxice_autodiscover). When I look at the module files for Dajaxice I don't see one for autodiscover either. If I leave out these lines, will I have any troubles using dajaxice? Thanks.

The import should be correct like that! dajaxice_autodiscover imported in __init.py__ of the core package, so it is supposed to work like that! More likely the whole app is probably installed in a wrong path, you could try to open a shell (python manage.py shell) and try import dajaxice and see what happens!

William What version of dajaxice do you have? the "registration approach" documented in github wiki work with dajaxice>=0.1.5
For older versions of dajaxice you should register your functions in settings.DAJAXICE_FUNCTIONS.
Anyway newest versions of dajaxice has less bugs.

It looks like the wiki installation instructions are ahead of the available downloads. If you pull the latest version of the code from git and install that then the instructions work. I'm not sure how to install versions 1.4 and below though.

I experienced the same problem and I found the solution.
It all about environment vairables in windows. You set following via CMD:
set DJANGO_SETTINGS_MODULE 'Your django project/your site/settings.py
Now it should work fine, Good Luck!

Related

manage.py createsuperuser: AttributeError: module 'os' has no attribute 'PathLike'

I'm trying a Django tutorial. For some reason my existing superuser got deleted; creating that went fine, but I can't make another one. This also happens when I try to use pip.
I didn't change anything in the libraries so not sure why this happens now but didn't before. On windows 7 (Python 3.6.3 and Django 1.11). I've seen similar but not the exact same problems for Windows. Still I checked the file and there seems to be a PathLike class.
I've also tried to repair my Python installation but it didn't help. any ideas?
Seems like you may have modified the settings.py file. But as MrName mentioned you need to share full stack trace
This looks like a feature that changed in Python3.6 as you can see here. Make sure that your python version is 3.6 or greater.
Update your Python and Django version and that will work perfect.
AttributeError: module 'os' has no attribute 'PathLike'
Installing it into the global site-packages with the below command solved my problem:
pip install --user virtualenvwrapper

PyCharm Not Properly Recognizing Requirements - Python, Django

Often requirements show up in requirements.txt like this:
django-registration
But in INSTALLED_APPS it appears as registration. So when you import like:
from registration.signals import user_registered
This is valid but PyCharm is showing a red squiggly line under the word registration in from registration... that says "Package 'registration' is not listed in project requirements".
How can I remedy this?
UPDATE
I was able to find a way to make the warning go away but it's not a good solution. If you simply add the package name to the requirements.txt file the warning goes away, but then that requirement is not valid if you were to install with pip. For example, I'm also using pygooglevoice which is how it's written in requirements.txt but when it's imported in the code, you write:
from googlevoice import Voice
This seems weird because I use PyCharm for many projects and I'm just noticing this with a recent project I'm working on...
After seeing this phenomenon again, I did some more digging. After setting certain folders as source roots and restarting PyCharm, these reference warnings went away. I think this is a bug in PyCharm.
This seem to be an open issue
https://youtrack.jetbrains.com/issue/PY-11963
JetBrains claims that this is fixed in version 2017.2:
https://youtrack.jetbrains.com/issue/PY-11963#comment=27-2248728
I can confirm this (in IntelliJ IDEA). Also, it's worth double-checking that the correct requirements file is specified in Settings -> Tools -> Python Integrated Tools -> Package requirements file
PyCharm should be able to figure this out, but it doesn't. For now, I just add # noinspection PyPackageRequirements to each import with this warning to suppress it. I'd rather not, but it works for now.
This issue can be fixed using the following commands in the terminal (using linux, not sure if this will work on windows, but I see no reason why it shouldn't, I haven't tried on windows.)
If you haven't created a requirements.txt file already
touch requirements.txt
This should do the trick
pip freeze > requirements.txt
pip install flask
For better understanding, I recommend reading this
https://boscacci.medium.com/why-and-how-to-make-a-requirements-txt-f329c685181e

Python-Django: ImportError: no module named django

Im completely new to django and Ive been trying to set up an environment from here [https://docs.djangoproject.com/en/1.1/intro/tutorial01/]. Python was already setup on my mac
Python 2.7.2. I followed the instructions and setup django using
sudo port install py27-django
And also added /etc/paths.d/macports with
/opt/local/bin
/opt/local/sbin
/opt/local/lib/python2.7/site-packages/django/bin
But I still get the ImportError: No module named django message when I import django from the python shell.
I looked at this link
importerror: No module named django but it didnt really help much. Any help is appreciated
Have a look at this article... they are using virtualenv to set up the project and this fixed a lot of problems like this for me. With virtualenv, the system libraries and the libraries you need for your python project are separated, so your not mangling them together.
http://www.jeffknupp.com/blog/2012/02/09/starting-a-django-project-the-right-way/
If I may, it looks like the last path you added was pointing to a python2.4 directory, you might need to look for django in a python2.7 directory instead.

Running django-admin.py startproject is giving me an error

I've just started looking into python and django.. Im pretty sure ive successfull installed both python and the django framework and i managed to add python and django-admin.py to my system path but now when i run the command django-admin.py startproject My_Test_Site, in the folder i want to create a new project directory in (just following the tutorials), i get the following error:
What am i doing wrong?
This is not a Django error. It appears it cannot find the Python module unicodedata which is part of the Python Standard Library (docs). I see that there is also a bug report about this issue (Python 2.7 on Windows, see here). On the other hand, some people there report that reinstalling their Python installation fixed the problem. You could give that a try.
notice the last line, it says import unicodedata, importError
im guessing you probably didnt install your django properly.
so reinstall it and check that django is in your "path", i believe django does this automatically when it installs but doesnt hurt to double check.
if reinstalling django still doesn't work, i suggest you uninstall python and django related stuff.
then install python, install pip, then use pip install django.

Error starting Django with Pinax

Upon trying to start a Pinax app, I receive the following error:
Error: No module named notification
Below are the steps I took
svn co http://svn.pinaxproject.com/pinax/trunk/ pinax
cd pinax/pinax/projects/basic_project
./manage.py syncdb
Any suggestions?
UPDATE:
Turns out there are some bugs in the SVN version. Downloading the latest release solved my problem. If any one has any other suggestions on getting the trunk working, they would still be appreciated.
I'd avoid the svn version all together. It's unmaintained and out of date. Instead, use the git version at http://github.com/pinax/pinax or (even better) the recently release 0.7b3 downloadable from http://pinaxproject.com
Two thoughts:
1. Check all of your imports to make sure that notification is getting into the namespace.
2. You may be missing quotes around an import path (eg. in your urls.py: (r'^test', 'mysite.notification') -- sometimes I forget the quotes around the view)
Try following the latest install instructions here:
http://github.com/pinax/pinax/blob/600d6c5ca0b45814bdc73b1264d28bb66c661ac8/INSTALL
Don't think this will work on Windows (maybe if you are using cygwin) as they are using virtualenv and pip.
Note the version has recently been upgraded to 0.7rc1
IIRC I had to add a directory or two to the Python path last time I did a fresh install of Pinax. I'm doing a fresh checkout now into a new virtualenv, I'll edit this answer if I hit any snags.

Categories