model
This commit is contained in:
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.")
|
||||
Reference in New Issue
Block a user