Start adding code
This commit is contained in:
parent
7cbf9f9e3a
commit
93710fe834
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class MainConfig(AppConfig):
|
||||||
|
name = 'main'
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 3.1.1 on 2020-09-06 02:53
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Thought',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('text', models.CharField(max_length=140)),
|
||||||
|
('extended_text', models.TextField(blank=True)),
|
||||||
|
('posted', models.DateTimeField()),
|
||||||
|
('timezone_offset', models.IntegerField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,9 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Thought(models.Model):
|
||||||
|
text = models.CharField(max_length=140)
|
||||||
|
extended_text = models.TextField(blank=True)
|
||||||
|
posted = models.DateTimeField()
|
||||||
|
timezone_offset = models.IntegerField() # The number of minutes behind UTC we were when this was posted
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Hello, and welcome to the index.
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form action="{% url 'post'%}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<label>
|
||||||
|
<textarea></textarea>
|
||||||
|
</label>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,16 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from .models import Thought
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
return render(request, "whispermaphone/index.html", {})
|
||||||
|
|
||||||
|
|
||||||
|
def post(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
# offset = request["POST"].timezone_offset
|
||||||
|
|
||||||
|
# Thought(text=, extended_text=, posted=, timezone_offset=, )
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return render(request, "whispermaphone/post.html", {})
|
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'main',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -16,6 +16,9 @@ Including another URLconf
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
|
from main import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path("", views.index),
|
||||||
|
path("post", views.post),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue