'RegistrationTestModel has no attribute '_deferred' - django

I am trying to get the Django Shell working with the Google App Engine. Unfortunately, I am getting the following error:
AttributeError: type object 'RegistrationTestModel' has no attribute '_deferred'
Does anyone have any idea of how to fix this?
Stack trace:
WARNING:root:Could not read datastore data from /var/folders/X0/X0QgAfs7Hd8IcCVZOIkiCE+++TI/-Tmp-/django_content-sharer.datastore
WARNING:root:Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
Traceback (most recent call last):
File "manage.py", line 30, in <module>
execute_manager(settings)
File "/Users/chris/Documents/workspace/ContentSharer/src/__init__.py", line 362, in execute_manager
File "/Users/chris/Documents/workspace/ContentSharer/src/__init__.py", line 303, in execute
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 195, in run_from_argv
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 222, in execute
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 351, in handle
File "/Users/chris/Documents/workspace/ContentSharer/src/django/core/management/commands/shell.py", line 18, in handle_noargs
loaded_models = get_models()
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/db/models/loading.py", line 166, in get_models
AttributeError: type object 'RegistrationTestModel' has no attribute '_deferred'

Are you using Django 1.1.2 with the helper? If so, the helper has not yet been updated for Django 1.1.2 yet. Be sure to get r105 or later of the helper. As a side note, Django 1.1.2 hasn't been installed on production for use_library yet, as far as I know.
Try using Django 1.1.1 until 1.1.2 is available on GAE production and the helper has been updated.
Patch is included in this ticket: http://code.google.com/p/google-app-engine-django/issues/detail?id=171
Update: the helper has been patched with r105 http://code.google.com/p/google-app-engine-django/source/detail?r=105

It looks like you're trying to load a part of Django that depends on Django models. Django models do not work on App Engine, as they depend on a relational database.
Try django-nonrel instead.

Related

I am getting a module not found error for authlib, I had followed the instructions as written

ModuleNotFoundError
ModuleNotFoundError: No module named 'authlib'
Traceback (most recent call last)
File "/usr/local/lib/python3.8/site-packages/flask/cli.py", line 184, in
find_app_by_string
app = call_factory(script_info, attr, args)
File "/usr/local/lib/python3.8/site-packages/flask/cli.py", line 119, in call_factory
return app_factory()
File "/app/superset/app.py", line 44, in create_app
raise ex
File "/app/superset/app.py", line 37, in create_app
app_initializer.init_app()
File "/app/superset/initialization/__init__.py", line 616, in init_app
self.init_app_in_ctx()
File "/app/superset/initialization/__init__.py", line 564, in init_app_in_ctx
File "/app/superset/initialization/__init__.py", line 656, in configure_fab
appbuilder.init_app(self.superset_app, db.session)
File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/base.py", line 202, in
init_app
self.sm = self.security_manager_class(self)
File "/usr/local/lib/python3.8/site-
packages/flask_appbuilder/security/sqla/manager.py",
line 54, in __init__
super(SecurityManager, self).__init__(appbuilder)
File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/manager.py",
line 263, in __init__
from authlib.integrations.flask_client import OAuth
ModuleNotFoundError: No module named 'authlib'
The debugger caught an exception in your WSGI application. You can now look at the
traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on
the "Traceback" headline. From the text traceback you can also create a paste of it.
For code execution mouse-over the frame you want to debug and click on the console
icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra
helpers available for introspection:
dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
This is my directory structure: /home/directory/superset/superset-frontend.
I'm runnning superset in docker and I'm trying to get OAuth working.
I’ve edited the config file and added the OAuth configuration.
One of the lines I added was:
AUTH_TYPE = AUTH_OAUTH
This required me to import the auth types as below:
from flask_appbuilder.security.manager import (
AUTH_OID,
AUTH_REMOTE_USER,
AUTH_DB,
AUTH_LDAP,
AUTH_OAUTH,
)
When I try running npm run dev-server in development mode in superset.
I get the following error:
ModuleNotFoundError
ModuleNotFoundError: No module named 'authlib'

PyMongo 3 and ServerSelectionTimeoutError while getting data from Mongodb

