I am trying to make a set of forms with the following models (boost is the main one):
class boost (models.Model):
creator = models.ForeignKey (userInfo)
game = models.ForeignKey (gameInfo)
name = models.CharField (max_length = 200)
desc = models.CharField (max_length = 500)
rules = models.CharField (max_length = 500)
subscribe = models.IntegerField (default = 0)
class userInfo (models.Model):
pic_url = models.URLField (default = 0, blank = True)
auth = models.ForeignKey (User, unique = True)
birth = models.DateTimeField (default = 0, blank = True)
country = models.IntegerField (default = 0, blank = True)
class gameInfo (models.Model):
psn_id = models.CharField (max_length = 100)
name = models.CharField (max_length = 200)
publisher = models.CharField (max_length = 200, default = 0)
developer = models.CharField (max_length = 200, default = 0)
release_date = models.DateTimeField (blank = True, null = True)
I want to display the form for adding a Boost element, trying to do it like this:
TrophyFormSet = inlineformset_factory (db.gameInfo, db.boost, extra = 1)
formset = TrophyFormSet ()
Here are my questions:
1 - When rendering, the list of "db.userInfo" (literally) is displayed in the combo box for "Creator"! I want this to display db.userInfo.auth.username which are already in the database ... how to do this?
2 - So, where is my "db.gameInfo" to choose?
Thank you! = D
======
czarchaic answered my question very well! Boo now I only need a small question:
modelform boost_trophy:
class boost_trophy(models.Model):
boost = models.ForeignKey(boost)
trophy = models.ForeignKey(gameTrophyInfo)
# 0 - Obtiveis
# 1 - Requisitos minimos
type = models.IntegerField(default=0)
class gameTrophyInfo(models.Model):
game = models.ForeignKey(gameInfo)
name = models.CharField(max_length=500)
desc = models.CharField(max_length=500)
type = models.CharField(max_length=20)
, , "" , : gameTrophyInfo (game__name = "Game_A" ). ?