Skip to content
Snippets Groups Projects
Verified Commit 2f9e3c65 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add example applicaiton.

parent 55a28e00
No related branches found
No related tags found
No related merge requests found
from django import forms
from django_starfield import Stars
class RatingForm(forms.Form):
rating_1 = forms.IntegerField(label='Default rating', widget=Stars)
rating_2 = forms.IntegerField(label='Big rating', widget=Stars(stars=17))
rating_3 = forms.IntegerField(label='Pink rating', widget=Stars(colour='#ff1493'))
rating_4 = forms.IntegerField(label='Dolphin rating', widget=Stars(codepoint='1f42c'))
"""
Django settings for example project.
Generated by 'django-admin startproject' using Django 2.0.7.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'kn+=4+#i($pch$5tgq2-teo&w14zrwlgb0#t=kcb@w*v7^h0ll'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'django_starfield',
'example'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'example.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
],
},
},
]
WSGI_APPLICATION = 'example.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>django_starfield example</title>
</head>
<body>
<form method="post">
{% csrf_token %}
<table>
{{ rating_form.as_table }}
</table>
<input type="submit" value="Submit" />
</form>
</body>
</html>
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.form)
]
from django.shortcuts import render
from .forms import RatingForm
def form(request):
if request.method == 'POST':
rating_form = RatingForm(request.POST)
else:
rating_form = RatingForm()
return render(request, 'form.html', {'rating_form': rating_form})
"""
WSGI config for example project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
application = get_wsgi_application()
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment