0

I have the following code:

models.py

    from django.db import models

    class Title(models.Model):
        title_name = models.CharField(max_length=200)
        category = models.CharField(max_length= 30)

    class Tags(models.Model):
        tag1 = models.CharField(max_length=15)
        tag2 = models.CharField(max_length=15)
        tag3 = models.CharField(max_length=15)
        tag4 = models.CharField(max_length=15)

    class Videos:
        primo: str

views.py

    from django.shortcuts import render, HttpResponse
    from django.http import HttpResponse
    from .models import Videos

    def home(request):
        vid = Videos()
        vid.primo = 'https://www.youtube.com/'
        return render(request, 'index.html', {'vid': vid})

settings.py

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
    ]

When I run the server I get: RuntimeError: Model class home.models.Title doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Everything was working before adding class Videos() and just using:

    def home(request):
        return render(request, 'index.html')

I don't understand what I should specify in the INSTALLED_APPS as I just added a new def to render a video URL inside my HTML. Why I get this error?

Thanks!

Steven
  • 63
  • 2
  • 12

0 Answers0