{% csrf_token %}
">
{% csrf_token %}
">
{% csrf_token %}
">
<form method="post" action="{% url 'my_view' %}">
{% csrf_token %}
<label for="id_user">ユーザー:</label>
<input type="text" id="id_user" name="user" required>
<br>
<label for="id_minute">分:</label>
<input type="number" id="id_minute" name="minute" required>
<br>
<button type="submit">送信</button>
</form>
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
# Register your models here.
class TimeRecord(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateField()
time = models.PositiveIntegerField(help_text="単位:分")
def __str__(self):
return str(self.time) # 時間を文字列として表示する例
class Schedule(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
daytime = models.DateTimeField()
category = models.TextField()
memo = models.TextField(a.py
from django.contrib import admin
from .models import TimeRecord, Schedule
@admin.register(TimeRecord)
class TimeRecordAdmin(admin.ModelAdmin):
list_display = ('user', 'date', 'time')
@admin.register(Schedule)
class ScheduleAdmin(admin.ModelAdmin):
list_display = ('user', 'daytime','category', 'memo')