After migration fandjango to version 4.2., I've got an error when I access my facebook application:
Exception Value: [u'Enter valid JSON']
Exception Location: /usr/local/lib/python2.7/dist-packages/jsonfield/fields.py in pre_init, line 77
Trace:
/usr/local/lib/python2.7/dist-packages/jsonfield/subclassing.py in set
obj.dict[self.field.name] = self.field.pre_init(value, obj)
...
jsonfield.subclassing.Creator object at 0x2a5c750
obj
User: My User
value u''
/usr/local/lib/python2.7/dist-packages/jsonfield/fields.py in pre_init
raise ValidationError(_("Enter valid JSON"))
...
▼ Local vars
Variable Value
self
jsonfield.fields.JSONField: extra_data
obj
User: My User
value u''
I have upgraded fandjagno using pip install -upgrade fandjango, python manage.py migrate fandjango.
There were another problems:
-No module named jsonfield, so I installed it using pip
-No module named dateutil.tz, so I installed it as well.
-Also it asked for property DJANGO_SITE_URL, which was not defined in the settings object. I putted also it in the settings file. However I didn't find any documentation about this property.
So now I am trying to figure out what else is needed.
Ok, I get it. The problem was with mysql database. The new version added a json field extradata. MySql interpreted it as text field with NULL value. So the problem was that fandjango wanted empty json, not NULL. I have updated the extradata field with '{}' and it's worked.
Now I have a standart problem: The mobile version of the app is unavailable because it is misconfigured for mobile access.
As it was earlier, before new version
Now I will try to figure out what is this. :)
Related
I have received a compressed Odoo instance as a ZIP file. My purpose was to unzip it and make it work in my computer. I was able to do it with no problem.
Now, I have to make that instance work in another server, so I have moved the instance from my computer to the mentioned server.
The only difference (apparently) between both installations is that in the new server I am using virtualenv to install all the Python3 packages and to run Odoo. In this new server, when I start Odoo, I see the message:
The database manager has been disabled by the administrator
And I have no chance to create a new database from the interface.
The same instance of Odoo, in my computer, shows the database manager to create a new database, as always.
Any ideas? Could be the virtualenv the problem?
When I searched Using IDE for this sentence I found it in this file \web\views\database_manager.html There is a condition to show this sentence it's:
{% if not list_db %}
<div class="alert alert-danger text-center">
The database manager has been disabled by the administrator
</div>
It's shown when this list_db variable have falsy value. now this variable is passed to this template (html page) by this method:
def _render_template(self, **d):
d.setdefault('manage',True)
d['insecure'] = odoo.tools.config.verify_admin_password('admin')
d['list_db'] = odoo.tools.config['list_db']
.....
.....
return env.get_template("database_manager.html").render(d)
This means that this value is retrieved from configuration file, So make sure that this value is set to True in the configuration file:
[options]
addons_path = .....
admin_passwd = ....
....
....
list_db = True
Didn't know about this option until know, Very good question as always #forvas.
I am trying to validate a form in a django project and part of the validation is to check if a project exists.
The Environment:
python 3.6.3
django 1.10.8
python-keystoneclient 3.14.0
I have this check currently
def clean_projectname(self):
submitted_data = self.cleaned_data['projectname']
newproj = "PROJ-FOO" + submitted_data.upper()
keystone = osauth.connect()
try:
project = keystone.projects.find(name=newproj)
raise forms.ValidationError('The project name is already taken')
except NotFound:
return submitted_data
The try section will return either a project object or it will have a 404 not found Exception.
I have tried to except on the NotFound but Django gives me an error
name 'NotFound' is not defined
I would appreciate help with this.
Have you imported NotFound from python-keystoneclient? The only way your code would work is if you had this line somewhere else in your file:
from keystoneclient.exceptions import NotFound
I'm not aware of the NotFound Exception. Is it something you've written yourself or perhaps you meant to use a similar sound Django exception?
https://docs.djangoproject.com/en/2.0/ref/exceptions/
import ckanapi
try:
ckan = ckanapi.RemoteCKAN(serverurl,
apikey='myapikeyhere',
user_agent='useragenthere')
res = ckan.action.resource_create(
package_id='2ad3c9de-502c-403a-8b03-bfc619697ff2',
#url='url',
#revision_id='revid',
description='my first upload with CKANAPI',
upload=open('./upload.csv')
)
except Exception as e:
raise Exception(str(e.error_dict))
It fails with:
Field errors: {u'url': [u'Missing value'], u'__type': u'Validation Error'}
They made url a required attribute in this discussion on GitHub:
https://github.com/ckan/ckan/pull/1641
So what is the expected value of the url attribute?
If it's expecting the url to the local file, it's not hosted.
And I cannot supply the url of the file on CKAN, because the resourceid was not created, yet.
PS: When passing an arbitrary value for the url attribute, the upload succeeds.
It makes no sense to require the url attribute. Can anybody explain?
That's, in my opinion, a bug in CKAN. I've created a issue to track it at https://github.com/ckan/ckan/issues/2769. I've also wrote a pull request on ckanapi to abstract this bug at https://github.com/ckan/ckanapi/pull/74.
As a workaround in the mean time, you can set the url to an empty string.
I am trying to use the django-user-accounts package from pinax. I am completely new to django, and I get stuck at some point, I've been struggling for hours but I still cannot display the account/signup page.
So, I have the following line in my urls.py:
url(r"^account/", include("account.urls")),
Then, I went to check in the urls.py of the account package, and
it countains this line.
url(r"^signup/$", SignupView.as_view(), name="account_signup"),
So, when I give the address: 127.0.0.1:8000/account/signup/ in my browser, I think that django should give back the SignupView. But I don't really know what the "as_view()" function does. Usually the second argument of url() should be a function that returns a HTMLResponse. So I went to see in the views.py of the account package: The class SignupView has an attribute
template_name = "account/signup.html"
I would expect the HTMLResponse returned by SignupView.as_view() to be using this template but it doesnt. Instead, I got this error:
TypeError at /
'str' object is not callable
Request Method: GET Request URL: http://127.0.0.1:8000/ Django
Version: 1.6.1 Exception Type: TypeError Exception Value:
'str' object is not callable
Exception Location:
/usr/lib/python2.7/dist-packages/django/core/handlers/base.py in
get_response, line 112 Python Executable: /usr/bin/python Python
Version: 2.7.6
Note that this is just the default behaviour of django-user-accounts, I have not modified anything. So I guess that I am missing a dependency or something, but I cannot interprete the error message. By the way, the returned error is exaclty the same as when I give this address in the browser 127.0.0.1:8000/. Here I expect to receive an error because I have no home page yet, but still, why does the SignupView try to get the html of the root page ???
I am stuck here and I have no idea how I can try to debug this. Any hints would be more than welcome.
So, the problem has been solved thanks to a comment of Bilou06, the problem was actually caused by another line in the urls.py of the project, because the root of the project was pointing to an indexView that did not exist.
I have the following Python code to connect to a MongoDB (2.0.1 installed through MacPorts) database using MongoEngine (0.7.9 installed through pip):
import datetime
from mongoengine import *
connect('mydb')
class Post(EmbeddedDocument):
title = StringField(required=True)
description = StringField(required=True)
author = StringField(required=True)
pub_date = DateTimeField(required=True, default=datetime.datetime.now)
p = Post()
p.author = "genba"
p.title = "Test post"
p.description = "This is a test post"
When calling the method to_mongo on the objet p, I get the following traceback:
env/lib/python2.7/site-packages/mongoengine/base.pyc in to_mongo(self)
1040 # Only add _cls and _types if allow_inheritance is not False
1041 if not (hasattr(self, '_meta') and
-> 1042 self._meta.get('allow_inheritance', ALLOW_INHERITANCE) == False):
1043 data['_cls'] = self._class_name
1044 data['_types'] = self._superclasses.keys() + [self._class_name]
AttributeError: 'NoneType' object has no attribute 'get'
As you may notice, the error is produced by a line of code in MongoEngine's code, installed in the virtual environment env with virtualenv.
This error actually arises both when I embed the document Post into another document by using an EmbeddedDocumentField, and when I just paste the previous code into the Python interpreter (until now, I've just used IPython instead of the vanilla Python interpreter).
I've tried debugging with pdb and searching the internet, but I haven't got to find any useful information on this issue. The only thing I can tell is that self._meta is None and that causes the exception to be raised. But why it is None or what that should mean… I don't know.
Why do I get this error? It's definitely in MongoEngine's code, but is it cause by MongoEngine or by my code/data? How can I solve it?
Thanks in advance.
PS: As additional information, I plan to use this with Django, but the previous code can be run apart from Django, and I've done my tests like that (without Django, just with IPython, like I mentioned before).