This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# | |
# Find a mistake: | |
################# | |
from django.core.cache import cache | |
from celery import shared_task | |
@shared_task() | |
def clear_blog_item_cache(article): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .. import section .. | |
class Post(models.Model): | |
author = models.ForeignKey(CustomUserModel) | |
title = models.CharField(max_length=200) | |
text = models.CharField(max_length=15000) | |
is_published = models.BooleanField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################### | |
# To Do: How can we refactor code to make that faster? | |
###################################################### | |
def func(user, moderator_ids): | |
for post in Post.objects.all().order('?'): | |
if user.pk in moderator_ids: | |
post.updated_at = timezone.now() | |
post.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
from decimal import Decimal | |
from django.db import transaction | |
# send a request to PayPal.com to transfer money | |
from .services import transfer_money_via_paypal | |
class BillingAccount(models.Model): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pytest | |
try: | |
from.temp_env_var import TEMP_ENV_VARS, ENV_VARS_TO_SUSPEND | |
except ImportError: | |
TEMP_ENV_VARS = {} | |
ENV_VARS_TO_SUSPEND = [] | |
OlderNewer