У меня проблема с запуском моего Django кода.
File "E:\sophienwald\amocrm\models.py", line 3, in <module>
from amocrm import BaseContact, amo_settings, fields, BaseLead
ImportError: cannot import name 'BaseContact'
Но я заметил странную особенность ... Если я поменяю местами «BaseContact» и «BaseLead», это скажет, что компилятор не может импортировать BaseLead. "fields" и "amo_setting" работают нормально.
Бит кода из amocrm \ models.py:
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'),
], 'Авторизация'),
]
Есть часть models.py с "BaseContact"
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}'