django:无法从全局应用导入模型

时间:2018-08-07 16:57:23

标签: python django import models

尝试从views.py中的其他应用程序导入模型:

from global.models import Global

控制台引发错误:

    from global.models import Global
              ^
SyntaxError: invalid syntax

我检查了很多信息,但找不到我做错了什么。

global.models.py

from django.db import models

# Create your models here.
class Global(models.Model):
    phone = models.CharField(max_length=50, blank=True)
    email = models.EmailField(max_length=50, blank=True)
    adress = models.CharField(max_length=100, blank=True)

    class Meta:
        verbose_name = 'Глобальные настройки'
        verbose_name_plural = 'Глобальные настройки'

    def __str__(self):
        return 'Глобальные настройки'

projects.views.py

from django.shortcuts import render, redirect, get_object_or_404
from global.models import Global
from .models import Advertising, Films, Presentations, AuthorsLeft, AuthorsRight, BackstageImg
from django.utils import timezone

在我的编辑器“ global”中为蓝色,如果我尝试导入另一个应用程序,它将正常工作。可能是django保留的“ global”,还是我做错了什么?

1 个答案:

答案 0 :(得分:2)

 let translatedText = new TranslatePipe().transform(msg);

 but the `TranslatePipe` does not work. 

您可以像这样使用它:

<script>
$( document ).ready(function() {
    $("#department").chained("#directorate"); 
    $("#section").chained("#department"); 
});
</script>