Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGilang Ilhami
12,045 PointsStep is not defined
When i tried to tun the server, it gave me an error
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/importlib/__init__.py", line 126, in import
_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/treehouse/workspace/learning_site/courses/admin.py", line 6, in <module>
admin.site.register(Step)
NameError: name 'Step' is not defined
i don't see any flaws in the module.py and admin.py
from django.db import models
# Create your models here.
class Course(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=255)
description = models.TextField()
def __str__(self):
return self.title
class Step(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
order = models.IntegerField(default=0)
course = models.ForeignKey(Course)
def __str__(self):
return self.title
from django.contrib import admin
from .models import Course
admin.site.register(Course)
admin.site.register(Step)
Please someone, help!
2 Answers
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsIt looks like you have an error in your admin.py file.
from django.contrib import admin
from .models import Course
admin.site.register(Course)
admin.site.register(Step) # Step was not defined or imported yet
Dariush Azimi
310 PointsYou need to add it as Chris mentioned to your import line
from .models import Course, Step