Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5963055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:11:36+00:00 2026-05-22T19:11:36+00:00

I’ve set up several models, as you’ll see shortly in my code. These models

  • 0

I’ve set up several models, as you’ll see shortly in my code. These models are Era, Year, Month, Day, and Hour.

I’d like for, when I create an Era, it creates a set of Years, which in turn create Months, which in turn create Days, which create Hours. I’m sure I can figure out most of this if someone could just help me with the methodology with say the Era to Year step.

The goal is then to have the CurrentTime model able to step through all the other models (like a clock basically).

In case you’re wondering, I’m going to try and make a simple web based game off this, that’s why the values are a bit different from a regular calendar!

So here’s my models.py file:

from django.db import models

# Create your models here.
DAY_LENGTH = 24 #1 day is 24 hours
MONTH_LENGTH = 24 #1 month is 24 days
MONTH_CHOICES = (
        (1, 'January'),
        (2, 'Febuary'),
        (3, 'March'),
        (4, 'April'),
        (5, 'May'),
        (6, 'June'),
        (7, 'July'),
        (8, 'August'),
        (9, 'September'),
        (10, 'October'),
        (11, 'November'),
        (12, 'December'),
        (13, 'Extravember'),
        (14, 'Othertober'),
    )
DAY_CHOICES = (
        (1, 'Monday'),
        (2, 'Tuesday'),
        (3, 'Wednesday'),
        (4, 'Thursday'),
        (5, 'Friday'),
        (6, 'Saturday'),
    )
YEAR_LENGTH = MONTH_CHOICES.length     #1 year contains
ERA_LENGTH = 9999 #1 era is 9999 years     #one of every month

NUMBER_OF_BLOCKS = 6 #Number of discreet actions programmable for a day
BLOCK_LENGTH = DAY_LENGTH / NUMBER_OF_BLOCKS

class Era(models.Model):
    #Era number
    value = models.AutoField()
    #Name of the Era
    name = models.CharField(max_length=50)

    def __unicode__(self):
        return "Era of " + self.name

class Year(models.Model):
    #Year number
    value = models.PositiveSmallIntegerField(max_value=9999)
    #Era the year belongs to
    era = models.ForeignKey('Era')
    length = YEAR_LENGTH

    def __unicode__(self):
        return "Year " + self.value + self.era


class Month(models.Model):
    #Should return name of month
    value = models.PositiveSmallIntegerField(
        choices=MONTH_CHOICES)
    #Year that the month fits into
    year = models.ForeignKey(Year)

    def __unicode__(self):
        return self.value " of " + self.year

class Day(models.Model):
    #Should give the name of the day
    name = models.PositiveSmallIntegerField(
        choices = DAY_CHOICES)
    #Month that the day belongs to
    month = models.ForeignKey('Month')
    #Day number, dependant on month length
    value = models.PositiveSmallIntegerField(
        max_value = month.length)

    def __unicode__(self):
        return self.name + ", day " + self.value + " of " + self.month

class Hour(models.Model):
    value = models.PositiveSmallIntegerField(
        max_value = DAY_LENGTH)
    day = models.ForeignKey('Day')

    def __unicode__(self):
        return self.value + ":00, " + self.day

class CurrentTime(models.Model):
    hour = ForeignKey('Hour')
    day = ForeignKey('Day')
    month = ForeignKey('Month')
    year = ForeignKey('Year')
    era = ForeignKey('Era')

    def __unicode__(self): #!!will only work for current config!
        return self.hour

I’m sure it’s pretty messy… But in any case, please help me figure out my code! And any other help you’d like to give me, I appreciate too!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:11:37+00:00Added an answer on May 22, 2026 at 7:11 pm

    Storing a datastructure in 6 tables is overkill. You would not store a string “abc” in three different tables. So something in your design is, in my opinion, wrong.

    Try instead to write your problem as simple as possible and post it to along with your solution to it here at SO.

    There are sure alternatives to your implementation and import this

    >>> import this
    ...
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    ...
    

    If you want to – against any advice 😉 – use your above stated Models, override the save method of your models.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
In order to apply a triggered animation to all ToolTip s in my app,
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.