├── .gitignore
├── Final Code
├── core
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── 0002_todo.py
│ │ └── __init__.py
│ ├── models.py
│ ├── templates
│ │ ├── base.html
│ │ └── index.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── htmx_daisyui
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
├── Start Code
├── core
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── 0002_todo.py
│ │ └── __init__.py
│ ├── models.py
│ ├── templates
│ │ ├── base.html
│ │ └── index.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── htmx_daisyui
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
└── requirements.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | __pycache__
3 | db.sqlite3
4 | notes*.txt
--------------------------------------------------------------------------------
/Final Code/core/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bugbytes-io/htmx-django-daisyui/7492f2b2213dff340fb6202ef28a10f53f940b6d/Final Code/core/__init__.py
--------------------------------------------------------------------------------
/Final Code/core/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from core.models import Todo
3 |
4 | class TodoAdmin(admin.ModelAdmin):
5 | list_display = ['description', 'is_completed', 'user']
6 | admin.site.register(Todo, TodoAdmin)
--------------------------------------------------------------------------------
/Final Code/core/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class CoreConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'core'
7 |
--------------------------------------------------------------------------------
/Final Code/core/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 | from core.models import Todo
3 |
4 |
5 | class TodoForm(forms.ModelForm):
6 | class Meta:
7 | model = Todo
8 | fields = ('description', 'is_completed')
--------------------------------------------------------------------------------
/Final Code/core/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 4.2.4 on 2023-11-09 09:08
2 |
3 | import django.contrib.auth.models
4 | import django.contrib.auth.validators
5 | from django.db import migrations, models
6 | import django.utils.timezone
7 |
8 |
9 | class Migration(migrations.Migration):
10 | initial = True
11 |
12 | dependencies = [
13 | ("auth", "0012_alter_user_first_name_max_length"),
14 | ]
15 |
16 | operations = [
17 | migrations.CreateModel(
18 | name="User",
19 | fields=[
20 | (
21 | "id",
22 | models.BigAutoField(
23 | auto_created=True,
24 | primary_key=True,
25 | serialize=False,
26 | verbose_name="ID",
27 | ),
28 | ),
29 | ("password", models.CharField(max_length=128, verbose_name="password")),
30 | (
31 | "last_login",
32 | models.DateTimeField(
33 | blank=True, null=True, verbose_name="last login"
34 | ),
35 | ),
36 | (
37 | "is_superuser",
38 | models.BooleanField(
39 | default=False,
40 | help_text="Designates that this user has all permissions without explicitly assigning them.",
41 | verbose_name="superuser status",
42 | ),
43 | ),
44 | (
45 | "username",
46 | models.CharField(
47 | error_messages={
48 | "unique": "A user with that username already exists."
49 | },
50 | help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
51 | max_length=150,
52 | unique=True,
53 | validators=[
54 | django.contrib.auth.validators.UnicodeUsernameValidator()
55 | ],
56 | verbose_name="username",
57 | ),
58 | ),
59 | (
60 | "first_name",
61 | models.CharField(
62 | blank=True, max_length=150, verbose_name="first name"
63 | ),
64 | ),
65 | (
66 | "last_name",
67 | models.CharField(
68 | blank=True, max_length=150, verbose_name="last name"
69 | ),
70 | ),
71 | (
72 | "email",
73 | models.EmailField(
74 | blank=True, max_length=254, verbose_name="email address"
75 | ),
76 | ),
77 | (
78 | "is_staff",
79 | models.BooleanField(
80 | default=False,
81 | help_text="Designates whether the user can log into this admin site.",
82 | verbose_name="staff status",
83 | ),
84 | ),
85 | (
86 | "is_active",
87 | models.BooleanField(
88 | default=True,
89 | help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
90 | verbose_name="active",
91 | ),
92 | ),
93 | (
94 | "date_joined",
95 | models.DateTimeField(
96 | default=django.utils.timezone.now, verbose_name="date joined"
97 | ),
98 | ),
99 | (
100 | "groups",
101 | models.ManyToManyField(
102 | blank=True,
103 | help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
104 | related_name="user_set",
105 | related_query_name="user",
106 | to="auth.group",
107 | verbose_name="groups",
108 | ),
109 | ),
110 | (
111 | "user_permissions",
112 | models.ManyToManyField(
113 | blank=True,
114 | help_text="Specific permissions for this user.",
115 | related_name="user_set",
116 | related_query_name="user",
117 | to="auth.permission",
118 | verbose_name="user permissions",
119 | ),
120 | ),
121 | ],
122 | options={
123 | "verbose_name": "user",
124 | "verbose_name_plural": "users",
125 | "abstract": False,
126 | },
127 | managers=[
128 | ("objects", django.contrib.auth.models.UserManager()),
129 | ],
130 | ),
131 | ]
132 |
--------------------------------------------------------------------------------
/Final Code/core/migrations/0002_todo.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 4.2.4 on 2023-11-16 14:45
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('core', '0001_initial'),
12 | ]
13 |
14 | operations = [
15 | migrations.CreateModel(
16 | name='Todo',
17 | fields=[
18 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 | ('description', models.CharField(max_length=200)),
20 | ('is_completed', models.BooleanField(default=False)),
21 | ('created_at', models.DateTimeField(auto_now_add=True)),
22 | ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
23 | ],
24 | ),
25 | ]
26 |
--------------------------------------------------------------------------------
/Final Code/core/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bugbytes-io/htmx-django-daisyui/7492f2b2213dff340fb6202ef28a10f53f940b6d/Final Code/core/migrations/__init__.py
--------------------------------------------------------------------------------
/Final Code/core/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import AbstractUser
3 |
4 |
5 | # Create your models here.
6 | class User(AbstractUser):
7 | pass
8 |
9 |
10 | class Todo(models.Model):
11 | description = models.CharField(max_length=200)
12 | is_completed = models.BooleanField(default=False)
13 | user = models.ForeignKey(User, on_delete=models.CASCADE)
14 | created_at = models.DateTimeField(auto_now_add=True)
15 |
16 | def __str__(self):
17 | return self.description
--------------------------------------------------------------------------------
/Final Code/core/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | To-Do List
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | {% block content %}
18 | {% endblock %}
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Final Code/core/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% load widget_tweaks %}
3 | {% load partials %}
4 |
5 | {% block content %}
6 |
7 |
8 |
{{ user.username }}'s To-Do list
9 |
10 |
28 |
29 |
30 |
31 |
32 |
33 | Description |
34 | Created |
35 | Completed |
36 | Actions |
37 |
38 |
39 |
40 | {% for todo in todos %}
41 | {% partialdef todoitem-partial inline=True %}
42 |
43 | {{ todo.description }} |
44 | {{ todo.created_at }} |
45 | {{ todo.is_completed }} |
46 |
47 | {% if not todo.is_completed %}
48 |
52 | {% endif %}
53 |
54 |
57 | |
58 |
59 | {% endpartialdef %}
60 | {% endfor %}
61 |
62 |
63 |
64 |
65 |
66 | {% endblock %}
--------------------------------------------------------------------------------
/Final Code/core/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/Final Code/core/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from . import views
3 |
4 | urlpatterns = [
5 | path('', views.index, name='index'),
6 | path('submit-todo', views.submit_todo, name='submit-todo'),
7 | path('complete-todo//', views.complete_todo, name='complete-todo'),
8 | path('delete-todo//', views.delete_todo, name='delete-todo'),
9 | ]
10 |
--------------------------------------------------------------------------------
/Final Code/core/views.py:
--------------------------------------------------------------------------------
1 | from django.http import HttpResponse
2 | from django.shortcuts import render, get_object_or_404
3 | from django.contrib.auth.decorators import login_required
4 | from django.views.decorators.http import require_POST, require_http_methods
5 | from core.models import Todo
6 | from core.forms import TodoForm
7 |
8 |
9 | @login_required
10 | def index(request):
11 | context = {
12 | 'todos': Todo.objects.filter(user=request.user),
13 | 'form': TodoForm()
14 | }
15 | return render(request, 'index.html', context)
16 |
17 |
18 | @login_required
19 | @require_POST
20 | def submit_todo(request):
21 | form = TodoForm(request.POST)
22 | if form.is_valid():
23 | todo = form.save(commit=False)
24 | todo.user = request.user
25 | todo.save()
26 |
27 | # return an HTML partial
28 | context = {'todo': todo}
29 | return render(request, 'index.html#todoitem-partial', context)
30 |
31 | @login_required
32 | @require_POST
33 | def complete_todo(request, pk):
34 | todo = get_object_or_404(Todo, pk=pk, user=request.user)
35 | todo.is_completed = True
36 | todo.save()
37 | context = {'todo': todo}
38 | return render(request, 'index.html#todoitem-partial', context)
39 |
40 | @login_required
41 | @require_http_methods(['DELETE'])
42 | def delete_todo(request, pk):
43 | todo = get_object_or_404(Todo, pk=pk, user=request.user)
44 | todo.delete()
45 | response = HttpResponse(status=204)
46 | response['HX-Trigger'] = 'delete-todo'
47 | return response
--------------------------------------------------------------------------------
/Final Code/htmx_daisyui/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bugbytes-io/htmx-django-daisyui/7492f2b2213dff340fb6202ef28a10f53f940b6d/Final Code/htmx_daisyui/__init__.py
--------------------------------------------------------------------------------
/Final Code/htmx_daisyui/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for htmx_daisyui project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'htmx_daisyui.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/Final Code/htmx_daisyui/settings.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
4 | BASE_DIR = Path(__file__).resolve().parent.parent
5 |
6 |
7 | # Quick-start development settings - unsuitable for production
8 | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
9 |
10 | # SECURITY WARNING: keep the secret key used in production secret!
11 | SECRET_KEY = 'django-insecure-%hjisw!0c0)bs&s9m#0e(#(=g54-#f+q2-d3+p%puk)0=5qrp#'
12 |
13 | # SECURITY WARNING: don't run with debug turned on in production!
14 | DEBUG = True
15 |
16 | ALLOWED_HOSTS = []
17 |
18 |
19 | # Application definition
20 |
21 | INSTALLED_APPS = [
22 | 'django.contrib.admin',
23 | 'django.contrib.auth',
24 | 'django.contrib.contenttypes',
25 | 'django.contrib.sessions',
26 | 'django.contrib.messages',
27 | 'django.contrib.staticfiles',
28 | 'django_extensions',
29 | 'allauth',
30 | 'allauth.account',
31 | 'allauth.socialaccount',
32 | 'core',
33 | 'widget_tweaks',
34 | 'template_partials'
35 | ]
36 |
37 | MIDDLEWARE = [
38 | 'django.middleware.security.SecurityMiddleware',
39 | 'django.contrib.sessions.middleware.SessionMiddleware',
40 | 'django.middleware.common.CommonMiddleware',
41 | 'django.middleware.csrf.CsrfViewMiddleware',
42 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
43 | 'django.contrib.messages.middleware.MessageMiddleware',
44 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
45 | ]
46 |
47 | ROOT_URLCONF = 'htmx_daisyui.urls'
48 |
49 | TEMPLATES = [
50 | {
51 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
52 | 'DIRS': [],
53 | 'APP_DIRS': True,
54 | 'OPTIONS': {
55 | 'context_processors': [
56 | 'django.template.context_processors.debug',
57 | 'django.template.context_processors.request',
58 | 'django.contrib.auth.context_processors.auth',
59 | 'django.contrib.messages.context_processors.messages',
60 | ],
61 | },
62 | },
63 | ]
64 |
65 | WSGI_APPLICATION = 'htmx_daisyui.wsgi.application'
66 |
67 |
68 | # Database
69 | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
70 |
71 | DATABASES = {
72 | 'default': {
73 | 'ENGINE': 'django.db.backends.sqlite3',
74 | 'NAME': BASE_DIR / 'db.sqlite3',
75 | }
76 | }
77 |
78 |
79 | # Password validation
80 | # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
81 |
82 | AUTH_PASSWORD_VALIDATORS = [
83 | {
84 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
85 | },
86 | {
87 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
88 | },
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
94 | },
95 | ]
96 |
97 |
98 | # Internationalization
99 | # https://docs.djangoproject.com/en/4.0/topics/i18n/
100 |
101 | LANGUAGE_CODE = 'en-us'
102 |
103 | TIME_ZONE = 'UTC'
104 |
105 | USE_I18N = True
106 |
107 | USE_TZ = True
108 |
109 |
110 | # Static files (CSS, JavaScript, Images)
111 | # https://docs.djangoproject.com/en/4.0/howto/static-files/
112 |
113 | STATIC_URL = 'static/'
114 |
115 | # Default primary key field type
116 | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
117 |
118 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
119 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
120 | AUTH_USER_MODEL = 'core.User'
121 | LOGIN_REDIRECT_URL = '/'
--------------------------------------------------------------------------------
/Final Code/htmx_daisyui/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import include, path
3 |
4 | urlpatterns = [
5 | path('admin/', admin.site.urls),
6 | path('accounts/', include('allauth.urls')),
7 | path('', include('core.urls')),
8 | ]
9 |
--------------------------------------------------------------------------------
/Final Code/htmx_daisyui/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for htmx_daisyui project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'htmx_daisyui.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/Final Code/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'htmx_daisyui.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/Start Code/core/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bugbytes-io/htmx-django-daisyui/7492f2b2213dff340fb6202ef28a10f53f940b6d/Start Code/core/__init__.py
--------------------------------------------------------------------------------
/Start Code/core/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/Start Code/core/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class CoreConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'core'
7 |
--------------------------------------------------------------------------------
/Start Code/core/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 |
--------------------------------------------------------------------------------
/Start Code/core/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 4.2.4 on 2023-11-09 09:08
2 |
3 | import django.contrib.auth.models
4 | import django.contrib.auth.validators
5 | from django.db import migrations, models
6 | import django.utils.timezone
7 |
8 |
9 | class Migration(migrations.Migration):
10 | initial = True
11 |
12 | dependencies = [
13 | ("auth", "0012_alter_user_first_name_max_length"),
14 | ]
15 |
16 | operations = [
17 | migrations.CreateModel(
18 | name="User",
19 | fields=[
20 | (
21 | "id",
22 | models.BigAutoField(
23 | auto_created=True,
24 | primary_key=True,
25 | serialize=False,
26 | verbose_name="ID",
27 | ),
28 | ),
29 | ("password", models.CharField(max_length=128, verbose_name="password")),
30 | (
31 | "last_login",
32 | models.DateTimeField(
33 | blank=True, null=True, verbose_name="last login"
34 | ),
35 | ),
36 | (
37 | "is_superuser",
38 | models.BooleanField(
39 | default=False,
40 | help_text="Designates that this user has all permissions without explicitly assigning them.",
41 | verbose_name="superuser status",
42 | ),
43 | ),
44 | (
45 | "username",
46 | models.CharField(
47 | error_messages={
48 | "unique": "A user with that username already exists."
49 | },
50 | help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
51 | max_length=150,
52 | unique=True,
53 | validators=[
54 | django.contrib.auth.validators.UnicodeUsernameValidator()
55 | ],
56 | verbose_name="username",
57 | ),
58 | ),
59 | (
60 | "first_name",
61 | models.CharField(
62 | blank=True, max_length=150, verbose_name="first name"
63 | ),
64 | ),
65 | (
66 | "last_name",
67 | models.CharField(
68 | blank=True, max_length=150, verbose_name="last name"
69 | ),
70 | ),
71 | (
72 | "email",
73 | models.EmailField(
74 | blank=True, max_length=254, verbose_name="email address"
75 | ),
76 | ),
77 | (
78 | "is_staff",
79 | models.BooleanField(
80 | default=False,
81 | help_text="Designates whether the user can log into this admin site.",
82 | verbose_name="staff status",
83 | ),
84 | ),
85 | (
86 | "is_active",
87 | models.BooleanField(
88 | default=True,
89 | help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
90 | verbose_name="active",
91 | ),
92 | ),
93 | (
94 | "date_joined",
95 | models.DateTimeField(
96 | default=django.utils.timezone.now, verbose_name="date joined"
97 | ),
98 | ),
99 | (
100 | "groups",
101 | models.ManyToManyField(
102 | blank=True,
103 | help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
104 | related_name="user_set",
105 | related_query_name="user",
106 | to="auth.group",
107 | verbose_name="groups",
108 | ),
109 | ),
110 | (
111 | "user_permissions",
112 | models.ManyToManyField(
113 | blank=True,
114 | help_text="Specific permissions for this user.",
115 | related_name="user_set",
116 | related_query_name="user",
117 | to="auth.permission",
118 | verbose_name="user permissions",
119 | ),
120 | ),
121 | ],
122 | options={
123 | "verbose_name": "user",
124 | "verbose_name_plural": "users",
125 | "abstract": False,
126 | },
127 | managers=[
128 | ("objects", django.contrib.auth.models.UserManager()),
129 | ],
130 | ),
131 | ]
132 |
--------------------------------------------------------------------------------
/Start Code/core/migrations/0002_todo.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 4.2.4 on 2023-11-16 14:45
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('core', '0001_initial'),
12 | ]
13 |
14 | operations = [
15 | migrations.CreateModel(
16 | name='Todo',
17 | fields=[
18 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 | ('description', models.CharField(max_length=200)),
20 | ('is_completed', models.BooleanField(default=False)),
21 | ('created_at', models.DateTimeField(auto_now_add=True)),
22 | ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
23 | ],
24 | ),
25 | ]
26 |
--------------------------------------------------------------------------------
/Start Code/core/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bugbytes-io/htmx-django-daisyui/7492f2b2213dff340fb6202ef28a10f53f940b6d/Start Code/core/migrations/__init__.py
--------------------------------------------------------------------------------
/Start Code/core/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import AbstractUser
3 |
4 |
5 | # Create your models here.
6 | class User(AbstractUser):
7 | pass
--------------------------------------------------------------------------------
/Start Code/core/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | To-Do List
8 |
9 |
10 |
11 |
12 |
13 | {% block content %}
14 | {% endblock %}
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Start Code/core/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block content %}
4 |
5 | {{ user.username }}'s To-Do list
6 |
7 | {% endblock %}
--------------------------------------------------------------------------------
/Start Code/core/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/Start Code/core/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from . import views
3 |
4 | urlpatterns = [
5 | path('', views.index, name='index'),
6 | ]
7 |
--------------------------------------------------------------------------------
/Start Code/core/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 | from django.contrib.auth.decorators import login_required
3 |
4 |
5 | @login_required
6 | def index(request):
7 | context = {}
8 | return render(request, 'index.html', context)
--------------------------------------------------------------------------------
/Start Code/htmx_daisyui/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bugbytes-io/htmx-django-daisyui/7492f2b2213dff340fb6202ef28a10f53f940b6d/Start Code/htmx_daisyui/__init__.py
--------------------------------------------------------------------------------
/Start Code/htmx_daisyui/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for htmx_daisyui project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'htmx_daisyui.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/Start Code/htmx_daisyui/settings.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
4 | BASE_DIR = Path(__file__).resolve().parent.parent
5 |
6 |
7 | # Quick-start development settings - unsuitable for production
8 | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
9 |
10 | # SECURITY WARNING: keep the secret key used in production secret!
11 | SECRET_KEY = 'django-insecure-%hjisw!0c0)bs&s9m#0e(#(=g54-#f+q2-d3+p%puk)0=5qrp#'
12 |
13 | # SECURITY WARNING: don't run with debug turned on in production!
14 | DEBUG = True
15 |
16 | ALLOWED_HOSTS = []
17 |
18 |
19 | # Application definition
20 |
21 | INSTALLED_APPS = [
22 | 'django.contrib.admin',
23 | 'django.contrib.auth',
24 | 'django.contrib.contenttypes',
25 | 'django.contrib.sessions',
26 | 'django.contrib.messages',
27 | 'django.contrib.staticfiles',
28 | 'django_extensions',
29 | 'allauth',
30 | 'allauth.account',
31 | 'allauth.socialaccount',
32 | 'core'
33 | ]
34 |
35 | MIDDLEWARE = [
36 | 'django.middleware.security.SecurityMiddleware',
37 | 'django.contrib.sessions.middleware.SessionMiddleware',
38 | 'django.middleware.common.CommonMiddleware',
39 | 'django.middleware.csrf.CsrfViewMiddleware',
40 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
41 | 'django.contrib.messages.middleware.MessageMiddleware',
42 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
43 | ]
44 |
45 | ROOT_URLCONF = 'htmx_daisyui.urls'
46 |
47 | TEMPLATES = [
48 | {
49 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
50 | 'DIRS': [],
51 | 'APP_DIRS': True,
52 | 'OPTIONS': {
53 | 'context_processors': [
54 | 'django.template.context_processors.debug',
55 | 'django.template.context_processors.request',
56 | 'django.contrib.auth.context_processors.auth',
57 | 'django.contrib.messages.context_processors.messages',
58 | ],
59 | },
60 | },
61 | ]
62 |
63 | WSGI_APPLICATION = 'htmx_daisyui.wsgi.application'
64 |
65 |
66 | # Database
67 | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
68 |
69 | DATABASES = {
70 | 'default': {
71 | 'ENGINE': 'django.db.backends.sqlite3',
72 | 'NAME': BASE_DIR / 'db.sqlite3',
73 | }
74 | }
75 |
76 |
77 | # Password validation
78 | # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
79 |
80 | AUTH_PASSWORD_VALIDATORS = [
81 | {
82 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
83 | },
84 | {
85 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
86 | },
87 | {
88 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
89 | },
90 | {
91 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
92 | },
93 | ]
94 |
95 |
96 | # Internationalization
97 | # https://docs.djangoproject.com/en/4.0/topics/i18n/
98 |
99 | LANGUAGE_CODE = 'en-us'
100 |
101 | TIME_ZONE = 'UTC'
102 |
103 | USE_I18N = True
104 |
105 | USE_TZ = True
106 |
107 |
108 | # Static files (CSS, JavaScript, Images)
109 | # https://docs.djangoproject.com/en/4.0/howto/static-files/
110 |
111 | STATIC_URL = 'static/'
112 |
113 | # Default primary key field type
114 | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
115 |
116 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
117 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
118 | AUTH_USER_MODEL = 'core.User'
119 | LOGIN_REDIRECT_URL = '/'
--------------------------------------------------------------------------------
/Start Code/htmx_daisyui/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import include, path
3 |
4 | urlpatterns = [
5 | path('admin/', admin.site.urls),
6 | path('accounts/', include('allauth.urls')),
7 | path('', include('core.urls')),
8 | ]
9 |
--------------------------------------------------------------------------------
/Start Code/htmx_daisyui/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for htmx_daisyui project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'htmx_daisyui.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/Start Code/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'htmx_daisyui.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Django==4.2.4
2 | django-allauth==0.54.0
3 | django-extensions==3.2.3
4 | django-widget-tweaks==1.5.0
--------------------------------------------------------------------------------