Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Planteer/Planteer/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions Planteer/Planteer/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for Planteer project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Planteer.settings')

application = get_asgi_application()
127 changes: 127 additions & 0 deletions Planteer/Planteer/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"""
Django settings for Planteer project.

Generated by 'django-admin startproject' using Django 6.0.4.

For more information on this file, see
https://docs.djangoproject.com/en/6.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/6.0/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-8xc6_a1f_o+5kui$8s1v2$kx8c!#@ljv#i_*5dd&a@6_j#+ugs'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'plants',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'Planteer.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'Planteer.wsgi.application'


# Database
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/6.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/6.0/howto/static-files/

STATIC_URL = 'static/'

# Default primary key field type
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

# Media files — uploaded images (ImageField)
# NOTE: pip install Pillow is required for ImageField support
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
17 changes: 17 additions & 0 deletions Planteer/Planteer/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
URL configuration for Planteer project.
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('main.urls')),
path('plants/', include('plants.urls')),
]

# Serve media files during development only
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16 changes: 16 additions & 0 deletions Planteer/Planteer/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Planteer 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/6.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Planteer.settings')

application = get_wsgi_application()
Binary file added Planteer/db.sqlite3
Binary file not shown.
Empty file added Planteer/main/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions Planteer/main/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib import admin
from .models import Contact


@admin.register(Contact)
class ContactAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'email', 'created_at')
list_filter = ('created_at',)
search_fields = ('first_name', 'last_name', 'email', 'message')
5 changes: 5 additions & 0 deletions Planteer/main/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class MainConfig(AppConfig):
name = 'main'
36 changes: 36 additions & 0 deletions Planteer/main/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django import forms
from .models import Contact


class ContactForm(forms.ModelForm):
class Meta:
model = Contact
fields = ['first_name', 'last_name', 'email', 'message']
widgets = {
'first_name': forms.TextInput(attrs={
'placeholder': 'First name',
'required': True,
'minlength': '2',
}),
'last_name': forms.TextInput(attrs={
'placeholder': 'Last name',
'required': True,
'minlength': '2',
}),
'email': forms.EmailInput(attrs={
'placeholder': 'your@email.com',
'required': True,
}),
'message': forms.Textarea(attrs={
'placeholder': 'Your message...',
'required': True,
'rows': 5,
'minlength': '10',
}),
}

def clean_message(self):
message = self.cleaned_data.get('message', '').strip()
if len(message) < 10:
raise forms.ValidationError("Message must be at least 10 characters.")
return message
28 changes: 28 additions & 0 deletions Planteer/main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 6.0.4 on 2026-04-18 22:46

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Contact',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('email', models.EmailField(max_length=254)),
('message', models.TextField()),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'ordering': ['-created_at'],
},
),
]
Empty file.
15 changes: 15 additions & 0 deletions Planteer/main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.db import models


class Contact(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
email = models.EmailField()
message = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"{self.first_name} {self.last_name} — {self.email}"

class Meta:
ordering = ['-created_at']
Loading