This seems like an old solved problem here and here and here but Still I am getting this error.I create my db on Docker.And It worked only one time.Before this, I re-created db, did "connect =false",added wait, downgraded pymongo, did previous solutions etc. I stuck.
Python 3.8.0, Pymongo 3.9.0
from pymongo import MongoClient
import pprint
client = MongoClient('mongodb://192.168.1.100:27017/',
username='admin',
password='psw',
authSource='myappdb',
authMechanism='SCRAM-SHA-1',
connect=False)
db = client['myappdb']
serverStatusResult=db.command("serverStatus")
pprint(serverStatusResult)
and I am getting ServerSelectionTimeoutError
Traceback (most recent call last):
File "C:\Users\ME\eclipse2019-workspace\exdjango\exdjango__init__.py",
line 12, in
serverStatusResult=db.command("serverStatus")
File "C:\Users\ME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\database.py",
line 610, in command
with self.client._socket_for_reads(
File "C:\Users\ME\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py",
line 113, in __enter
return next(self.gen)
File "C:\Users\ME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\mongo_client.py",
line 1099, in _socket_for_reads
server = topology.select_server(read_preference)
File "C:\Users\ME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\topology.py",
line 222, in select_server
return random.choice(self.select_servers(selector,
File "C:\Users\ME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\topology.py",
line 182, in select_servers
server_descriptions = self._select_servers_loop(
File "C:\Users\ME\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymongo\topology.py",
line 198, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: 192.168.1.100:27017: timed out
Your connection looks a little misconfigured. Firstly you have half connection string, half parameter format. I'd suggest you stick with one or the other.
Your auth database is usually seperate to your actual databases (and it's usually called admin). Check this is correct.
There's no particular need to specify the authMechanism assuming you are using MongoDB 3.0 or later.
The connect=False is likely a red herring.
So I would try one of either:
client = MongoClient('mongodb://admin:psw#192.168.1.100:27017/myappdb?authSource=admin')
or
client = MongoClient(host='192.168.1.100',
port=27017,
username='admin',
password='psw',
authSource='admin')

Error in gcloud " AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'"

I am trying to implement firebase functions cron job from this link : https://github.com/firebase/functions-cron
Everything worked properly
But when I try to run google cloud cron job it gives me below error :
(/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
I tried this solution : Getting AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS' when running Google Sheets API quickstart
But still no luck.
Can anyone please help me with this.
Issue is with your httplib Module.
When you installed this module for your project you must have installed it with pip for Python 3
If you want to check whether this module is for python 3 or python 2,
Go to httplib2 module and go inside its init.py
later see this line Requires Python 3 or later
if it is written like that means you have installed this library with pip for python 3. Now delete all the httplib2 from your lib folder.
Create a seperate enviroment for python 2.7 and again install all your modules with pip install -t lib -r requirements.txt

django 1.9.5 testing tutorial

I am new to Django 1.9.5, when trying the tutorial part 5 in the official website.
I followed their instructions and coded the tests.py file found here: https://docs.djangoproject.com/en/1.9/intro/tutorial05/
But when I run it, this is what I got:
ImportError: Failed to import test module: polls.tests
Traceback (most recent call last):
File "C:\Python27\lib\unittest\loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "C:\Python27\lib\unittest\loader.py", line 232, in _get_module_from_name__import__(name)
File "C:\Users\--\Desktop\Django\mysite\polls\tests.py", line 11, in <module>class QuestionMethodTests(TestCase):
File "C:\Users\--\Desktop\Django\mysite\polls\tests.py", line 20, in QuestionMethodTests
self.assertEqual(future_question.was_published_recently(), False)
NameError: name 'self' is not defined
Can any Django experts help me to understand the why is this happening and how do I solve it.
Thank you so much!

ImportError: No module named phonenumbers in Odoo (OpenERP v8)

I'm trying to intall the asterisk_click2dial module on ODOO and this error comes to me in the log file:
ValueError: Routing: posting a message without model should be with a parent_id (private mesage).
2015-03-09 15:23:38,262 11093 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/openerp/service/server.py", line 281, in app
return self.app(e, s)
File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1274, in __call__
self.load_addons()
File "/opt/odoo/openerp/http.py", line 1293, in load_addons
m = __import__('openerp.addons.' + module)
File "/opt/odoo/openerp/modules/module.py", line 79, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/opt/odoo/addons/base_phone/__init__.py", line 23, in <module>
from . import wizard
File "/opt/odoo/addons/base_phone/wizard/__init__.py", line 23, in <module>
from . import number_not_found
File "/opt/odoo/addons/base_phone/wizard/number_not_found.py", line 25, in <module>
import phonenumbers
ImportError: No module named phonenumbers
The problem is just that I installed that module (phonenumbers) plus the py-Asterisk module without errors using pip install phonenumbers and pip install py-Asterisk and the error persists.
I noticed I have at least two versions of python installed (2.6 and 2.7) but both modules are installed at the same version from odoo (I can see the modules in the python2.7 cli when, for example, I write phonenumbers or search).
Has anybody any idea what is happening to me? I'd be gratefull for some specific response. Thanks.
Here the connector's page: OpenERP - Asterisk connector
Ok, my bad. During odoo instalation I created a virtual environment under the Odoo system user account which was used solely by the Odoo server so I just need to install these modules under that enviorment. This works for me:
First let’s switch from root to the odoo user, then create a new virtual environment called odoo and activate it:
su - odoo
/usr/local/bin/virtualenv --python=/usr/local/bin/python2.7 odoo
source odoo/bin/activate
(If you have the virtual environment created like me just ignore the second line). Before starting the module installation we need to add the path to the PostgreSQL binaries, otherwise the PsycoPG2 module install will fail (I ignored this one too):
export PATH=/usr/pgsql-9.3/bin:$PATH
Then I can do pip install... Thank you all for your help.