Category: Django

66 posts · Page 2
Django
2021-01-20 11:10 (5 years ago)
Create Another Admin Site in Django

If you want to create a different URL for Django's Admin while keeping /admin/ intact: Create an instance using `from django.contrib.admin import AdminSite` and `site = AdminSite(name='staff')`.

DjangoMySQL
2020-11-08 10:53 (6 years ago)
mysql django.db.utils.InterfaceError: (0, '')

If you encounter the django.db.utils.InterfaceError: "(0, '')" error When this error occurs intermittently during get operations depending on the table or record, it might be due to a mismatch in the connection character encoding.

DjangoMySQLPython
2020-10-11 02:52 (6 years ago)
NameError: name '_mysql' is not defined in Python (Django) (Especially During Local Development)

If a Django project that has been working until now fails to start after a long time with the following error: ``` version_info, _mysql.version_info, _mysql.__file__ NameError: name '_mysql' is not defined ```

Django
2020-09-13 06:57 (6 years ago)
Starting Django on Docker Alpine Results in django.db.utils.OperationalError: (2000, 'Unknown MySQL error')

When running `python3 ./manage.py runserver 8080`, I encountered the error `django.db.utils.OperationalError: (2000, 'Unknown MySQL error')`. This error occurs when the `OPTIONS` setting includes `'charset': 'utf8mb4'`.

Django
2020-05-19 06:34 (6 years ago)
Manually Operating Viewsets in Django Rest Framework to Retrieve Serialized Data

Introduction to Python Code for APIView.

Django
2020-05-18 02:16 (6 years ago)
Fix: MySQL error 1467 'Failed to read auto-increment value from storage engine' — AutoIncrement exhausted in Django

MySQL raises error 1467 'Failed to read auto-increment value from storage engine' when a Django int id hits the AUTO_INCREMENT limit 2147483647. Check information_schema, then migrate the primary key to BigAutoField.

Django
2019-12-25 06:14 (6 years ago)
Upgrading to Django 3: from_db_value() missing 1 required positional argument: 'context' Error Occurs

Fix `from_db_value() missing 1 required positional argument: 'context'` on custom Django fields after upgrading to Django 3 — adapt to the removed `context` arg.

Django
2019-06-22 13:07 (7 years ago)
When Django's DecimalField quantize Fails on Alpine Linux

Stop PyCharm / JetBrains project view from opening files on a single click — how to require a double click instead.

Django
2019-03-25 23:57 (7 years ago)
How to Use freezegun in Django Tests to Set the Date One Day Ahead with USE_TZ=True

Use freezegun in Django tests so that "one day later" or relative offsets work correctly under `USE_TZ=True`.

DjangoPHP
2019-03-14 15:19 (7 years ago)
Using Vue.js Webpack Dev Server Proxy for Social Provider Authentication with Django + Python Social Auth

When developing with Vue, if you are running a webpack dev server and using Django for the API backend along with Django's authentication using Python social auth and an external Auth provider, you may encounter an issue.

Django
2018-09-27 02:37 (8 years ago)
Preventing "table already exists" error when canceling migrations in Django tests

Avoid `table already exists` failures in Django tests when running with `--keepdb` after cancelling migrations — how to forcibly reset the test DB migration state.

Django
2018-09-25 10:10 (8 years ago)
Unit Testing Abstract Models in Django

Django: Best way to unit-test an abstract model - Stack Overflowhttps://stackoverflow.com/questions/4281670/django-best-way-to-unit-test-an-abstract-model

Django
2018-07-12 11:24 (8 years ago)
Issues with Redirect URLs Being HTTP Instead of HTTPS in Python Social Auth Django or AllAuth

One-liner to count upgradable packages with `apt list --upgradable`, plus a shell script to surface the number in the MOTD login banner.

Django
2018-05-15 03:24 (8 years ago)
Creating a ForeignKey Across Databases in Django 2.0

※ This does not mean creating constraints in an RDB. It simply means creating a ForeignKey field that works for now.

Django
2018-03-29 06:37 (8 years ago)
NameError: name 'module1' is not defined when running ./manage.py test in Django

Make Django's `request.build_absolute_uri()` return HTTPS behind Apache + ELB — `USE_X_FORWARDED_HOST` and `SECURE_PROXY_SSL_HEADER` settings.

Django
2018-02-05 08:02 (8 years ago)
How to Unit Test a Django Model with managed = False

When using Django, setting `Meta: managed = False` in a model can sometimes lead to a `ProgrammingError` during unit tests from other apps when attempting operations such as `create()`. This is a memo on how to address this issue.

Django
2018-01-11 05:48 (8 years ago)
When Updating Django from 1.6 to 2.0, django.db.utils.InternalError: (1364, "Field 'name' doesn't have a default value") Occurs During Migration

When I tried to migrate a project using Python 2.7 + Django 1.6 to Python 3.5 + Django 2.0 and recreated the migration files, running ./manage.py migrate resulted in the following error:

DjangoLinux
2017-09-11 08:35 (9 years ago)
Install libgconf2 if Python Selenium ChromeDriver Fails to Start with Error 127

On Ubuntu 14.04, Selenium ChromeDriver exits with status 127 when `libgconf-2.so.4` is missing. Run `sudo apt install libgconf2-4` to fix it.

DjangoPython
2017-09-01 02:10 (9 years ago)
What to Do When You Encounter AuthAlreadyAssociated with Django Social Auth

I'm writing this down because I always get flustered.

Django
2017-05-09 08:49 (9 years ago)
Base View Class for Downloading CSV in SJIS with Django

Base View Class for Downloading SJIS CSV in Django