Category: Django

Django
2025-03-13 09:25 (11 months ago)

When upgrading Django to version 5.1, you may encounter an issue in the admin site's Inline where a string like `{'name': 'id', 'label': 'ID', 'help_text': '', 'field': 'id', 'is_hidden': True}` is displayed in place of the primary key. This issue may occur only when using Grappelli.

Django
2024-12-14 04:46 (14 months ago)

How to Create a Login View in Django Allauth Without Specifying the Social Account Backend in the URL

Django
2024-04-15 08:35 (22 months ago)

I updated Django to version 5.0 and also updated other libraries. When I executed the code for sending an email, an ssl.SSLCertVerificationError occurred.

DjangoPython
2024-03-28 00:41 (23 months ago)

When looking at the assertEqual method in Django's unit tests, the first argument is named 'first' and the second argument is named 'second'. It appears that there is no difference in the usage of these variables.

DjangoPython
2024-03-24 04:53 (23 months ago)

This blog post covers the steps to build a Python 3.12 environment and discusses how to create a new virtual environment using Pipenv. It focuses on a specific issue that might arise when running the `pipenv install` command, which results in the error: AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'? The post provides a detailed checklist and solutions to address this error.

DjangoPython
2023-11-09 03:39 (2 years ago)

Here is an English translation of the summary for a blog post on how to address the error "symbol not found in flat namespace '_mysql_affected_rows'" when attempting to use MySQLdb in Python: --- **How to Address the "symbol not found in flat namespace '_mysql_affected_rows'" Error When Using MySQLdb in Python** In this blog post, we will discuss the steps to resolve the error "symbol not found in flat namespace '_mysql_affected_rows'" that may occur when attempting to use the MySQLdb library in Python. This error typically arises due to issues with the MySQLdb installation or compatibility problems between the library and your system. We will explore various troubleshooting methods and provide detailed instructions to help you get MySQLdb running smoothly.

Django
2023-10-12 12:41 (2 years ago)

Here's an overview in English: How to change the user of an already established session using the Django shell. Please do not attempt this in a production environment as it can be dangerous.

Django
2022-12-27 10:15 (3 years ago)

This article explains how to directly view the contents of Django Redis using the Django shell.

Django
2022-11-18 10:16 (3 years ago)

I usually write data copy scripts in bash, but I tried writing one in Python this time and decided to document it.

Django
2022-11-02 12:34 (3 years ago)

During an IT audit, it was necessary to represent the scale of the application. To achieve this, I decided to consider the total number of URLs in Django as an indicator of the application's scale.

Django
2022-10-17 11:24 (3 years ago)

Here is the code to create a password reset URL using Django all_auth.

Django
2022-09-16 10:11 (3 years ago)

The migration for the `oauth2_provider` app included in Django's `django-oauth-toolkit` failed at migration 0004. The issue was resolved by manually removing the foreign key, changing the integer field to a bigint, and then reapplying the foreign key.

Django
2022-09-12 12:21 (3 years ago)

Summary of the blog post in English: "Django Logging Configuration: Output to Console Instead of File"

DjangoMySQL
2022-09-11 09:58 (3 years ago)

Here is a summary of the blog article in English: "When issuing raw SQL in Django, an error '2027 Malformed packet' may occur with certain SQL statements. A helpful solution is to avoid using double quotations."

DjangoDockerPython
2022-09-03 11:03 (3 years ago)

Until now, I often created Django images using Alpine Linux and uWSGI, but there is a performance issue when running Python on Alpine Linux. This is a note on changing the Docker image configuration from Alpine to Debian and the HTTP server from uWSGI to Daphne + WhiteNoise.

Django
2022-08-06 02:09 (3 years ago)

If you are using version 4 of tinyMCE, you can add an onChange event in the setup option of tinyMCE.init.

Django
2022-03-21 08:57 (3 years ago)

When creating unit tests in Django, there are times when you need a Request (WSGIRequest).

Django
2021-12-11 13:51 (4 years ago)

Here is the solution for resolving the ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' that occurs when running manage.py hoge in Django.

DjangoMySQL
2021-11-14 11:10 (4 years ago)

When querying MySQL (5.7) with Django, the process started to stop due to the error (2013, 'Lost connection to MySQL server during query'). First, check the innodb_strict_mode setting in the current connection. Use the command SHOW VARIABLES LIKE '%innodb_strict_mode%'; It needs to be set to ON.

Django
2021-01-26 08:21 (5 years ago)

### How to Add Custom HTML to Django Admin Inlines If you want to add custom HTML to Django Admin inlines, simply defining custom properties in the Admin or model class and trying to handle them with `fields` or `fieldsets` in the Inline class won't work smoothly. It's better to straightforwardly extend the inline templates.

Django
2021-01-20 11:10 (5 years ago)

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 (5 years ago)

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 (5 years ago)

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 (5 years ago)

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 (5 years ago)

Introduction to Python Code for APIView.

Django
2020-05-18 02:16 (5 years ago)

MySQLdb._exceptions.OperationalError: (1467, 'Failed to read auto-increment value from storage engine') In Django, when you specify an implicit id, the above error occurs if the auto increment value reaches its upper limit.

Django
2019-12-25 06:14 (6 years ago)

If you encounter the error "TypeError: from_db_value() missing 1 required positional argument: 'context'", it indicates that there is an issue with the `from_db_value` method in Django. In Django 3, the arguments for the `from_db_value` method in model fields have been changed.

Django
2019-06-22 13:07 (6 years ago)

