小编Sir*_*ius的帖子

使用django rest框架教程时出现TypeError

我是使用Django Rest框架的新手,我正在遵循这个教程 Django-Rest-Framework

我的模型不是代码片段,而是由下面给出的userprofile组成:

class UserProfile(models.Model):
      user = models.OneToOneField(User)
      emp_code = models.CharField(max_length=10, blank=True)
      user_type = models.IntegerField(max_length=1, default=0, choices=USER_TYPE)
      group = models.ForeignKey(Group, null=True, blank=True)
      status = models.SmallIntegerField(max_length=1,default=0)
      added_on = models.DateTimeField(auto_now_add=True)
Run Code Online (Sandbox Code Playgroud)

本教程的第一部分运行正常,如上所述以json格式获得所需的输出,但是第二个教程以后我得到了类型错误:

TypeError at /authentication/userprofile/
'type' object is not iterable
Request Method: GET
Request URL:    http://*****.com/authentication/userprofile/
Django Version: 1.6
Exception Type: TypeError
Exception Value:    
'type' object is not iterable
Exception Location: /home/web/cptm_venv/lib/python2.7/site-     packages/rest_framework/views.py in get_permissions, line 226
Python Executable:  /usr/bin/python
Python Version: 2.7.3
Python Path:    
['/home/web/cptm_venv/lib/python2.7/site-packages',
 '/home/web/cptm',
 '/home/web/cptm_venv/lib/python2.7/site-packages',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old', …
Run Code Online (Sandbox Code Playgroud)

python django rest typeerror django-rest-framework

28
推荐指数
5
解决办法
2万
查看次数

从exe恢复Python源代码

我编写了一个python程序,我使用py2exe将其转换为exe二进制文件.我有在dist文件夹中生成的所有文件但由于系统崩溃,我丢失了源代码.

有没有办法从.exe或py2exe生成的其他支持文件中获取.py源代码文件?

python recovery

2
推荐指数
1
解决办法
8117
查看次数