When working with Django models, you may encounter the error django.core.exceptions.FieldDoesNotExist. This exception means Django can't find a field you're trying to access on a model, usually because of a typo, a missing field definition, or an incomplete migration.
In this guide, we'll cover all the common causes of this error and walk through practical solutions with examples to help you fix it quickly.
What Is FieldDoesNotExist?
FieldDoesNotExist is a Django exception raised when you reference a field name that doesn't exist on a model. This can happen in views, serializers, admin configurations, querysets, or anywhere you interact with model fields by name.
The error typically looks like:
django.core.exceptions.FieldDoesNotExist: ModelName has no field named 'field_name'Common Causes
Before jumping into solutions, let's identify the most frequent reasons this error occurs:
| Cause | Description |
|---|---|
| Typo in field name | Misspelling a field name when querying or accessing it |
| Missing field definition | Referencing a field that was never added to the model |
| Unmigrated changes | Adding a field to the model code but not running migrations |
| Wrong model | Accessing a field on a model where it doesn't exist |
| Inheritance issues | Expecting a field from a parent model that isn't defined there |
| Stale admin/serializer config | Admin classes or serializers referencing fields that were renamed or removed |
Solutions
Solution 1: Fix Misspelled Field Names
The most common cause is a simple typo. Python is case-sensitive, so Price, price, and PRICE are all different names.
❌ Wrong: Typo in the field name:
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=100)
price = models.IntegerField()
results = Product.objects.filter(prce=1000) # 'prce' instead of 'price'Output:
django.core.exceptions.FieldDoesNotExist: Product has no field named 'prce'✅ Correct: Use the exact field name from the model:
results = Product.objects.filter(price=1000)Solution 2: Add the Missing Field and Migrate
If you're trying to access a field that was never defined in the model, you need to add it and run migrations.
❌ Wrong: Accessing a field that doesn't exist on the model:
class Product(models.Model):
name = models.CharField(max_length=100)
price = models.IntegerField()
products = Product.objects.filter(category="Electronics")Output:
django.core.exceptions.FieldDoesNotExist: Product has no field named 'category'✅ Correct: Add the field to the model and migrate:
Step 1: Add the field to your model:
class Product(models.Model):
name = models.CharField(max_length=100)
price = models.IntegerField()
category = models.CharField(max_length=50, default="General") # New fieldStep 2: Create and apply the migration:
python manage.py makemigrations
python manage.py migrateStep 3: Now the query works:
products = Product.objects.filter(category="Electronics")Solution 3: Ensure Migrations Are Up to Date
If you've added a field to your model code but the error persists, your migrations may not have been applied properly.
Check for pending migrations:
python manage.py showmigrationsLook for unapplied migrations (marked with [ ] instead of [X]):
app_name
[X] 0001_initial
[ ] 0002_product_category ← Not applied!Apply pending migrations:
python manage.py migrateIf migrations are corrupted or out of sync, you may need to recreate them:
python manage.py makemigrations app_name
python manage.py migrate --fake app_name zero
python manage.py migrate app_nameSolution 4: Check You're Using the Correct Model
When a project has multiple models, it's easy to query a field on the wrong model:
❌ Wrong: Querying category on Order instead of Product:
class Product(models.Model):
name = models.CharField(max_length=100)
category = models.CharField(max_length=50)
class Order(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.IntegerField()
orders = Order.objects.filter(category="Electronics") # FieldDoesNotExist!✅ Correct: Use the relationship to traverse to the right model:
orders = Order.objects.filter(product__category="Electronics")Solution 5: Fix Admin and Serializer Configurations
The error frequently appears in Django Admin or DRF serializers when they reference fields that have been renamed or removed from the model.
❌ Wrong: Admin class references a removed field:
from django.contrib import admin
from .models import Product
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ['name', 'price', 'description'] # 'description' doesn't existOutput:
django.core.exceptions.FieldDoesNotExist: Product has no field named 'description'✅ Correct: Only reference fields that exist on the model:
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ['name', 'price', 'category'] # All fields existThe same applies to Django REST Framework serializers:
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ['name', 'price', 'description'] # 'description' doesn't exist
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ['name', 'price', 'category']Solution 6: Handle Model Inheritance Properly
If you're using model inheritance, make sure the field you're accessing is defined in the correct class in the hierarchy:
❌ Wrong: Accessing a child field on the parent model:
class Vehicle(models.Model):
make = models.CharField(max_length=50)
model = models.CharField(max_length=50)
class Car(Vehicle):
num_doors = models.IntegerField()
vehicles = Vehicle.objects.filter(num_doors=4) # FieldDoesNotExist!✅ Correct: Query the correct model:
cars = Car.objects.filter(num_doors=4)Debugging Workflow
When you encounter FieldDoesNotExist, follow this systematic approach:
from myapp.models import Product
print([f.name for f in Product._meta.get_fields()])
Quick Reference
| Cause | Fix |
|---|---|
| Typo in field name | Correct the spelling; check with _meta.get_fields() |
| Field never defined | Add it to the model and run migrations |
| Migrations not applied | Run python manage.py migrate |
| Wrong model | Use the correct model or follow relationships with __ |
| Admin/serializer references old field | Update list_display, fields, etc. to match current model |
| Inheritance confusion | Query the model where the field is actually defined |
Conclusion
The django.core.exceptions.FieldDoesNotExist error occurs when you reference a field name that doesn't exist on a Django model.
The fix depends on the root cause: correct typos in field names, add missing fields and run migrations, verify you're querying the right model, and update admin or serializer configurations to match your current model schema.
When in doubt, use Model._meta.get_fields() to inspect the actual fields available on any model, and always run python manage.py showmigrations to confirm your database schema is up to date.