Circular Import URL

I can’t see where the circular import is

django.core.exceptions.ImproperlyConfigured: The included URLconf ‘<module ‘Reciept.urls’ from ‘Reciept\urls.py’>’ does not appear to have any patterns in it. If you see the ‘urlpatterns’ variable with valid patterns in the file then the issue is probably caused by a circular import

project level urls.py

from django.contrib import admin
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('PPMS/', include('PPMS.urls')),
    path('Dispute/',include('Dispute.urls')),
    path('Reciept/', include('Reciept.urls'))
]

urls.py

from django.urls import path
from .views import Disputeindex

app_name='Dispute'

urlpatterns = [
    path('',Disputeindex, name='Disputeindex')
]

View.py

from django.shortcuts import render
def Recipetindex(request):

    return render(request, 'Reciept/index.html')

We’d need to see all the urls.py files in your project. The circular import situation may not be visible just by looking at the urls.py file from the Receipt app. (Also, please label the individual files to include the directory name. Under the project urls.py file you have another file labeled urls.py, but you don’t identify which app that file is from.)

And, it’s also possible that the circular imports involve files other than the urls.py files. You’ll want to check any file that the urls.py file imports, and what they import, etc, until you’re sure that there are no circular import situations.

ZP_DjangoProject/ZP_DjangoProject/urls.py

from django.contrib import admin
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('PPMS/', include('PPMS.urls')),
    path('Dispute/',include('Dispute.urls')),
    path('Reciept/', include('Reciept.urls')),
]

ZP_DjangoProject/ZP_DjangoProject/settigns.py

from pathlib import Path
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Build paths inside the project like this: BASE_DIR / 'subdir'.
# BASE_DIR = Path(__file__).resolve().parent.parent

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'PPMS.apps.PpmsConfig',
    'Reciept.apps.RecieptConfig',
    'Transactions.apps.TransactionsConfig',
    'Dispute.apps.DisputeConfig'
]

ROOT_URLCONF = 'ZP_DjangoProject.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'Z_templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

ZP_DjangoProject/Dispute/urls.py

from django.urls import path
from .views import Disputeindex

app_name='Dispute'

urlpatterns = [
    path('',Disputeindex, name='Disputeindex')
]

ZP_DjangoProject/Dispute/models.py

from django.db import models
from PPMS.models import Property

# Create your models here.
class Dispute(models.Model):
    dept = [
        ('Legal','Legal'),
        ('Credit Control','Credit Control'),
        ('Property Management','Property Management'),
        ('Pre Sales','Pre Sales'),
        ('Asset', 'Asset'),
        ('Subletting','Subletting')
    ]

    allocated_dept = models.CharField(max_length=50,choices=dept,blank=True)
    dispute_create_date = models.DateTimeField(auto_now_add=True)
    dispute_modified_date = models.DateTimeField(auto_now=True)
    disputor = models.CharField(max_length=100)
    disputor_telephone = models.CharField(max_length=12)
    disputor_email = models.EmailField()
    dispute_info = models.TextField()
    property = models.ForeignKey(Property, on_delete=models.CASCADE, related_name='DisProp')

    def __str__(self):
        return f"{self.id} - {self.disputor}"

ZP_DjangoProject/Dispute/views.py

from django.shortcuts import render
from .models import Dispute

# Create your views here.
def Disputeindex(request):
    disputes = Dispute.objects.all()


    return render(request, 'Disputes/index.html', {
                'disputes': disputes    })

ZP_DjangoProject/PPMS/urls.py

from django.urls import path
from .views import PPMSindex

urlpatterns = [
    path('',PPMSindex, name='PPMSindex')
]

ZP_DjangoProject/PPMS/models.py

from django.db import models

# Create your models here.
class Owner(models.Model):
    owner_name = models.CharField(max_length=100)
    owner_reference = models.CharField(max_length=50)
    address_1 = models.CharField(max_length=100,blank=True)
    address_2 = models.CharField(max_length=100,blank=True)
    address_3 = models.CharField(max_length=100,blank=True)
    address_4 = models.CharField(max_length=100,blank=True)
    address_5 = models.CharField(max_length=100,blank=True)
    postcode = models.CharField(max_length=10,blank=True)
    bank = models.CharField(max_length=50, blank=True)
    type = models.CharField(max_length=50, blank=True)
    charge_to = models.CharField(max_length=50, blank=True)
    vat_number = models.CharField(max_length=50, blank=True)
    
    def __str__(self):
        return {self.owner_reference} - {self.owner_name}

