Search Results

Search found 4 results on 1 pages for 'user292652'.

Page 1/1 | 1 

  • Django admin site populated combo box based on imput

    - by user292652
    hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two = models.ForeignKey('Team', related_name='Team_two') Stadium = models.CharField(max_length=255, blank=True) Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True, null=True) Rafree = models.CharField(max_length=255, blank=True) Judge = models.CharField(max_length=255, blank=True) Winner = models.ForeignKey('Team', related_name='winner', blank=True) updated = models.DateTimeField('update date', auto_now=True ) created = models.DateTimeField('creation date', auto_now_add=True ) def save(self, force_insert=False, force_update=False): pass @models.permalink def get_absolute_url(self): return ('view_or_url_name') class MatchAdmin(admin.ModelAdmin): list_display = ('Team_one','Team_two', 'Winner') search_fields = ['Team_one','Team_tow'] admin.site.register(Match, MatchAdmin) i was wondering is their a way to populated the winner combo box once the team one and team two is selected in admin site ?

    Read the article

  • Django admin site auto populate combo box based on input

    - by user292652
    hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two = models.ForeignKey('Team', related_name='Team_two') Stadium = models.CharField(max_length=255, blank=True) Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True, null=True) Rafree = models.CharField(max_length=255, blank=True) Judge = models.CharField(max_length=255, blank=True) Winner = models.ForeignKey('Team', related_name='winner', blank=True) updated = models.DateTimeField('update date', auto_now=True ) created = models.DateTimeField('creation date', auto_now_add=True ) def save(self, force_insert=False, force_update=False): pass @models.permalink def get_absolute_url(self): return ('view_or_url_name') class MatchAdmin(admin.ModelAdmin): list_display = ('Team_one','Team_two', 'Winner') search_fields = ['Team_one','Team_tow'] admin.site.register(Match, MatchAdmin) i was wondering is their a way to populated the winner combo box once the team one and team two is selected in admin site ?

    Read the article

  • Django unable to update model

    - by user292652
    i have the following function to override the default save function in a model match def save(self, *args, **kwargs): if self.Match_Status == "F": Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1) Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1) if self.Winner !="": Team.objects.filter(pk=self.Winner.id).update(Win=F('Win')+1, Points=F('Points')+3) else: return if self.Match_Status == "D": Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1, Draw = F('Draw')+1, Points=F('Points')+1) Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1, Draw = F('Draw')+1, Points=F('Points')+1) super(Match, self).save(*args, **kwargs) I am able to save the match model just fine but Team model does not seem to be updating at all and no error is being thrown. am i missing some thing here ?

    Read the article

  • Dajano admin site foreign key fields

    - by user292652
    hi i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100) Nick = models.CharField(max_length=100, blank=True) Jersy_Number = models.IntegerField() Team_id = models.ForeignKey('Team') Postion_Choices = ( ('M', 'Manager'), ('P', 'Player'), ) Poistion = models.CharField(max_length=1, blank=True, choices =Postion_Choices) Red_card = models.IntegerField( blank=True, null=True) Yellow_card = models.IntegerField(blank=True, null=True) Points = models.IntegerField(blank=True, null=True) #Pic = models.ImageField(upload_to=path/for/upload, height_field=height, width_field=width, max_length=100) class PlayerAdmin(admin.ModelAdmin): list_display = ('Player_Name',) search_fields = ['Player_Name',] admin.site.register(Player, PlayerAdmin) class Team(models.Model): """Model docstring""" #slug = models.slugField(max_length=200) Team_Name = models.CharField(max_length=100,) College = models.CharField(max_length=100,) Win = models.IntegerField(blank=True, null=True) Loss = models.IntegerField(blank=True, null=True) Draw = models.IntegerField(blank=True, null=True) #logo = models.ImageField(upload_to=path/for/upload, height_field=height, width_field=width, max_length=100) class Meta: pass #def __unicode__(self): # return Team_Name #def save(self, force_insert=False, force_update=False): # pass @models.permalink def get_absolute_url(self): return ('view_or_url_name') class TeamAdmin(admin.ModelAdmin): list_display = ('Team_Name',) search_fields = ['Team_Name',] admin.site.register(Team, TeamAdmin) my question is how do i get to the admin site to show Team_name in the add player form Team_ID field currently it is only showing up as Team object in the combo box

    Read the article

1