RuntimeError, Conflicting 'product' models and also RuntimeError: app_label

I’m getting error:

  File "/home/pi/PROJECTS/mysite29/mysite/mysite/users/models.py", line 6, in <module>
    from products.models import Product
  File "/home/pi/PROJECTS/mysite29/mysite/mysite/products/models.py", line 4, in <module>
    class Product(models.Model):
  File "/home/pi/.virtualenvs/mysite29/lib/python3.9/site-packages/django/db/models/base.py", line 113, in __new__
    raise RuntimeError(
RuntimeError: Model class products.models.Product doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.


So I put this in my Product model:

	class Meta:
		app_label = "mysite.products"

The error changes to:

  File "/home/pi/PROJECTS/mysite29/mysite/mysite/products/models.py", line 4, in <module>
    class Product(models.Model):
  File "/home/pi/.virtualenvs/mysite29/lib/python3.9/site-packages/django/db/models/base.py", line 321, in __new__
    new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
  File "/home/pi/.virtualenvs/mysite29/lib/python3.9/site-packages/django/apps/registry.py", line 228, in register_model
    raise RuntimeError(
RuntimeError: Conflicting 'product' models in application 'mysite.products': <class 'products.models.Product'> and <class 'mysite.products.models.Product'>.


I just can’t work out the right combination of the path namespace in the base urls.py, the installed app in settings, the app_name in urls.py and the ProductConfig.name in the apps.py to get it working.

My main urls.py has:

...
from mysite.products.views import ProductListView

urlpatterns = [
    ...
    path('discover/', ProductListView.as_view(), name="discover"),
    path("p/", include("mysite.products.urls", namespace="products")),
    ...
] 

My products app urls.py is:

from django.urls import path
from .views import ProductDetailView


app_name = "products"
#app_name = apps.ProductsConfig.name

urlpatterns = [
	path("<slug>/", ProductDetailView.as_view(), name="product-detail"),
]

The views.py in the products app is:

from django.views import generic
#from django.views.generic import ListView, DetailView
from .models import Product


class ProductListView(generic.ListView):
	template_name = "discover.html"
	queryset = Product.objects.all()

class ProductDetailView(generic.DetailView):
	template_name = "products/product.html"
	queryset = Product.objects.all()

My base.py settings file has:

LOCAL_APPS = [
    "mysite.users",
    "mysite.products.apps.ProductsConfig",
    #"products.apps.ProductsConfig",
    #"products",
    #"mysite.products",    
]

my models.py has:

from django.db import models


class Product(models.Model):
	name = models.CharField(max_length=100)
	description = models.TextField()
	cover = models.ImageField(blank=True, null=True, upload_to="product_covers/")
	slug = models.SlugField()
	content_url = models.URLField(blank=True, null=True)
	content_file = models.FileField(blank=True, null=True)
	price = models.PositiveIntegerField(default=100)

	# class Meta:
		# app_label = "mysite.products"
	
	def __str__(self):
		return self.name

my apps.py is:

from django.apps import AppConfig


class ProductsConfig(AppConfig):
#    default_auto_field = 'django.db.models.BigAutoField'
    name = "mysite.products"
    #name = "products"

I’m using django cookiecutter and it seems like it would be straight forward to copy the same way the users app is set up however I still get the app_name error. I tried a bunch of combinations over a few days and looked on stack overflow and youtube, and I’m not getting the same results with the way other people put their settings. Can you see which section is causing the conflict? Thanks

I got it working.
Solution:
The default users app for cookiecutter was registered in base.py as:
“mysite.users”,
Instead of:
“mysite.users.apps.UsersConfig”,

It seems this still worked until I referenced the mysite.products.models.Product model in the mysite.users.models, now that both the users and products apps are registered in the full way like this it works:

LOCAL_APPS = [
“mysite.users.apps.UsersConfig”,
“mysite.products.apps.ProductsConfig”,
]