Invalid model reference ''. String model references must be of the form 'app_label.ModelName'.

Hey, Ive got this problem here. I will paste in my code too. After looking through the internet, I found this error, but only for custom User models.

In my example I have a simple Comment model:

class Comment(models.Model):
    author = models.ForeignKey(User, default=1, on_delete=models.SET_DEFAULT)
    published = models.DateField(auto_now_add=True)
    hidden = models.BooleanField(default=False)
    content = models.TextField()
    ref_comments = models.ManyToManyField('self', blank=True, related_name="comment_relation", default=None)
    parent = models.ForeignKey('self', default=None, null=True, on_delete=models.SET_DEFAULT)

    level = models.SmallIntegerField(default=1)
    no_of_reactions = models.IntegerField(default=0)

    def delete_tread(self):
        orphans = Comment.objects.filter(parent=None)
        for com in orphans:
            if not com.get_blog() and not com.get_vlog() and not com.get_popPost() and not com.get_article():

    def get_article(self):
        if self.article_relation.all():
            return self.article_relation.all()[0]
            return None

    def get_blog(self):
        if self.blog_relation.all():
            return self.blog_relation.all()[0]
            return None

    def get_vlog(self):
        if self.vlog_relation.all():
            return self.vlog_relation.all()[0]
            return None

    def get_popPost(self):
        if self.pop_relation.all():
            return self.pop_relation.all()[0]
            return None

    def __str__(self):
        return self.content

Error message:

File “/workspaces/coachGu-live/guru/”, line 100, in
class Comment(models.Model):
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/”, line 160, in new
new_class.add_to_class(obj_name, obj)
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/”, line 325, in add_to_class
value.contribute_to_class(cls, name)
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/fields/”, line 1585, in contribute_to_class
self.remote_field.through = create_many_to_many_intermediary_model(self, cls)
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/fields/”, line 1052, in create_many_to_many_intermediary_model
lazy_related_operation(set_managed, klass, to_model, name)
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/fields/”, line 80, in lazy_related_operation
return apps.lazy_model_operation(partial(function, **kwargs), *model_keys)
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/fields/”, line 78, in
model_keys = (make_model_tuple(m) for m in models)
File “/usr/local/python/3.10.13/lib/python3.10/site-packages/django/db/models/”, line 18, in make_model_tuple
raise ValueError(
ValueError: Invalid model reference ‘’. String model references must be of the form ‘app_label.ModelName’.

Please help me, and tell if I need to show other code snippets! Thanks

Hello there!
Is your inside another directory? I mean, your folder structure must look something like this:

|- your_app

it actually does, it is in a “guru”-app folder, which is inside the projects folder with the file

Can you share your project directory?
It looks like you’re using linux, you can use tree from the project directory and paste the output here as code.

Dockerfile Procfile coachGu guru requirements.txt search temp
GeoLiteCity.dat config home notes policy.json runtime.txt staticfiles

tree command would give out to many unimportant files like jquery ect., i am using codespaces on github because of me working with a client