I try to reinitialize my DB and I have this error:
django.db.utils.OperationalError: no such table: app_evaluation
I don't have any variable with this name, I try to dele db.sqlite3 and all files of migrations folder and run the migrate and makemigrations command but nothings works
models.py
from django.db import models
from jsonfield import JSONField
from site_.settings import MEDIA_ROOT
from django.core.validators import MaxValueValidator
class Criterion(models.Model):
label = models.CharField(max_length=100)
def __str__(self):
return self.label
class Candidate(models.Model):
name = models.CharField(max_length=100)
e_mail = models.EmailField(max_length=100, default = '')
github = models.URLField(default = '')
linkedin = models.URLField(max_length=100, default = '')
cover_letter = models.TextField(default = '')
higher_education = models.BooleanField(default = False)
average = models.IntegerField(default = 0)
#############################################################score = models.ForeignKey()
docfile = models.FileField(upload_to='/home/douglas/Documentos/Django/my-second-blog/site_/media', null=True, blank=True)
def __str__(self):
return self.name
class Evaluation(models.Model):
candidate = models.ForeignKey(Candidate, unique=True)
#s_candidate = models.CharField(max_length=100)
criterion = models.ForeignKey(Criterion, default='')
score = models.PositiveIntegerField(default = 0, validators=[MaxValueValidator(10)])
appraiser = models.ForeignKey('auth.User')
def __str__(self):
return str(self.candidate)
class avarage(models.Model):
eva = Evaluation.objects.get()
view.py
from django.shortcuts import render, get_object_or_404
from .models import Candidate, Criterion, Evaluation
from django import forms
from .forms import CandForm
from .forms import EvalForm
from django.shortcuts import redirect
def canditate_list(request):
candidates = Candidate.objects.all()
eva = Evaluation.objects.all()
eval_cand_list = [] #aqui guarda uma lista com os FK candidates convertidos p/ str
context = {
'candidates': candidates,
'eva': eva
}
return render(request, 'app/candidate_list.html',context)
def candidate_detail(request, pk):
candidate = get_object_or_404(Candidate, pk=pk)
c_name = candidate.name #pega o nome (string) do candidato
c1 = Evaluation.objects.all() #guarda tds Evaluation na variavel
scores = [] #declara a array que vai receber as notas
for c in c1:
cand = str(c.candidate) #guarda o nome do candidato do Evaluation atual
if cand == c_name: #confere se o Evaluation atual corresponde ao candidate atual(pk)
scores += [c.score]
_sum = 0 #variavel que guardara a soma declarada
for s in scores:
_sum += s #faz a soma dos scores
average = _sum/len(scores) #tira a média
context = {
'candidate': candidate,
'average': average
}
return render(request, 'app/candidate_detail.html', context)
def evaluation(request):
if request.method == "POST":
form2 = EvalForm(request.POST)
if form2.is_valid():
post = form2.save(commit=False)
post.save()
return redirect('canditate_list')
else:
form2 = EvalForm()
return render(request, 'app/evaluation.html', {'criterions': form2,})
def register(request):
if request.method == "POST":
form = CandForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.save()
return redirect('candidate_detail', pk=post.pk)
else:
form = CandForm()
return render(request, 'app/register.html', {'form': form})
[EDIT]:
I try to follow this: How do I drop a table from SQLite3 in DJango? tips but always the same error.