Created
September 3, 2024 17:14
-
-
Save mistressAlisi/645b966cbf738fdbddf220f5ea97ca40 to your computer and use it in GitHub Desktop.
Get the Daily Ledger page for a given date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from ledger.models import DailyLedger | |
def get_daily_ledger(date=datetime.datetime.now()): | |
year = date.year | |
day = date.strftime("%j") | |
try: | |
dObj = DailyLedger.objects.get(year=year, day=day) | |
except DailyLedger.DoesNotExist: | |
dObj = DailyLedger(year=year, day=day) | |
dObj.save() | |
return dObj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment