创建django模型时出现语法错误

时间:2016-06-22 09:55:37

标签: django python-2.7 django-models

我试图创建一个django模型来获取新闻通讯的注册,同时在model.py文件中创建模型即可获得以下错误

  from __future__ import unicode_literals

  from django.db import models



  def SignUp(models.Model):
       Email = models.EmailField(max_length=254, null = False , blank = False)
       Name  = CharField(max_length= 26, null = False , blank = False, default = 'datta')
       TmieStamp = DateTimeField(auto_now=False, auto_now_add=True)
       def __unicode(self)__:
           return self.Name

错误:

Error:
       File "C:\Users\DattaVamshi\Desktop\env\src\newsletter\models.py", line 7
  def SignUp(models.Model):
                   ^
SyntaxError: invalid syntax

错误出现在这行“def SignUp(models.Model):”

Pyhon 2.7,Django 1.9

1 个答案:

答案 0 :(得分:7)

您已使用def SignUp代替class SignUp