diff --git a/game_collection/app.py b/game_collection/app.py index c2bbce6..e4565b1 100644 --- a/game_collection/app.py +++ b/game_collection/app.py @@ -3,6 +3,7 @@ from flask_sqlalchemy import SQLAlchemy from database import init_db from models import db, Game import os +from datetime import datetime app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(app.instance_path, 'games.db') @@ -21,7 +22,7 @@ def add_game(): new_game = Game( image=data['image'], title=data['title'], - date=data['date'], + date=datetime.now().strftime('%Y-%m-%d'), # Set current date buyer=data['buyer'], owned=data['owned'] ) diff --git a/game_collection/models.py b/game_collection/models.py index a693407..2c43a0b 100644 --- a/game_collection/models.py +++ b/game_collection/models.py @@ -7,6 +7,6 @@ class Game(db.Model): id = db.Column(db.Integer, primary_key=True) image = db.Column(db.String(255)) title = db.Column(db.String(100), nullable=False) - date = db.Column(db.String(10)) + date = db.Column(db.String(10), nullable=False) # Ensure date is not nullable buyer = db.Column(db.String(100)) owned = db.Column(db.Boolean, nullable=False)