S
S
solovey12021-11-28 19:47:14
Django
solovey1, 2021-11-28 19:47:14

ImportError: cannot import name ... most likely due to a circular import?

when starting a Django project I get an error:

ImportError: cannot import name 'Full_anketa' from partially initialized module 'anketa.models' (most likely due to a circular import) (/Users/sergey/Documents/Projects/Anketa-django/filkos/anketa/models.py)


Anketa/models code
from django.db import models
from .views import anketa
from django.db.models import IntegerField
from django.core.validators import  RegexValidator, MinValueValidator

class Full_anketa(models.Model):
    surname = models.CharField(max_length=100,blank=True,verbose_name='Фамилия')
    name = models.CharField(max_length=100,blank=True,verbose_name='Имя')
    middlename = models.CharField(max_length=100,blank=True,verbose_name='Отчество')
    sum = models.PositiveIntegerField(blank=True,default=1,validators=[MinValueValidator(0)],verbose_name='Сумма')
    birthdate_regex = RegexValidator(regex=r'^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$',message="Дата рождения должна быть введена в формате: '1987-05-26'.")    
    birthdate = models.DateField(validators =[birthdate_regex],blank=True,verbose_name='Дата рождения')
    phone_regex = RegexValidator(regex=r'^((7)+([0-9]){10})$',message="Номер телефона должен быть введен в формате: '79999999999'.")
    phone_number = models.CharField(validators=[phone_regex],max_length=11,verbose_name='Номер телефона',blank=True)
    email = models.EmailField(max_length=100,verbose_name='Электронная почта',blank=True)
    #town = models.CharField(choices=)
    agreement = models.BooleanField(blank=True,default=False,verbose_name='Согласие на обработку персональных данных')

    income = models.PositiveIntegerField(blank=True)
    #employment = models.IntegerField(choices=)
    #proof = models.IntegerField(choices=)
    #expirience = models.IntegerField(choices=)
    #credit_history = models.IntegerField(choices=)
    #education = models.IntegerField(choices=)
    #property = models.IntegerField(choices=)

    pass_series_num = models.CharField(max_length=100,help_text="Серия и номер паспорта должны быть введены в формате: '1234 №123456'",blank=True)
    passdate_regex = RegexValidator(regex=r'^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$',message="Номер паспорта должен быть введен в формате: '2015-10-26'.")
    pass_date = models.CharField(max_length=100,validators=[passdate_regex],verbose_name='Дата выдачи паспорта',blank=True)
    passcode_regex = RegexValidator(regex=r'^\d{3}-\d{3}$',message="Код подразделения должен быть введен в формате '123-123'.")
    pass_code = models.CharField(max_length=100,validators=[passcode_regex],verbose_name='Код подразделения',blank=True)
    pass_who_issued = models.CharField(max_length=100,blank=True,verbose_name='Кем выдан')
    #reg_town = models.CharField(choices=,blank=True,verbose_name='Город прописки')
    reg_street = models.CharField(max_length=100,blank=True,verbose_name='Улица прописки')
    reg_house = models.CharField(max_length=100,blank=True, verbose_name='Дом прописки')
    reg_flat = models.CharField(max_length=100,blank=True,verbose_name='Квартира прописки')

    work_name = models.CharField(max_length=100,verbose_name='Наименование организации')
    work_head = models.CharField(max_length=100,verbose_name='Руководитель')
    workphone_regex = RegexValidator(regex=r'^((7)+([0-9]){10})$',message="Номер телефона должен быть введен в формате: '79999999999'.")
    work_phone = models.CharField(max_length=100,validators=[workphone_regex],verbose_name='Рабочий телефон')
    #work_position = models.IntegerField(choices=,verbose_name='Должность')
    #work_town = models.CharField(choices=,verbose_name='Город работы')
    work_street = models.CharField(max_length=100,verbose_name='Улица работы')
    work_house = models.CharField(max_length=100,verbose_name='Дом работы')
    work_inn = models.CharField(max_length=100,verbose_name='ИНН работы')


code/forms
from django import forms
from .models import Full_anketa

class step1(forms.ModelForm):
    class Meta:
        model = Full_anketa
        fields = ['surname','name','middlename','sum','birthdate','phone_nubmer','email','agreement']

class step2(forms.ModelForm):
    class Meta:
        model = Full_anketa
        fields = ['income']

class step3(forms.ModelForm):
    class Meta:
        model = Full_anketa
        fields = ['pass_series_num','pass_date','pass_code','pass_who_issued','reg_street','reg_house','reg_flat']

class step4(forms.ModelForm):
    class Meta:
        model = Full_anketa
        fields = ['work_name','work_head','work_phone','work_street','work_house','work_inn']


What other information about my project can I provide?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question