Django GAE testapp tutorial - python

I'm running Windows 10 (sorry) and I'm trying to set up the django-nonrel test app for GAE from github, https://github.com/django-nonrel/django-testapp.
I've downloaded and installed it and I've also installed the various modules from Django and NoSQL on github.
So my filestructure is dbindexer, django, djangoappengine and djangotoolbox as subdirectories of testapp. I've put these in place as I've come across install errors in the log file.
I'm now getting the message
ImproperlyConfigured: Error importing module autoload.middleware: "No
module named autoload.middleware"
This is reasonable since settings.py has autoload as an installed app.
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'djangotoolbox',
'autoload',
'dbindexer',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
)
But I don't know where I find this module. I know I must be being really thick but I cannot work out how to get this running.
EDIT - here is the requirements.txt file
-e git+http://github.com/django-nonrel/djangotoolbox#toolbox-1.4#egg=djangotoolbox
-e git+http://github.com/django-nonrel/djangoappengine#appengine-1.4#egg=djangoappengine
-e git+http://github.com/django-nonrel/django-dbindexer#dbindexer-1.4#egg=django-dbindexer
-e git+http://github.com/django-nonrel/django#nonrel-1.4#egg=django-nonrel
-e hg+http://bitbucket.org/twanschik/django-autoload#egg=django-autoload
So I've downloaded this autoload and I'm now getting the following error.
ImportError: No module named fcntl

This was solved by going to a MySQL solution rather than django-nonrel. It took some time but lots on StackOverflow to help through it.

Related

Issue importing modules with Django, but runs fine when I run it independently using '-m' flag

Currently I have a python project with the following directory structure.
I can run the demo.py file directly fine (without importing it in my Django project) from the outermost directory shown above using the following command:
python -m ObjectSegmentation.segmentation_api.apps.tools.demo
However, in my Django project, I need to import the demo.py file in my django views.py file, but when I do so, I get the following error:
from ObjectSegmentation.segmentation_api.apps.tools.test import *
ModuleNotFoundError: No module named 'ObjectSegmentation'
These are the first few lines from demo.py (including line 4) where the error occurs.
My installed apps in settings.py for the whole project look like this:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.tools.demo',
'rest_framework'
]
How can I make it so that the imports work with both the project run independently and imported in my django project?

ModuleNotFoundError: No module named 'project.user'

If anyone knows how to solve this, please don't hesitate to help. I've tried many hints, but so far this problem still remains. Too frustrating!
I just started a little project on Django because I want to test Django Rest Framework. I created a project called project and inside it an app called user.
After that, I created a directory called api inside user and then I created the files viewsets.py and serializers.py in order to test Django Rest Framework.
In urls.py I imported "UsuarioViewSet" class from viewsets.
from project.user.api.viewsets import UsuarioViewSet
When I run python manage.py runserver the problem bellow ocurrs
(I also tried only user.api.viewsets... but it says "unresolved reference")
In my settings.py I registered 'user' and 'rest_framework':
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'user',
]
OS: Linux Mint |
IDE: PyCharm (community) |
Virtualenv: venv |
Python: 3.6.6
As far as I know, this kind of thing happens because of migration file __init__.py.
The main reason for this is when you write code and make changes in the migration file and then you remove some part from code for which a migrate file has been already created.
So a solution is just delete __init__.py from migration
and make sure that there is no other import which is removed or changed.

integrate an external app in django taking the code from any folder

I want to install the external app django-disqus in my blog. However, instead of install the module in the system via pip install or python setup.py install, I would like to download the code to a specific folder called libs and then link it to my project.
My folder structure is like this:
-root_folder
-- project (here I have settings.py, urls.py and wsgi.py)
-- blog (here I have models.py, admin.py, urls.py, templatetags/, template/)
-- libs (here I want to add the code of disqus)
If I downloaded the code in libs, how can I link it to INSTALLED_APPS in setting.py?
Note: I run django 1.8
You should be able to register it the same way you'd register any django app.
Make libs a package by adding __init__.py file
Then add it to your settings.INSTALLED_APPS
INSTALLED_APPS = (
...
'libs.disqus',
)

how to import django project from github to local system?

I am new to Django.
I am trying to run a project, that downloaded from github .
I run the setup.py file . that downloaded all requirements .
after that i am stuck because there is no any manage.py file as i read in tutorial ( http://www.tangowithdjango.com/book17/chapters/setup.html) .
That is not a project. It's an app that you need to install in your own project.
you have to install it
pip install django-mongo-auth
docs are here
You should then add mongo_auth and dependency django_browserid to INSTALLED_APPS. Add django_browserid.context_processors.browserid_form to TEMPLATE_CONTEXT_PROCESSORS to conclude django_browserid installation. Add mongo_auth.middleware.LazyUserMiddleware just after django.contrib.auth.middleware.AuthenticationMiddleware in MIDDLEWARE_CLASSES.
Optionally, to use provided templates, you can add mongo_auth.contrib and sekizai to INSTALLED_APPS, and mongo_auth.contrib.context_processors.mongo_auth and sekizai.context_processors.sekizai to TEMPLATE_CONTEXT_PROCESSORS, too.
Afterwards, you configure authentication providers you want to offer:
AUTHENTICATION_BACKENDS = (
'mongo_auth.backends.MongoEngineBackend',
'mongo_auth.backends.FacebookBackend',
'mongo_auth.backends.TwitterBackend',
'mongo_auth.backends.FoursquareBackend',
'mongo_auth.backends.GoogleBackend',
'mongo_auth.backends.BrowserIDBackend',
'mongo_auth.backends.LazyUserBackend',
)
Hope it helps.

Django application database error: No module named

I was trying to connect my database application to project in django. Succeded on connecting psycopg and database. Then I started to build application for it by
python manage.py startapp books
and wrote some code in models.py.
But when I tried to put application in INSTALLED_APPS, it caused on error.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'tut1.books',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
So, I'm in project's folder and type in Command Line:
%>python manage.py syncdb
ImportError: No module named 'tut1.books'
If I remove my app from INSTALLED_APPS, everything goes fine.
I suspect, there gotta be different syntax for linking application.
Tried to change 'tut1.books' to just 'books'. Causes another error.
%>python manage.py syncdb
AttributeError:'module' object has no attribute 'URLFIELD'
Files and folders in project /tut1/
manage.py
views.py
/tut1/
/templates/
/books/
Files in /books/
__init__.py
modules.py
views.py
tests.py
Files in /tut1/tut1/
__init__.py
settings.py
urls.py
views.py
wsgi.py
init.py is empty by default.
Checked PYTHONPATH for this project. Nothing odd...
>>> import sys
>>> for i in sys.path:
print(i)
C:\study\django\tut1
C:\Python33\Lib\idlelib
C:\Python33\lib\site-packages\setuptools-1.1.6-py3.3.egg
C:\Python33\python33.zip
C:\Python33\DLLs
C:\Python33\lib
C:\Python33
C:\Python33\lib\site-packages
It can be a problem with models.py.
You seem to write code as follows.
foo = models.URLFIELD()
"models" module has no URLFIELD().
You should change it to URLField().
You'll need to add an __init__.py file (it can be empty) to the folder tut1.books before python can import it. See this answer: What is __init__.py for?

Categories