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.
Related
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.
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. :)
I am still trying to find out why the same line of code works in Apache 2.2.22 with mod_wsgi and causes an error with any other version such as 2.2.25 and 2.4. When I run the python/django app under 2.2.22, no errors, no complaints, no loss of functionality. When I change the Apache to be 2.2.25 (or 2.4) I get the following error messages from Django ...
Request URL: http://127.0.0.1/portal/
Django Version: 1.5.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'account_index' with arguments '()' and keyword arguments '{}' not found.
Exception Location: C:\Python27\lib\site-packages\django\template\defaulttags.py in render, line 424
Python Executable: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe
Referring to these lines ...
48 {% if user.is_superuser %}
49 <li><a tabindex="-1" href="{% url 'account_index' %}">Browse</a></li>
50 {% else %}
This is the only piece that causes an error and I have no explanation as to why. The link next to it is exactly the same and causes no errors. I have checked the Apache logs, there is no complaint about wsgi failures. The Django error message gives me no more info than above. I am very confused about this as going to the html template file and removing line #49 eliminates the error (but also the dropdown menu).
* Looking at related posts about similar errors gave me the idea that this line from account.urls.py might be the problem, can anyone comment on this?
url(r'^/?$', 'account.views.account_index', name='account_index'),
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).
I have implemented a very basic and by-the-tutorial Pusher triggers in my django app.
At first it worked great, but after a few commits I ran into the following exception:
"object of type 'NoneType' has no len()"
Out of the second of the following lines:
p = pusher.Pusher()
p[page_key].trigger('page_update', {'msgid' : message.id})
Different or an empty dict produced same result, same as changing page_key to string instead of unicode - nothing.
Also note that type() of p and p.trigger gives logical results, and they're definitely not None.
This line WORKS IN SOME CASES (which I have no clue what so special about them) and has worked in the past as I've mentioned, yet I can't figure out what am I doing wrong.
It seems that none of the last commits have anything to do with Pusher, so I'm helpless. Searching the web for this exception wasn't fruitful at all and in general there's not enough documentation regarding to django + Pusher.
It is probably something else that I'm doing wrong but I have no clue where to start looking.
Any help will be most appreciated.
Traceback:
79. p[page_key].trigger('page_update', {'msgid' : message.id})
File "/usr/local/lib/python2.7/dist-packages/pusher/__init__.py" in trigger
41. status = self.send_request(self.signed_query(event, json_data, socket_id), json_data)
File "/usr/local/lib/python2.7/dist-packages/pusher/__init__.py" in signed_query
54. signature = hmac.new(self.pusher.secret, string_to_sign, hashlib.sha256).hexdigest()
File "/usr/lib/python2.7/hmac.py" in new
133. return HMAC(key, msg, digestmod)
File "/usr/lib/python2.7/hmac.py" in __init__
68. if len(key) > blocksize:
Exception Type: TypeError at /sphere/comment
Exception Value: object of type 'NoneType' has no len()
self.pusher.secret is None there instead of a string. Are your settings for pusher not getting picked up?