iam在model.py中編寫我的代碼,但是我得到了我的開發server.Any建議是welcome.I任何建議welcome.I以前suggections在堆棧中,但我不能得到任何解決我的代碼的答案。 錯誤:下面的代碼是我得到的錯誤。下面我得到一個SyntaxError在我的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'](https://docs.python.org/2/library/functions.html#print)的標準功能,您應該更改爲其他名稱.. –