model
This commit is contained in:
parent
d9407e221b
commit
ddcb33e20d
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,3 +4,7 @@
|
||||
/resources/_gen
|
||||
/public
|
||||
/result
|
||||
|
||||
__pycache__
|
||||
|
||||
db.sqlite3
|
||||
|
@ -1,21 +1,8 @@
|
||||
"""
|
||||
Django settings for e11mail project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.0.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.0/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/5.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/5.0/howto/deployment/checklist/
|
||||
|
||||
@ -25,12 +12,13 @@ SECRET_KEY = 'django-insecure-$e2!=equ(efm0e%f9&t+xjtz0)$*$@pw%rnjdqcl8f@5o5hw!l
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
#ALLOWED_HOSTS = ["100.89.176.6"]
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'signup.apps.SignupConfig',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@ -69,10 +57,6 @@ TEMPLATES = [
|
||||
|
||||
WSGI_APPLICATION = 'e11mail.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
@ -80,10 +64,6 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
@ -100,9 +80,6 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
@ -111,13 +88,6 @@ USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
@ -14,9 +14,11 @@ Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import include, path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('signup.urls')),
|
||||
]
|
@ -1,4 +1,4 @@
|
||||
#!/nix/store/5k91mg4qjylxbfvrv748smfh51ppjq0g-python3-3.11.6/bin/python
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
0
app/signup/__init__.py
Normal file
0
app/signup/__init__.py
Normal file
5
app/signup/admin.py
Normal file
5
app/signup/admin.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Signup
|
||||
|
||||
admin.site.register(Signup)
|
6
app/signup/apps.py
Normal file
6
app/signup/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SignupConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'signup'
|
28
app/signup/migrations/0001_initial.py
Normal file
28
app/signup/migrations/0001_initial.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Generated by Django 5.0 on 2023-12-14 20:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Signup',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('email', models.EmailField(max_length=254)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('anonymized_ip', models.GenericIPAddressField()),
|
||||
('user_agent', models.CharField(max_length=255)),
|
||||
],
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='signup',
|
||||
constraint=models.UniqueConstraint(fields=('email',), name='unique_email'),
|
||||
),
|
||||
]
|
0
app/signup/migrations/__init__.py
Normal file
0
app/signup/migrations/__init__.py
Normal file
15
app/signup/models.py
Normal file
15
app/signup/models.py
Normal file
@ -0,0 +1,15 @@
|
||||
from django.db import models
|
||||
|
||||
class Signup(models.Model):
|
||||
email = models.EmailField()
|
||||
created_at = models.DateTimeField(auto_now_add = True)
|
||||
anonymized_ip = models.GenericIPAddressField()
|
||||
user_agent = models.CharField(max_length = 255)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(name = "unique_email", fields = ["email"]),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.email
|
3
app/signup/tests.py
Normal file
3
app/signup/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
app/signup/urls.py
Normal file
7
app/signup/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.index, name="index"),
|
||||
]
|
4
app/signup/views.py
Normal file
4
app/signup/views.py
Normal file
@ -0,0 +1,4 @@
|
||||
from django.http import HttpResponse
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Hello. You're at the signup index.")
|
Loading…
Reference in New Issue
Block a user