Model imports shown, but giving NameError on usage.
See original GitHub issueVersion:
- django-extensions==2.2.8
- Django==3.0.2
- ipython==7.13.0
Sample output:
(2004)-> ./manage.py shell_plus --ipython
[TerminalIPythonApp] WARNING | File not found: '/home/ash/.pythonrc'
# Shell Plus Model Imports
from allauth.account.models import EmailAddress, EmailConfirmation
from allauth.socialaccount.models import SocialAccount, SocialApp, SocialToken
from catalogue.models import Brand, Category, Product, ProductImage
from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.models import Session
from django.contrib.sites.models import Site
from orders.models import LineItem, Order, Review
from rest_framework.authtoken.models import Token
from users.models import User
# Shell Plus Django Imports
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import transaction
from django.db.models import Avg, Case, Count, F, Max, Min, Prefetch, Q, Sum, When, Exists, OuterRef, Subquery
from django.utils import timezone
from django.urls import reverse
Python 3.8.2 (default, Feb 26 2020, 04:23:39)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
[TerminalIPythonApp] WARNING | File not found: '/home/ash/.pythonrc'
In [1]: User
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-1974857568df> in <module>
----> 1 User
NameError: name 'User' is not defined
Also, in my settings I already have this:
# Custom user app
AUTH_USER_MODEL = 'users.User'
# settings/local.py
INSTALLED_APPS += ('django_nose', 'django_extensions',)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
Top Results From Across the Web
NameError in Django model? Why Cant I reference ...
It is the order in which the classes are defined. Python interpreter does not do a forward lookup This should fix your issue....
Read more >NameError: Name plot_cases_simple is Not Defined
In Python, the NameError occurs when you try to use a variable, function, or module that doesn't exist or wasn't used in a...
Read more >How to Fix: NameError name 'np' is not defined
This error occurs when you import the python library NumPy, but fail to give it the alias of np when importing it. The...
Read more >NameError: name 'pandas' is not defined – How To Fix
Pandas NameError can be annoying. It generally means you have not imported pandas, or if you did, you're not calling the right name...
Read more >ModuleNotFoundError: No module named x
tl;dr. Use absolute imports; Append your project's root directory to PYTHONPATH — In any environment you wish to run your Python application ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI, the problem is gone in our project since we removed
django_nose
. I tried to reproduced the issue in a minimal project withdjango_extensions
,ipython
anddjango_nose
but it works as expected so there’s something more needed to reproduce the issue.Works fine for me.
Please make sure to test this stuff and verify it’s reproducible. There tons of things that might be “different” or missing in configuration in my sample project making it not fail for me.
Alternatively, if somebody (eg; you are a company who is having this issue in your project) is willing to sponsor this ticket, I can take a look at the project to fix it.