feat: set current date automatically when adding a new game to the database

This commit is contained in:
2024-09-02 09:49:10 +02:00
parent 8345ac4e64
commit 58254c4973
2 changed files with 3 additions and 2 deletions

View File

@ -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']
)