fix function for date and import
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4m6s

This commit is contained in:
pierre geeraert
2026-06-21 22:21:55 +01:00
parent bb642c781a
commit 0216a9f1e1
2 changed files with 17 additions and 44 deletions
+12 -39
View File
@@ -14,50 +14,23 @@ python django_code/manage.py migrate --database=cloudmanager_db
python django_code/manage.py migrate --database=simpsons_db
python django_code/manage.py migrate --database=redirect_db
```
### Create virtual env
In the main directory, create a virtual env
### Database debug
```
python3 -m venv .env
create database django;
create database simpsons;
create database cloudmanager;
create database redirect;
drop database django;
drop database simpsons;
drop database cloudmanager;
drop database redirect;
```
to activate it :
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
```
source .env/bin/activate
```
### Env variables inside the .env file
Edit .env/bin/activate
In the deactivate () function, append at the end:
```
# unset required variables
unset DB_HOST
unset DB_PORT
unset DB_USERNAME
unset DB_PASSWORD
unset DB_DATABASE
unset ALLOWED_HOSTS
unset DEBUG
```
at the end of the file add the DB value for testing:
```
export DB_HOST=localhost
export DB_PORT=5432
export DB_USERNAME=postgres
export DB_PASSWORD=example
export DB_DATABASE=cloudmanager
export CUSTOM_DB_DATABASE=cloudmanager
export ALLOWED_HOSTS="0.0.0.0,localhost,127.0.0.1"
export DEBUG=true
```
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
@@ -1,11 +1,11 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.utils import timezone
from django.apps import AppConfig
from .models import redirectData
import redis
import datetime
def hello(request):
return HttpResponse('<h1>Hello Django!</h1>')
@@ -36,7 +36,7 @@ def redirect_process(request):
key = key.lower()
r.set(key, value)
redirectData.objects.create(url=key,addedDate=datetime.datetime.now(),seenDate="")
redirectData.objects.create(url=key,addedDate=timezone.now().date(),seenDate="")
text_generated = "successfully set "+value+" to "+key
return HttpResponse(text_generated, content_type="text/plain")