compiled django application fails to run ASGI channels - django

I'm building a django application using Pyinstaller.
When I run the application i get an error from dapne server.
"daphne\server.py:13: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on."
In addition, when I compare the console log of the EXE application and a regular run of the django application I notice the following difference.
In the regular run which works as expected I see the following print:
"Django version 2.1.5, using settings 'cfehome.settings'
Starting ASGI/Channels version 2.1.5 development server at http://0.0.0.0:8000/"
however, when I run the application from the EXE I see:
"Django version 2.1.5, using settings 'cfehome.settings'
Starting development server at http://0.0.0.0:8000/"
Appreciate any lead to understand this behavior and ways to fix it.

I know this is old but for others seeking answer. There's a simple fix:
Before importing raven in settings.py, import daphne.server So, your settings.py will look like this:
import daphne.server
import raven
For further information you can read: https://github.com/django/channels/issues/793
I hope it will help.

Related

Apache webserver with app using GDAL not working on windows

I am trying to deploy a django project using POSTGIS on my windows 11 PC with Apache 2.4.
The web page is working as long as I am not using 'django.contrib.gis'.
When I add 'django.contrib.gis' to my INSTALLED_APPS and define GDAL_LIBRARY_PATH to point to my gdal installation things stop working.
Specifically, trying to access the web app ends up in infinitely loading the page. Weird enough there are no errors in the apache error log. The apache service starts fine.
As far as I can see gdal install is correct as the app is working fine on the same machine with the same python environment with the django development server.
Actually, I have the same issue with other python libraries that need some dlls, like opencv.
So my guess is that it is a security related issue, but I do not find any clues on how to solve it.
Any ideas?
I tried also to grant rights to the directory where gdal is install in apache conf. But no luck.

My demo django project doesn't start server after a restarting command prompt

I have created demo django project, now I cant run the server. I'm getting "ImportError: Couldn't import Django" I dont know what I'm missing.
You must install Django. The error is about this. Maybe you installed django on a virtual environment and you have deactivated it?

Error with django-registration module: AppRegistryNotReady("Models aren't loaded yet.")

I am having a problem getting the Django registration module to work. I am relatively new to Django, having only worked through a few examples, now wanting to rebuild a site using user registration, that I've previously made with python.
I am using Python 2.7, Django 1.7.1, and my operating system is Ubuntu 14.04. I'm also using Eclipse/PyDev for my IDE.
I keep getting the error message:
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
I have installed both the django-registration and django-registration-redux modules, understanding that there may issues with installing django-registration in Django 1.7. Should I copy the registration module directly into my app, although not advised, but for troubleshooting? Should I uninstall something before I install a new package?
The django-registration module resides in "/usr/local/lib/python2.7/dist-packages." I'm not sure where the django-registration-redux module should have ended up at, although it deposited "django_registration_redux-1.1.egg-info" with the dist-packages.
I have added 'registration', to the settings file, and to my urls' file pattern I've added: (r'^accounts/', include('registration.backends.default.urls')),
I've read numerous on-line postings about this issue, but I can't get around this block. Should I uninstall Django 1.7.1, and install Django 1.6 to avoid this impasse?
Thanks,
Walter Goedecke
Have you considered using django-allauth instead of django-registration?
As I understand it, django-registration is no longer being maintained.
Were you able to resolve this?
When you say “I have installed both the django-registration and django-registration-redux modules”, do you mean you are trying to use both at the same time, or you tried one and then the other? You should only be using django-registration-redux, I believe django-registration stopped being maintained during one of the Django 1.6 releases, maybe it was 1.5 don’t recall. If its of any help, we have Django 1.7.9, Django 1.8.1, and Django 1.8.3 working with django-registration-redux 1.1.
It sounds like you are installing your python packages system wide (you said its residing in /usr/local/lib/python2.7/dist-packages). There is a great tool called virtualenv that lets you keep all of your projects isolated, in their own virtual environment with their unique dependences. This way one project can be using django 1.5 while another is using django 1.7, one project can use django-registration-redux while the other uses allauth, etc. The other great thing about it, is that it makes your projects more portable, easier to share, and easier to update.
If you haven’t tried it yet, you should check it out!
http://docs.python-guide.org/en/latest/dev/virtualenvs/
I found this link very helpful when I was first getting started with Python and Django development:
http://www.jeffknupp.com/blog/2013/12/18/starting-a-django-16-project-the-right-way/

import error using djangorestframework with django-nonrel

I'm working on a Django-nonrel project using Django-rest-framework and I've run into the following error after following the instructions in the Token Authorization section of their Authorization API Guide:
ImportError: No module named rest_framework.authtoken
Normally I would just assume that this is something to do with my PYTHONPATH but I don't think that's exactly what the problem is because I can import this framework from both IDLE and the project's shell run using manage.py, the latter both with and without a virtual environment. Within the virtual environment I have installed django and djangorestframework, which should be the only requiremnets for the project thus far.
I had thought that it might have been a Python versioning problem but given that I can import the package directly from the project's shell (running under the virtual env) I'm kind of at a loss since theoretically running manage.py from the same virtual environment should result in the same context for locating libraries.
I've spent a long time searching around trying to fix this issue but to no avail. Any suggestions? I'm happy to provide any additional information as needed!
A few things to check:
Are you sure you are using the directory one level above rest_framework in your PYTHONPATH?
Did you restart your shell after installation?
Take a look at VirtualEnv PYTHONPATH setup. Did you try setting the PYTHONPATH for virtualenv explicitly?

No module named filterspecs

In eclipse,when i create new project, i got an error like,
Error creating Django project
settings.py file not created
Stdout:
Stderr:
If i synchronize present project and runserver, iam getting Error: No module named filterspecs.But i haven't used filterspecs in my project. Already filterspecs.py installed in usr/local/lib/python2.7/dist-packages/django/contrib/admin.
Kindly advise to rectify the error.
You may be using django.contrib.admin.filterspecs to create custom filters for your admin pages, such as outlined here:
Custom Filter in Django Admin on Django 1.3 or below
Unfortunatelly, you will have to rewrite these using the new list_filter module functionality.
See the manual here:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter
This happened to me as well, even though my code wasn't directly using any filterspecs.
Run python manage.py runserver --traceback to see exactly where the error is coming from.
This module was removed in Django 1.4, but other external modules you have listed in your settings.py might still be using it, so make sure you upgrade everything in your INSTALLED_APPS list. In my case, I was using an outdated version of FeinCMS, but after I upgraded it, the error went away.
Obviously, your system is lacking filterspecs module which is required by the project. Install it by typing sudo pip install filterspecs in the console (if you are on linux)