ytyng.com

Latest Articles

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

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

AWSMySQL
2017-01-03 12:34 (9 years ago)

Something is wrong with AWS RDS MySQL replication

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.

2016-09-14 09:50 (9 years ago)

If you are using Disqus for your blog's comment system

MySQL
2016-09-14 09:44 (9 years ago)

This isn't a completely quantitative discussion, but...

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

Python 3, Django 1.9

mac
2016-01-02 14:35 (10 years ago)

If you encounter the error "Cannot open application 'Steam.app'" when trying to launch the downloaded Steam on macOS 10.11 El Capitan, follow these steps. Note that the correctness of this method is not guaranteed...

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/.

iOS
2015-12-21 06:37 (10 years ago)

When encountering a large number of duplicate symbol _OBJC_CLASS_ errors during an iOS app build

HTML
2015-12-02 09:32 (10 years ago)

When using WebFont, you may encounter a phenomenon called FOUT (Flash of Unstyled Text) where text is not displayed if the font fails to load.

MySQL
2015-12-01 06:42 (10 years ago)

Background I'm creating a full-text index with bigrams in InnoDB on MySQL 5.6. However, when I tried to search for the term "TWIN,"

Python
2015-12-01 02:02 (10 years ago)

Get the SSL certificate expiration period using timedelta

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

```python

iOS
2015-11-05 11:27 (10 years ago)

The following article was helpful.

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

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

Bootstrap
2015-10-27 09:35 (10 years ago)

This method allows you to randomly change the initial position when displaying a large carousel in the hero area using Bootstrap.

Python
2015-10-19 07:34 (10 years ago)

Up until now, I had been writing custom thread pools using threading.Thread, but I thought there must be something provided by Python already. So, I did some searching and found that multiprosessing.pool.Pool was exactly what I was looking for. Creating a process pool is super easy with it. What was I doing all this time?

Python
2015-10-16 07:35 (10 years ago)

I should have used multiprocessing.pool.Pool orz

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.