I tried Django

Knowing that there is Django, there was a tutorial site first, so I tried it. Since I am new to Python, there were many places where I failed, so I made a note to look back. There should be no problem for people who are used to it. Or rather, if you matched the versions of Python and Django on your Mac as per the tutorial, there should have been no problem.

Tutorial site I tried this time

https://djangobrothers.com/ The guy who makes the blog management site of

environment

Where I stumbled

  1. Creating a virtual environment
  2. Enter the virtual environment
  3. pip update
  4. Display in the directory
  5. Create an empty file
  6. Error on admin page
  7. I can't post a blog from the admin page

1. Creating a virtual environment

cd /d C:\XXX\
python3 -m venv virtual environment name

I didn't even get an error. In Python3, you can use python, so solve it with the following command.

cd /d C:\XXX\
python -m venv virtual environment name

2. Enter the virtual environment

For Windows

.\Virtual environment name\Scripts\activate

3. pip update

(Virtual environment) >pip install --upgrade pip
...
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
ERROR: Could not install packages due to an EnvironmentError: [WinError 5]Access denied.: 'xxx\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.

Adding --user as instructed does not succeed. Probably because it has been uninstalled.

(Virtual environment) >pip install --upgrade pip --user
Traceback (most recent call last):
  File "xxx\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "xxx\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "xxx\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

You can install pip, but it's easier to initialize the virtual environment

cd /d Directory above the virtual environment#Move to a directory above the virtual environment
python -m venv --clear virtual environment name#Initialization
.\Virtual environment name\Scripts\activate  #Enter the virtual environment
(Virtual environment) >pip install --upgrade pip --user

4. Display in the directory

On Windows, the dir command instead of ls

5. Create an empty file

On Windows

copy nul index.html

6. Error on admin page

http://127.0.0.1:8000/adminページでエラーが出た A server error occurred. Please contact the administrator.

Looking at the command prompt screen

    raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'Asia/Tkyo'

I forgot to write o in settings.py

#TIME_ZONE = 'Asia/Tkyo'
TIME_ZONE = 'Asia/Tokyo'

7. I can't post a blog from the admin page

django.db.utils.OperationalError: no such table: main.auth_user__old

Reference page https://kenjimorita.jp/operationalerror-at-adminpostspostadd-no-such-table-main-auth_user__old/ https://stackoverflow.com/questions/53637182/django-no-such-table-main-auth-user-old

  1. keep django version 2.1.5 (the issue addressed in this version) pip install django==2.1.5
  2. Delete the SQLite db
  3. Migrate again python manage.py makemigrations and then python manage.py migrate
  4. Start the server python manage.py runserver

I think it's because SQLite was new because my environment didn't follow the tutorial Django Version:2.0.2 Sqlite3:3.28.0

Resolved by recreating SQLite db with django 2.1.5

pip install django==2.1.5
del db.sqlite3
python manage.py migrate
python manage.py runserver
python manage.py createsuperuser

Recommended Posts

I tried Django
I tried scraping
I tried PyQ
I tried AutoKeras
I tried papermill
I tried django-slack
I tried spleeter
I tried cgo
I tried the asynchronous server of Django 3.0
I tried using parameterized
I tried using argparse
I tried using mimesis
I tried using anytree
I tried competitive programming
I tried running pymc
I tried ARP spoofing
I tried using aiomysql
I tried using Summpy
I tried Python> autopep8
I tried using coturn
I tried using Pipenv
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried PyCaret2.0 (pycaret-nightly)
I tried using openpyxl
I tried deep learning
I tried AWS CDK!
I tried using Ipython
I tried to debug.
I tried using PyCaret
I tried using cron
I tried Kivy's mapview
I tried using ngrok
I tried using face_recognition
I tried to paste
I tried using PyCaret
I tried moving EfficientDet
I tried shell programming
I tried using Heapq
I tried using doctest
I tried running TensorFlow
I tried Auto Gluon
I tried using folium
I tried using jinja2
I tried AWS Iot
I tried Bayesian optimization!
I tried using folium
I tried using time-window
I tried Value Iteration Networks
I tried fp-growth with python
I tried scraping with Python
I tried to create a table only with Django
I tried AutoGluon's Image Classification
I tried to learn PredNet
I tried Learning-to-Rank with Elasticsearch!
[I tried using Pythonista 3] Introduction
I tried to organize SVM.
I tried using Random Forest
I tried clustering with PyCaret
I tried using BigQuery ML