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
| from collections import defaultdict | |
| from django.db.models.signals import * | |
| class DisableSignals(object): | |
| def __init__(self, disabled_signals=None): | |
| self.stashed_signals = defaultdict(list) | |
| self.disabled_signals = disabled_signals or [ | |
| pre_init, post_init, | |
| pre_save, 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
| server { | |
| listen *:80; | |
| server_name www.icinga2.com; | |
| root /usr/share/icingaweb2/public; #Path of icinga2 web directory | |
| index index.php; | |
| access_log /var/log/nginx/access.log; | |
| error_log /var/log/nginx/error.log; | |
| location = /favicon.ico { |
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
| from django.db.models import Count, Max | |
| unique_fields = ['field_1', 'field_2'] | |
| duplicates = ( | |
| MyModel.objects.values(*unique_fields) | |
| .order_by() | |
| .annotate(max_id=Max('id'), count_id=Count('id')) | |
| .filter(count_id__gt=1) | |
| ) |
OlderNewer