kikee1222
kikee1222

Reputation: 2026

Django Model class app.models.tasks doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

I have this view and model setup for my Django site.

When I run my page, I get the below error, and I have no idea why!

If anyone can recommend what I can do to fix this, I will be very grateful!

Can anyone help??

'Model class app.models.tasks doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Here is the code

from __future__ import unicode_literals
from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages
from django.http import *
from django.shortcuts import render_to_response,redirect
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserChangeForm
from django.db.models import Q
from django.db.models import Count
from datetime import datetime
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.forms import PasswordChangeForm
from datetime import date
from .models import tasks

def create_task(request):
    if request.method == 'POST':
        creator = request.user
        job_title = request.POST.get('job_title')
        skill_name = request.POST.get('skill_name')
        starting = request.POST.get('starting')
        description = request.POST.get('description')
        target_date = request.POST.get('target_date')
    i = tasks.objects.create(creator=creator, job_title=job_title, skill_name=skill_name,  starting=starting, current=starting, description=description, target_date=target_date)
    messages.success(request, ('Skill created'))
    return redirect('index')

I have this model:

from django.db import models

class tasks(models.Model):
    job_title = models.CharField(max_length=400, default="none")
    creator = models.CharField(max_length=400, default="none")
    skill_name = models.CharField(max_length=400)
    starting = models.CharField(max_length=400, default="none")
    current = models.CharField(max_length=400, default="none")
    description = models.CharField(max_length=4000000, default="none")
    target_date = models.CharField(max_length=400, default="none")
    def __str__(self):
        return self.text

Upvotes: 0

Views: 189

Answers (1)

error404
error404

Reputation: 2823

As per the comment above this error occurs when a new app has been configured but not part of INSTALLED_APPS in settings.py

Upvotes: 1

Related Questions