Python 导入错误:无法导入名称';BaseContact';
我在运行Django代码时遇到问题Python 导入错误:无法导入名称';BaseContact';,python,django,Python,Django,我在运行Django代码时遇到问题 File "E:\sophienwald\amocrm\models.py", line 3, in <module> from amocrm import BaseContact, amo_settings, fields, BaseLead ImportError: cannot import name 'BaseContact' models.py中有一部分带有“BaseContact” 是否可以发布定义了BaseContact的文件?使用
File "E:\sophienwald\amocrm\models.py", line 3, in <module>
from amocrm import BaseContact, amo_settings, fields, BaseLead
ImportError: cannot import name 'BaseContact'
models.py中有一部分带有“BaseContact”
是否可以发布定义了BaseContact的文件?使用BaseContact添加了部分代码?是否可以发布定义了BaseContact的文件?使用BaseContact添加了部分代码
import logging
from amocrm import BaseContact, amo_settings, fields, BaseLead
from django.conf import settings
from django.db import models
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.utils.functional import cached_property
from wagtail.admin.edit_handlers import MultiFieldPanel, FieldPanel
from wagtail.contrib.settings.models import BaseSetting
from wagtail.contrib.settings.registry import register_setting
logger = logging.getLogger(__name__)
@register_setting
class AmocrmSettings(BaseSetting):
PIPELINE_FIELDS = [
('stay_tuned_pipeline_name', 'stay_tuned_status_name'),
('new_posts_pipeline_name', 'new_posts_status_name'),
('back_call_pipeline_name', 'back_call_status_name'),
]
login = models.CharField('Логин', max_length=120, null=True, blank=True)
token = models.CharField('Токен', max_length=120, null=True, blank=True)
subdomain = models.CharField('Поддомен', max_length=120, null=True, blank=True)
run_async = models.BooleanField('Обновлять асинхронно', default=False)
# forms.StayTunedContact
stay_tuned_pipeline_name = models.CharField('Название воронки', max_length=120, null=True, blank=True)
stay_tuned_status_name = models.CharField('Статус при создании', max_length=120, null=True, blank=True)
# forms.NewPostsContact
new_posts_pipeline_name = models.CharField('Название воронки', max_length=120, null=True, blank=True)
new_posts_status_name = models.CharField('Статус при создании', max_length=120, null=True, blank=True)
# forms.BackCallContact
back_call_pipeline_name = models.CharField('Название воронки', max_length=120, null=True, blank=True)
back_call_status_name = models.CharField('Статус при создании', max_length=120, null=True, blank=True)
panels = [
MultiFieldPanel([
FieldPanel('login'),
FieldPanel('token'),
FieldPanel('subdomain'),
FieldPanel('run_async'),
], 'Авторизация'),
]
class Contact(BaseContact):
"""
Amocrm package contact model with custom fields
"""
phone = fields.EnumCustomField('Телефон', enum='WORK')
email = fields.EnumCustomField('Email', enum='WORK')
def __str__(self):
return f'name: {self.name}, phone: {self.phone}, email: {self.email}'