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
INSTALLED_APPS = [ | |
... | |
'django.forms', # Required in the last section. | |
'django_filters', # Django-filter | |
'crispy_forms', | |
'myapp' | |
] |
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
from django.contrib import admin | |
from .models import People | |
class PeopleAdmin(admin.ModelAdmin): | |
pass | |
admin.site.register(People, PeopleAdmin) |
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
$ django-admin startproject myproject | |
$ mv myproject src |
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
$ python manage.py createsuperuser |
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
TEMPLATES = [ | |
{ | |
... | |
'DIRS': [BASE_DIR / 'templates'], | |
... | |
}, | |
] |
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
$ pip install Django | |
$ pip install django-crispy-forms | |
$ pip install django-filter |
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
from django.shortcuts import render | |
from .models import People | |
def index(request): | |
all_people = People.objects.all() | |
return render(request, 'index.html', {'all_people':all_people}) |
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
... | |
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting' | |
... |
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
<div id="my-numeric-slider" | |
class="form-group numeric-slider" | |
data-range_min="[Min. Possible Value]" | |
data-range_max="[Max. Possible Value]" | |
data-cur_min="[Current Min. Value]" | |
data-cur_max="[Current Max. Value]"> | |
<div class="numeric-slider-range ui-slider ui-slider-horizontal ui-slider-range"></div> | |
<span class="numeric-slider-range_text" id='my-numeric-slider_text'>[Lower Value] - [Upper Value]</span> | |
<input type='hidden' id='my-numeric-slider_min' name='slider-min'/> | |
<input type='hidden' id='my-numeric-slider_max' name='slider-max'/> |
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
{% load crispy_forms_field %} | |
<div class="form-group{% if 'form-horizontal' in form_class %} row{% endif %}"> | |
<label for="{{ field.id_for_label }}" class="{% if 'form-horizontal' in form_class %}col-form-label {% endif %}{{ label_class }}{% if field.field.required %} requiredField{% endif %}"> | |
{{ field.label|safe }} | |
{% if field.field.required %} | |
<span class="asteriskField">*</span> | |
{% endif %} | |
</label> | |
{% crispy_field field %} |
OlderNewer