There was a problem testing Django today, and I was badly burned.
D:\pythonCode\django\mysite>django-admin.py startproject mysite
And then I’m going to create my APP, which I’m going to call MB
python manage.py startapp mb
The directory structure is as follows:
D:.
│ manage.py
│
├─mb
│ admin.py
│ models.py
│ models.pyc
│ tests.py
│ views.py
│ __init__.py
│ __init__.pyc
│
└─mysite
settings.py
settings.pyc
urls.py
wsgi.py
__init__.py
__init__.pyc
For testing, I created a very simple model
Modify the MB – & gt; Models.py, with only one field
from django.db import models
# Create your models here.
class Test(models.Model):
testField = models.TextField()
Modify the mysite – & gt; settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mysite.mb',
)
Note: This is where I want the database to be set to
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'D:\\test.db',
}
}
When performing database tests
manage.py sql mb
Error message:
ImportError: No module named mb
Well, I set it in Settings.py, why don’t I have this model?
I don’t know, Baidu, will mysite-> Settings. Py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mb',
)
This time, there it is
BEGIN;
CREATE TABLE "mb_test" (
"id" integer NOT NULL PRIMARY KEY,
"testField" text NOT NULL
)
;
COMMIT;
It looks like a success, but why?For explanation.
Read More:
- ImportError: No module named indexes.base
- Python:ImportError: No module named indexes.base
- Importerror: the perfect solution of no module named CV2!!! (not too good)
- Importerror: no module named typing error reporting solution (python2 PIP needs to be backed back from 21)
- How to solve the problem of error reporting in the introduction of Python Django no module name ‘Django. Utils. Six’
- django.core.exceptions . improveconfigured: error loading MySQL DB module. Django configuring MySQL database
- django.db.utils.OperationalError: no such table: django_admin_log
- Module not founderror: no module named ‘nets.ssd‘
- Error loading pscopg2 module: no module named pscopg2
- Module not found error: the solution to the problem of no module named ‘MySQL’
- ModuleNotFoundError: No module named xxx
- Unable to call numpy in pychar, module notfounderror: no module named ‘numpy’
- Error no module named ‘in newly installed Python_ sqlite3‘
- How to Fix gdb error: Failed to import the site module,No module named ‘_sysconfigdata_m’
- ModuleNotFoundError: No module named ‘numpy.testing.nosetester‘
- [Solved] ModuleNotFoundError: No module named ‘win32api’
- ModuleNotFoundError: No module named ‘ahocorasick‘ [100% Work Method]
- ModuleNotFoundError: No module named ‘mmcv._ext
- ModuleNotFoundError: No module named ‘notebook‘
- Modulenotfounderror: no module named ‘CV2’ – (version problem)