-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Django Select 2 example for demo app
- Loading branch information
Showing
11 changed files
with
135 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.11 on 2017-02-11 19:56 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('demo', '0010_auto_20170211_2037'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='showcase', | ||
name='country', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='demo.Country'), | ||
), | ||
migrations.AddField( | ||
model_name='showcase', | ||
name='country2', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='showcase_country2_set', to='demo.Country', verbose_name=b'asd'), | ||
), | ||
migrations.AddField( | ||
model_name='showcase', | ||
name='raw_id_field', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='showcase_raw_set', to='demo.Country'), | ||
), | ||
] |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var django = django || {}; | ||
django.jQuery = jQuery.noConflict(true); | ||
|
||
// Override Django jquery.init.js | ||
// Make jQuery global - needed for Django-Select2 | ||
if (!window.jQuery) | ||
window.$ = window.jQuery = django.jQuery; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.django-select2 { | ||
min-width: 250px; | ||
} | ||
|
||
/* Improve Bootstrap4 to make it more matching */ | ||
#content .select2-container--bootstrap { | ||
display: inline-block; | ||
margin-right: 5px; | ||
border-radius: .25rem; | ||
} | ||
|
||
#content .select2-container--bootstrap .select2-selection { | ||
box-shadow: none; | ||
-webkit-box-shadow: none; | ||
} | ||
|
||
#content .select2-container--bootstrap:not(.select2-container--focus):not(.select2-container--open) .select2-selection { | ||
border-color: #d9d9d9; | ||
} | ||
|
||
#content .select2-container--bootstrap .select2-selection--single { | ||
padding-top: 5px; | ||
padding-bottom: 5px; | ||
height: 32px; | ||
} | ||
|
||
#content .select2-container--bootstrap .select2-selection__choice { | ||
background-color: #F1F1F1; | ||
border: 1px solid #ddd; | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.conf import settings | ||
from django.forms import forms | ||
from django.contrib.staticfiles.templatetags.staticfiles import static | ||
|
||
|
||
class Bootstrap4Select(object): | ||
def build_attrs(self, extra_attrs=None, **kwargs): | ||
attrs = super(Bootstrap4Select, self).build_attrs(extra_attrs, **kwargs) | ||
attrs.setdefault('data-theme', 'bootstrap') | ||
return attrs | ||
|
||
def _get_media(self): | ||
""" | ||
Construct Media as a dynamic property. | ||
.. Note:: For more information visit | ||
https://docs.djangoproject.com/en/1.8/topics/forms/media/#media-as-a-dynamic-property | ||
""" | ||
return forms.Media( | ||
js=( | ||
settings.SELECT2_JS, | ||
static('django_select2/django_select2.js'), | ||
), | ||
css={'screen': ( | ||
settings.SELECT2_CSS, | ||
# static('css/select2-bootstrap.css'), | ||
'//cdnjs.cloudflare.com/ajax/libs/select2-bootstrap-theme/0.1.0-beta.6/select2-bootstrap.min.css',)} | ||
) | ||
|
||
media = property(_get_media) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Django==1.10.5 | ||
Django-Select2==5.8.10 |