For more info see: www.kidstrythisathome.com/2016/08/generic-model-autocomplete-with-dal3.html
This file contains 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
def view_historic_reversion(request, iid, vid): | |
item = get_object_or_404(MDR._concept, pk=iid).item | |
if not user_can_view(request.user, item): | |
if request.user.is_anonymous(): | |
return redirect(reverse('friendly_login') + '?next=%s' % request.path) | |
else: | |
raise PermissionDenied | |
old_item = default_revision_manager.get_for_object_reference( | |
item.__class__, |
This file contains 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 copy_reg | |
from django.db.models.fields import Field, _load_field, _empty | |
def _load_field_for_abstract(model, field_name): | |
return model._meta.get_field(field_name) | |
When spinning up a new service, Amazon Elastic LoadBalancer needs to check if the service is live and running.
This check is done from an IP (from any IP in a private IP range) to the service, this is done by the ELB just doing a simple GET
request to a specified path, with no host information - for example GET /heatbeat
.
If this instance is a Django service, regardless of the page accessed, this call will fail as in a properly setup Django it is very unlikely that the IP will be in Django's settings.ALLOWED_HOSTS
settings.
There are two ways around this, either:
a. Add every IP from every private IP range into your Django project's ALLOWED_HOSTS
settings
This file contains 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
# Lets run on the new infrastructure | |
sudo: false | |
language: python | |
python: | |
- "3.5" | |
install: | |
- pip install tox codecov coveralls |
This file contains 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 boto3 | |
import os | |
import requests | |
from botocore.auth import SigV4Auth | |
from requests_aws4auth import AWS4Auth | |
from elasticsearch import RequestsHttpConnection | |
class AWSRequestsHttpConnection(RequestsHttpConnection): |
OlderNewer