Options.unique_together
Sets of field names that, taken together, must be unique:
unique_together = (("driver", "restaurant"),)
This is a tuple of tuples that must be unique when considered together. It’s used in the Django admin and is enforced at the database level (i.e., the appropriate UNIQUE statements are included in the CREATE TABLE statement).
For convenience, unique_together can be a single tuple when dealing with a single set of fields:
unique_together = ("driver", "restaurant")
class TTest(models.Model):
t1 = models.IntegerField()
t2 = models.IntegerField()
class Meta:
unique_together = ('t1', 't2')
$python manage.py sql ttest
BEGIN;
CREATE TABLE "ttest_ttest" (
"id" integer NOT NULL PRIMARY KEY,
"t1" integer NOT NULL,
"t2" integer NOT NULL,
UNIQUE ("t1", "t2")
)
;
COMMIT;
$('.responsive').slick({
dots: true,
infinite: false,
speed: 300,
slidesToShow: 4,
slidesToScroll: 4,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
watch: {
'$route'(){
this.startComponent()
}
}
google.maps.event.addListener(marker, 'mouseover', onMarkermouseover);
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=ваш апи">
</script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 9,
center: new google.maps.LatLng(44.958196, 34.109555),
scrollwheel: false,
styles: [{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#46bcec"},{"visibility":"on"}]}],
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infoWindow = new google.maps.InfoWindow;
var onMarkerClick = function() {
var marker = this;
var latLng = marker.getPosition();
infoWindow.setContent(marker.title);
infoWindow.open(map, marker);
};
google.maps.event.addListener(map, 'click', function() {
infoWindow.close();
});
var onMarkermouseover = function() {
var marker = this;
var latLng = marker.getPosition();
infoWindow.setContent(marker.title);
infoWindow.open(map, marker);
};
google.maps.event.addListener(map, 'mouseover', function() {
infoWindow.close();
});
var marker1 = new google.maps.Marker({
map: map,
title: 'sadasdad',
icon: 'icon.png',
position: new google.maps.LatLng(44.958196,34.109555)
});
var marker2 = new google.maps.Marker({
map: map,
title: 'dfd',
icon: 'icon.png',
position: new google.maps.LatLng(44.858196,34.109555)
});
var marker3 = new google.maps.Marker({
map: map,
title: 'ааа',
icon: 'icon.png',
position: new google.maps.LatLng(44.758196,34.109555)
});
// infoWindow.open(map, marker1);
google.maps.event.addListener(marker1, 'mouseover', onMarkermouseover);
google.maps.event.addListener(map, 'mouseover', onMarkermouseover);
google.maps.event.addListener(marker2, 'mouseover', onMarkermouseover);
google.maps.event.addListener(marker3, 'mouseover', onMarkermouseover);
google.maps.event.addListener(marker1, 'click', onMarkerClick);
google.maps.event.addListener(marker2, 'click', onMarkerClick);
google.maps.event.addListener(marker3, 'click', onMarkerClick);
});
</script>
window.player; window.onYouTubeIframeAPIReady = function() { player = new YT.Player('tubular-player', { width: options.width, height: Math.ceil(options.width / options.ratio), videoId: options.videoId, playerVars: { controls: 0, showinfo: 0, modestbranding: 1, wmode: 'transparent' }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); }
wmode: 'transparent'
заменяешь на это wmode: 'transparent',
rel: 0
<iframe width="560" height="315" src="https://www.youtube.com/embed/nMVJxTcU8Kg" frameborder="0" allowfullscreen></iframe>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/nMVJxTcU8Kg" frameborder="0" allowfullscreen></iframe>
</div>
def messages(request):
return {
'messages': get_messages(request),
'DEFAULT_MESSAGE_LEVELS': DEFAULT_LEVELS,
}
...
def get_messages(request):
if hasattr(request, '_messages'):
return request._messages
else:
return []
class MessageMiddleware(MiddlewareMixin):
def process_request(self, request):
request._messages = default_storage(request)
...
def default_storage(request):
return import_string(settings.MESSAGE_STORAGE)(request)
...
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
messages.error(request, 'Ваш диапазон дат занят для данного объекта.')
def error(request, message, extra_tags='', fail_silently=False):
add_message(request, constants.ERROR, message, extra_tags=extra_tags,
fail_silently=fail_silently)
...
def add_message(request, level, message, extra_tags='', fail_silently=False):
if not isinstance(request, HttpRequest):
raise TypeError("add_message() argument must be an HttpRequest object, "
"not '%s'." % request.__class__.__name__)
if hasattr(request, '_messages'):
return request._messages.add(level, message, extra_tags) # *** THIS ***
if not fail_silently:
raise MessageFailure('You cannot add messages without installing '
'django.contrib.messages.middleware.MessageMiddleware')
def add(self, level, message, extra_tags=''):
if not message:
return
level = int(level)
if level < self.level:
return
# Add the message.
self.added_new = True
message = Message(level, message, extra_tags=extra_tags)
self._queued_messages.append(message)
...
def _get_level(self):
if not hasattr(self, '_level'):
self._level = getattr(settings, 'MESSAGE_LEVEL', constants.INFO)
return self._level
# settings.py
...
MY_SUPER_ERROR = 80
MESSAGE_LEVEL = MY_SUPER_ERROR
...
if not available_cars:
carstoshow = None
messages.add_message(request, settings.MY_SUPER_ERROR, 'Ваш диапазон дат занят для данного объекта.')
return redirect('car_detail', pk=car_used_id)