Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type object is not iterable Django

I am creating a personal portfolio website using Django. I am making a new model, called 'Skill', and I want a different instance of the model for each skill which I have. I have previous experience with Django, so I am simply doing the same process as always. However, for some reason, this time I get an error when registering the model - TypeError: 'type' object is not iterable. I have already added the skills app to my list of apps.

Does anyone know why this is happening? Here is my views.py

from django.shortcuts import render
from .models import Skill
# Create your views here.

def skills(request):
    Skills = Skill.objects.all()
    return render(request,'skills\skills.html')

Here is my models.py

from django.db import models

# Create your models here.
class Skill():
    title = models.CharField(max_length = 250)

    def __str__(self):
        return (self.title)

And here is my admin.py

from django.contrib import admin

from .models import Skill
# Register your models here.
admin.site.register(Skill)

I am not even calling this model yet in any html file - making migrations or running the server will give me this error.

All help is appreciated. Thank you.

like image 998
Pranav E Avatar asked Dec 17 '25 11:12

Pranav E


1 Answers

You have not inherited from models.Model in your Skill model.

Change your models.py as follows

class Skill(models.Model):
   title = models.CharField(max_length=250)

I think this answer helped you. :)

like image 94
Suresh Kumar Avatar answered Dec 19 '25 06:12

Suresh Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!