Lesson 6.15 Using Generic Relationships important import

I was struggling to get the tags to show up in the when adding a new product. I kept getting the error

NameError: name ‘TaggedItem’ is not defined

After trying a while to figure out the right syntax to import the TaggedItem class from the tag/models folder, I gave up and went on to the next lesson. And first thing, Mosh shows importing it like so:

from tags.models import TaggedItem

I went back through lesson 15 and and in all the “from … import …” statements and it’s not there! It’s simply the

from . import models

so it won’t import anything from the tags folder since it’s not in the current folder (using the ‘.’ only imports from the current folder.

So make sure to import

from tags.models import TaggedItem

to get it to run!

1 Like

Thanks for Posting!

This solution must be implemented to get lesson 15 working! However, in the next lesson ( 16 Extending Pluggable Apps ) Mosh goes over the way to achieve this without the dependency.

Similar solution for Lesson 16: you must add

from store import models

into the store_custom admin.py

and then unregister models.Product