我在 model.py 中收到语法错误,我的代码可能存在问题



我正在用 model.py 编写我的代码,但我在我的开发服务器中遇到了这个错误。欢迎任何建议。我已经遵循了堆栈流中以前的建议,但我无法得到任何解决我的代码的答案。 错误:下面的代码是我得到的错误。

Unhandled exception in thread started by <function wrapper at 0x7fe6d63e4938>
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/usr/lib64/python2.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
six.reraise(*_exception)
File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib64/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/lib64/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/harrugg2/projects/django/church/tithe/models.py", line 24
def print(self):
^
SyntaxError: invalid syntax

以下是我的 model.py 代码

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils import timezone
from django.db import models
# Create your models here.
class tithe(models.models):
genarationNo = models(ForeignKey('generationNo.User'))
memberid = models.IntField()
membername = models.VacharField()
tithe = models.IntField()
combinedoffering = models.IntField(max_length=45)
campmeetingoffering = models.IntField(IntField=45)
churchbuilding = models.IntField(max_length=45)
conference = models.IntField(max_length=45)
localchurch = models.IntField(max_length=45)
funds = models.IntField(max_length=45)
total = models.IntField(max_length=45)
created_date = models.DateTimeField(
default=timezone.now)
printed_date = models.DateTimeField(
blank=True, null=True)
def print(self):
self.printed_date = timezone.now()
self.save()
def __str__(self):
return self.generationNo
class Meta:
unique_together = ["generationNo","IntField"]
ordering = ["printed_date","membername"]

print是该语言的关键字。它是保留的,不能用作标识符。看到这里。

正如其他人所说,print不是函数的好名称,但您的代码还有其他奇怪之处。 在unique_together中,您引用的字段不存在。

相关内容

  • 没有找到相关文章

最新更新