Failed to run tests for Django Cartridge in an Alpine Docker environment

Django
2019-03-25 23:57 (6 years ago)

Freezegun is a Python library that hooks into the datetime module to allow for testing scenarios that require manipulating the current time, such as simulating the next day. When running tests in Django that assume the next day, there can be issues, such as tests failing before 9:00 AM if the system is set to the JST timezone.

DjangoPHP
2019-03-14 15:19 (6 years ago)

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 (7 years ago)

During testing of Django Mezzanine Cartridge, I encountered an issue when cancelling a migration. I had configured the settings in a certain way, but due to problems involving the ManyToMany field's `through=`, the process halted with a "table already exists" error, preventing the creation of the table and thus stopping the tests.

Django
2018-09-25 10:10 (7 years ago)

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 (7 years ago)

Django Social Auth's Django module and AllAuth's redirection protocol scheme becoming HTTP instead of HTTPS (callback_uri, redirect_uri, destination) was troublesome.

Django
2018-05-15 03:24 (7 years ago)

※ 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 (7 years ago)

How to Address the Error "NameError: name 'module1' is not defined" in Django

Django
2018-02-05 08:02 (8 years ago)

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 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 (8 years ago)

Ubuntu 14.04

DjangoPython
2017-09-01 02:10 (8 years ago)

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

Django
2017-05-09 08:49 (8 years ago)

Base View Class for Downloading SJIS CSV in Django

Django
2017-02-26 10:25 (9 years ago)

Using SimpleListFilter for Easy Implementation

Django
2017-01-26 04:11 (9 years ago)

Since I often make mistakes, here's a note.

DjangoLinux
2016-09-16 03:24 (9 years ago)

Originally, the configuration was AWS ELB -> Apache2 -> mod_wsgi, but after changing the Django server to use uWSGI, the configuration became AWS ELB -> Apache2 -> uWSGI. After this change, I started experiencing issues with Django's CSRF authentication, such as when submitting a login form. When I checked with DEBUG = True, I saw the following message: Access Forbidden (403) The request was aborted due to failure in CSRF verification. Help Reason given for failure: Referer checking failed - https://example.com.com/some-path/ does not match any trusted origins. In general, this can occur when there is a genuine Cross-Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure: Your browser is accepting cookies. The view function passes a request to the template's render method. In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL. If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data. You're seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed. You can customize this page using the CSRF_FAILURE_VIEW setting. The ELB receives HTTPS, sends requests to Apache on port 80, and uWSGI is listening for HTTP protocol (not uWSGI protocol). The Apache configuration is as follows: ProxyPass / http://127.0.0.1:8081/ ProxyPassReverse / http://127.0.0.1:8081/ Alias /static/ /var/django/xxxxx/staticfiles/ ProxyPass /static/ ! Something like this. Upon searching the Django code, I found in csrf.py: REASON_BAD_REFERER = "Referer checking failed - %s does not match any trusted origins." It appears that adding the domain to CSRF_TRUSTED_ORIGINS should work. CSRF_TRUSTED_ORIGINS = [".example.com"] This should do the trick.

DjangoPython
2016-06-20 08:35 (9 years ago)

Python 3, Django 1.9

Django
2015-12-22 09:57 (10 years ago)

I want to redirect people who access /url-path-before/feature/hoge/ to /url-path-after/feature/hoge/.

Django
2015-11-27 00:40 (10 years ago)

```python

Django
2015-10-29 08:35 (10 years ago)

Django's built-in django.views.generic.TemplateView is a powerful tool.

Django
2015-10-15 10:10 (10 years ago)

class Content(models.Model): content_name = models.CharField(...) group_id = models.PositiveIntegerField(...) volume_number = models.PositiveIntegerField(...) ... Assuming we have a typical Django model class, we want to search for its instances using a complex SQL query in a single shot. The results should be displayed on a web page, but since many rows are expected, we want to display a paginator.

Django
2015-09-03 11:48 (10 years ago)

This is a method to create a full-text index in MySQL using the DB migration feature in Django 1.7 and above.

Django
2015-07-07 05:38 (10 years ago)

```html Here are two methods to output an HTML template as it is using Django's TemplateView class, but replacing strings in the output result at once.

Django
2015-05-29 11:31 (10 years ago)

url(r'^login/', 'django.contrib.auth.views.login', name='login', kwargs={'template_name': 'admin/login.html', 'extra_context': {'next': '/'}}), Write this link in the template as follows,

Django
2015-05-10 07:19 (10 years ago)

There is a system called Mezzanine for building a CMS on Python + Django. By default, blog entries are written using a WYSIWYG HTML editor, but I wanted to write them using reStructured Text (reST, rst), so I did some research.

Django
2013-09-21 04:04 (12 years ago)

1. Define change_form_template in the admin.py module Specify the location of the custom template

Django
2011-09-10 11:32 (14 years ago)

Rollback the migration, delete all migration scripts, and then redo the schema migrations.

Django
2011-09-10 11:20 (14 years ago)

```python

Django
2011-06-21 06:24 (14 years ago)

```html Using template tags like lorem, you can create dummy data for articles utilizing the django.contrib.webdesign.lorem_ipsum package.

Django
2011-06-20 17:14 (14 years ago)

When you pass a GET query like

Django
2011-06-17 07:09 (14 years ago)

```python

Django
2011-06-17 01:10 (14 years ago)

Disable Deletion from List Checkboxes Create a file like common/admins.py

Categories

Archive