Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:36:37+00:00 2026-06-12T18:36:37+00:00

I can’t get my head around this error… I’m using the restframework2 branch. Am

  • 0

I can’t get my head around this error… I’m using the restframework2 branch.

Am I doing something wrong, or is this a bug in the restframework2 code?

Here’s my code:

resources.py

class TemplateHoursSerializer(serializers.ModelSerializer):
    class Meta:
        model = TemplateHours
        nested = True

    start = HourField()
    end = HourField()
    employee = EmployeeSerializer()

class TemplateHoursResource(ModelResource):
    model = TemplateHours
    serializer_class = TemplateHoursSerializer

urls.py

url(r'^api/template-hours/$', TemplateHoursResource.as_view(actions={
    'get': 'list',
    'post': 'create'
})),
url(r'^api/template-hours/(?P<pk>[0-9]+)/$', TemplateHoursResource.as_view(actions={
    'get': 'retrieve',
    'put': 'update',
    'delete': 'destroy'
})),
...

When I visit (or POST to) http://127.0.0.1:8000/api/template-hours/, I get this error and traceback:

AttributeError at /api/template-hours/
can't set attribute
Request Method: GET
Request URL:    http://127.0.0.1:8000/api/template-hours/
Django Version: 1.4.1
Exception Type: AttributeError
Exception Value:    
can't set attribute
Exception Location: C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-    packages\rest_framework\resources.py in wrapped, line 13
Python Executable:  C:\Python27\python.exe
Python Version: 2.7.2
Python Path:    
['C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\Scripts',
 'C:\\Python27\\lib\\site-packages\\setuptools-0.6c12dev_r88846-py2.7.egg',
 'C:\\Python27\\lib\\site-packages\\virtualenv-1.7.1.2-py2.7.egg',
 'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\Lib\\site-packages',
 'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\hedron',
 'C:\\Python27\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages',
 path(u'C:\\Users\\Mathieu\\Development\\django_projects\\hedron'),
 path(u'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\hedron\\apps'),
 path(u'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\hedron\\libs')]
Server time:    di, 9 Okt 2012 22:46:50 +0200

Traceback:
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\django\core\handlers\base.py" in get_response
  111. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in view
  48. return self.dispatch(request, *args, **kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
  77. return view_func(*args, **kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\views.py" in dispatch
  324. response = self.handle_exception(exc)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\views.py" in dispatch
  321. response = handler(request, *args, **kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in list
  74. return self.root_view().list(request, args, kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in root_view
  68. return wrapped(self, self.root_class())
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in wrapped
  13. setattr(dest, attr, getattr(source, attr))

Exception Type: AttributeError at /api/template-hours/
Exception Value: can't set attribute
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:36:38+00:00Added an answer on June 12, 2026 at 6:36 pm

    Resources and routers are not finished/supported in [the beta of] REST framework 2 yet. The docs on them are a placeholder for what I want the design to look like, but I’ll be removing them from the index today. Hopefully they’ll make it in for 2.0, but I don’t see it as at all essential, since you can do everything you need with Views and explicit URLconfs. Resources & routers just give you a useful shortcut.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can find why i get this error can someone help? package Android.data; public class
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can I authenticate with just Google account username and password instead of using OAuth?
Can any one tell, how to get the result of LINQ query contains group
Can anyone explain to me why this program: for(float i = -1; i <
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
Can you please clarify me, what's the best practice for this example: Activity1 does
Can this be done in Javascript? I am converting a java wiki page to
Can PHP PDO extension bind nested objects automatically ? I mean using foreign key

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.