Saya sedang belajar mengembangkan di Django dan saya menggunakan PyCharm pada proyek saya dan saya ingin menggunakan konsol iPython di dalamnya.
iPython diluncurkan, bukan ini masalahnya.
Masalahnya adalah ketika saya meluncurkan iPython dari konsol, semua model saya dan kelas utils lainnya diimpor.
Inilah yang terjadi ketika saya meluncurkan perintah python3 manage.py shell_plus
:
# Shell Plus Model Imports
from app.models.models import Model1, Model2, Model3
from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import Group, Permission, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.models import Session
# 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
/myproject/env/lib/python3.7/site-packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
warn("IPython History requires SQLite, your history will not be saved")
Python 3.7.4 (default, Jul 23 2019, 18:02:54)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]:
Sementara itu ketika saya memulai Konsol Python di PyCharm, tidak ada impor yang dilakukan dan saya harus mengimpor semua model saya secara manual. Inilah yang terjadi di Konsol PyCharm Python:
/home/user/myproject/env/bin/python /snap/pycharm-community/188/plugins/python-ce/helpers/pydev/pydevconsole.py --mode=client --port=33543
/home/user/myproject/env/lib/python3.7/site-packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
warn("IPython History requires SQLite, your history will not be saved")
import sys, django
print('Python %s on %s' % (sys.version, sys.platform))
Python 3.7.4 (default, Jul 23 2019, 18:02:54)
Type 'copyright', 'credits' or 'license' for more information
In[2]:
Jelas, sebuah perintah dijalankan pada perintah shell_plus yang tidak ada di konsol PyCharm.
Dan berikut adalah versi yang digunakan.
Ubuntu = 18.04 LTS
python = 3.7.4
iPython = 7.13.0
Django = 3.0.5
PyCharm = 2019.3.4 Community
Terima kasih atas bantuan Anda, saya dapat membantu saya.