i am getting a error:
AttributeError at /
'function' object has no attribute 'objects'
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 3.2.5
Exception Type: AttributeError
Exception Value:
'function' object has no attribute 'objects'
Exception Location: G:\PYTHON DJANGO 2021 - COMPLETE COURSE\first_django_project\devsearch\project\views.py, line 27, in projects
Python Executable: C:\ProgramData\Anaconda3\envs\djangoenv\python.exe
Python Version: 3.9.6
Python Path:
['G:\PYTHON DJANGO 2021 - COMPLETE COURSE\first_django_project\devsearch',
'C:\ProgramData\Anaconda3\envs\djangoenv\python39.zip',
'C:\ProgramData\Anaconda3\envs\djangoenv\DLLs',
'C:\ProgramData\Anaconda3\envs\djangoenv\lib',
'C:\ProgramData\Anaconda3\envs\djangoenv',
'C:\ProgramData\Anaconda3\envs\djangoenv\lib\site-packages']
Server time: Sat, 21 Aug 2021 13:18:04 +0000
# models.py
from django.db import models
import uuid
# Create your models here.
class Project(models.Model):
title = models.CharField(max_length=200)
description = models.TextField(null=True,blank=True)
demo_link = models.CharField(max_length=2000,null=True,blank=True)
source_link = models.CharField(max_length=2000,null=True,blank=True)
tag = models.ManyToManyField('Tag',blank=True)
vote_total = models.IntegerField(default=0,null=True,blank=True)
vote_ratio = models.IntegerField(default=0,null=True,blank=True)
created_on = models.DateTimeField(auto_now_add=True)
id = models.UUIDField(default=uuid.uuid4,unique=True,primary_key=True,editable=False)
def __str__(self):
return self.title
# views.py
from django.shortcuts import render
from .models import Project
# Create your views here.
def projects(requests):
projects = Project.objects.all()
return render(requests,"project/projects.html", {'projects':projects})
Project
in your file? – Willem Van Onsem