Newbie question - data structure for game

30 views
Skip to first unread message

Ken Albright

unread,
Oct 28, 2016, 8:00:14 PM10/28/16
to Django users
I'm just learning Python and Django so please be gentle...

I've written a quote decryption game (like you see in the newspaper) in Python. I'd like to put it on a web page with Django. However, I'm not sure of the best way to structure the data. The original quote and the encrypted quote need to have a one-to-one relationship at the letter level. So it could be two strings on the same row (same id) or a set of tuples, a dictionary, or ???

How to set up the database and models.py?

Thanks

Bob Gailer

unread,
Oct 29, 2016, 2:21:31 PM10/29/16
to Django users

On Oct 28, 2016 7:59 PM, "Ken Albright" <cfk...@gmail.com> wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in Python. I'd like to put it on a web page with Django. However, I'm not sure of the best way to structure the data. The original quote and the encrypted quote need to have a one-to-one relationship at the letter level. So it could be two strings on the same row (same id)

That is the simplest, and I see no need for anything more complex.

or a set of tuples, a dictionary, or ???
>
> How to set up the database

What do you mean?

and models.py?

class Quote:
    plain= Models.CharField()
    crypt = Models.CharField()

> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b37833bf-e474-4b15-844d-4ef8d8e854b6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Yaşar Arabacı

unread,
Oct 29, 2016, 2:49:39 PM10/29/16
to Django users
I am also quite new to django, but I will go with something like this;

class Quote(models.Model):
    quote= models.CharField(max_length=100)

class EncryptedQuote(models.Model)
    quote = models.ForeignKey(Quote, on_delete=models.CASCADE)
    encrypted_quote = models.CharField(max_length=100)


So, you can have multiple encryptions of any quote.

Ken Albright

unread,
Oct 29, 2016, 7:27:59 PM10/29/16
to Django users
Sounds good. Thanks for the advice. Now if I could only figure out how to get forms to expand and contract to match the size of the quote...

Thanks.

Stephanie&stephan Statsmann

unread,
Oct 29, 2016, 8:31:05 PM10/29/16
to Django users
K

Derek

unread,
Oct 30, 2016, 12:21:39 PM10/30/16
to Django users
You'll probably need jQuery. Bear in mind "size" is not absolute as it will depend on font family and font height.
Reply all
Reply to author
Forward
0 new messages