diff --git a/litl/admin.py b/litl/admin.py new file mode 100644 index 0000000..d0b6dc3 --- /dev/null +++ b/litl/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Slug + +admin.site.register(Slug) diff --git a/litl/forms.py b/litl/forms.py new file mode 100644 index 0000000..0f3bad3 --- /dev/null +++ b/litl/forms.py @@ -0,0 +1,20 @@ +# coding: utf-8 +# Author: Grizzly +# +# Forms for litl. The main form is for creating the link. + +from django import forms +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Submit +from .models import Slug + +class SlugAddForm(forms.ModelForm): + class Meta: + model = Slug + fields = ('destination','slug') + + def __init__(self,*args,**kwargs): + super().__init__(*args,**kwargs) + self.helper = FormHelper() + self.helper.form_method = 'post' + self.helper.add_input(Submit('submit','Shorten')) diff --git a/litl/settings.py b/litl/settings.py index 9a47c86..b09c9c6 100644 --- a/litl/settings.py +++ b/litl/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', + 'crispy_forms', 'django.contrib.staticfiles', ] @@ -52,6 +53,7 @@ MIDDLEWARE = [ ] ROOT_URLCONF = 'litl.urls' +CRISPY_TEMPLATE_PACK = 'bootstrap4' TEMPLATES = [ { @@ -120,3 +122,5 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' +STATIC_ROOT = os.path.join(BASE_DIR, "static_files") +STATICFILES_DIRS = (os.path.join(BASE_DIR, "static/"),) diff --git a/litl/templates/add_slug.html b/litl/templates/add_slug.html new file mode 100644 index 0000000..830674b --- /dev/null +++ b/litl/templates/add_slug.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + {% crispy form %} +{% endblock %} diff --git a/litl/templates/base.html b/litl/templates/base.html index 77c459e..320d292 100644 --- a/litl/templates/base.html +++ b/litl/templates/base.html @@ -1,26 +1,34 @@ {% load bootstrap4 %} +{% load static %} {% bootstrap_css %} {% bootstrap_javascript jquery='full' %} -
Resize this responsive page to see the effect!
-Lorem ipsum dolor..
-Lorem ipsum dolor..
-Lorem ipsum dolor..
+ + +