Got an error on piston 0.2.2 'Blogpost' object has no attribute 'format'

Anonymous avatarAnonymous created an issue

Hi all,

I run piston example with Django 1.02; when I open url: http://localhost:8000/api/posts/ It cause some errors and reports: Blogpost' object has no attribute 'format' But if I remove some statements in the blogpost/api/ 13 AWS Solution Division 14 def resource_uri(self): 15 return ('blogposts', [ 'format', ]) and it works fine. Does anyone know what problem is it?

The detail error msg: Environment:

Request Method: GET Request URL: http://localhost:8000/api/posts/ Django Version: 1.0.2 final Python Version: 2.6.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.markup', '', 'blogserver.api'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware')

Traceback: File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/core/handlers/" in get_response 86. response = callback(request, *callback_args, callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/views/decorators/" in inner_func 21. response = func(*args, kwargs) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in call 172. else: stream = srl.render(request) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in render 367. seria = simplejson.dumps(self.construct(), cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in construct 276. return _any(, self.fields) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in _any 91. ret = _qs(thing, fields=fields) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in _qs 261. return [ _any(v, fields) for v in data ] File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in _any 99. ret = _model(thing, fields=fields) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in _model 243. ret['resource_uri'] = permalink( lambda: (url_id, File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/db/models/" in inner 30. return reverse(bits[0], None, *bits[1:3]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/core/" in reverse 254. *args, kwargs))) File "/Users/wuyiting/Desktop/django-piston/examples/blogserver/../../ piston/" in <genexpr> 244. (getattr(data, f) for f in fields) ) ) ()

Exception Type: AttributeError at /api/posts/ Exception Value: 'Blogpost' object has no attribute 'format'

Comments (7)

  1. Anonymous

    "me to"

    Although i also found that if you remove the format parts you've mentioned, then the non-api view also fails to work. So it's a case of one, or the other. :(

  2. Anonymous

    I can confirm that the above patch is applied to the version i am using (92644a459862 ) has the above patch applied:

    api/, line 34: def read(self, request, title=None):

    However, the reported behaviour in this bug is still happening. :(

  3. Anonymous

    For the example project blogserver, In the file api/ you need to change the word 'format' to 'title', ie:

    # I replaced format to title in the following example;
    def resource_uri(self):
            return ('blogposts', [ 'title', ])
  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.