class Property(models.Model):
    property_name = models.CharField(max_length=100)
    property_reference = models.CharField(max_length=50)
    property_tenure = models.CharField(max_length=50, blank=True)
    property_status = models.CharField(max_length=50, blank=True)
    property_type = models.CharField(max_length=50, blank=True)
    address_1 = models.CharField(max_length=100,blank=True)
    address_2 = models.CharField(max_length=100,blank=True)
    address_3 = models.CharField(max_length=100,blank=True)
    address_4 = models.CharField(max_length=100,blank=True)
    address_5 = models.CharField(max_length=100,blank=True)
    postcode = models.CharField(max_length=10,blank=True)
    ipd_area = models.CharField(max_length=10, blank=True)
    start_date = models.DateField(blank=True)
    end_date = models.DateField(blank=True)
    title_number = models.CharField(max_length=50, blank=True)
    UPRN = models.CharField(max_length=50, blank=True)
    charged_to = models.CharField(max_length=50, blank=True) 
    owner = models.ForeignKey(Owner,on_delete=models.CASCADE, related_name='propowner', null=True)

    def __str__(self):
        return {self.property_reference} - {self.property_name}

class Unit(models.Model):
    unit_name = models.CharField(max_length=100)
    unit_reference = models.CharField(max_length=50)
    unit_tenure = models.CharField(max_length=50, blank=True)
    unit_status = models.CharField(max_length=50, blank=True)
    unit_type = models.CharField(max_length=50, blank=True)
    address_1 = models.CharField(max_length=100,blank=True)
    address_2 = models.CharField(max_length=100,blank=True)
    address_3 = models.CharField(max_length=100,blank=True)
    address_4 = models.CharField(max_length=100,blank=True)
    address_5 = models.CharField(max_length=100,blank=True)
    postcode = models.CharField(max_length=10,blank=True)
    UPRN = models.CharField(max_length=50, blank=True)
    lease_startdate = models.DateField(blank=True)
    lease_enddate = models.DateField(blank=True)
    lease_date = models.DateField(blank=True)
    lease_term = models.IntegerField(blank=True)
    charge_type = models.CharField(max_length=50, blank=True)
    property = models.ForeignKey(Property, on_delete=models.CASCADE, related_name='unitprop', null=True)

    def __str__(self):
        return {self.unit_reference} - {self.unit_name}

class Tenant(models.Model):
    tenant_name = models.CharField(max_length=100)
    tenant_reference = models.CharField(max_length=50, blank=True)
    tenant_status = models.CharField(max_length=100, blank=True)
    address_1 = models.CharField(max_length=100,blank=True)
    address_2 = models.CharField(max_length=100,blank=True)
    address_3 = models.CharField(max_length=100,blank=True)
    address_4 = models.CharField(max_length=100,blank=True)
    address_5 = models.CharField(max_length=100,blank=True)
    postcode = models.CharField(max_length=10,blank=True)
    telephone_1 = models.CharField(max_length=12, blank=True) 
    telephone_2 = models.CharField(max_length=12, blank=True)
    mobile = models.CharField(max_length=12, blank=True)   
    email_1 = models.EmailField(blank=True)
    email_2 = models.EmailField(blank=True)
    start_date = models.DateField(blank=True)
    end_date = models.DateField(blank=True)
    unit = models.ForeignKey(Unit, on_delete=models.CASCADE, related_name='tenantunit', null=True)
    
    def __str__(self):
        return {self.tenant_reference} - {self.tenant_name}

ZP_DjangoProject/PPMS/views.py

from django.shortcuts import render

def PPMSindex(request):

    return render(request, 'PPMS/index.html')

ZP_DjangoProject/Reciept/urls.py

from django.urls import path
from .views import Recipetindex

app_name='Reciept'

urlpatterns = [
    path('',Recipetindex,name='Recieptindex'),
]

ZP_DjangoProject/Reciepts/models.py

from django.db import models

ZP_DjangoProject/Reciepts/views.py

from django.shortcuts import render
def Recipetindex(request):

    return render(request, 'Reciept/index.html')

ZP_DjangoProject/Transactions/urls.py

from django.urls import path
from .views import tranIndex

app_name='Transaction'

urlpatterns = [
    path('',tranIndex,name='tranindex')
]

ZP_DjangoProject/Transactions/models.py

from django.db import models

ZP_DjangoProject/Transactions/views.py

from django.shortcuts import render

# Create your views here.
def tranIndex(request):

    return render(request, 'Tran/index.html')

I’m not seeing any circular imports here.

Do you have any imports in your various apps.py files other than imports from Django?

No other import statements other than the standard import from Django

The admin files have model import statements where I have defined models

Just to confirm. In your post you have:

But, you then have:

and

I’m assuming this is just a typo in your post? That the directory here is actually “Reciept” and not “Reciepts”?

yeah that’s a typo by me

What command are you running that is creating this output?

What happens if you try to run manage.py shell? Do you still get this error? How about manage.py check?

What if you comment out the include for Receipt.urls? Does an error still occur? If it does, then the error you are receiving is a false flag - the real problem is somewhere else and is only showing up during the url import process.

The only other idea that I have right off-hand would be to use the python -v parameter to see all the imports that are done, and to try and identify where the issue is occurring.
(Don’t bother posting it here, it’s going to be too big. You’ll need to read through it to see if you can identify an issue.)

For even more output, you could use the trace module to see exactly what’s happening. I don’t generally recommend this, but there are times when you just need to “see” how things are happening.

Recipet not Reciept?