Django教程Shenanigans

时间:2015-05-10 00:51:36

标签: python django

Aloha chaps,

有点麻烦的Django教程

safer

正如您在下面看到的,它是在说'问题'没有定义。

from django.db import models

class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    question = models.ForeignKey(Question)
    choice_text = models.Charfield(max_length=200)
    votes = models.IntegerField(default=0)

这是我的models.py文件

 public void btn_move_Click(object sender, EventArgs e)
        {

            if (locationArea == 165 && locationDistrict == 1 && locationSection == 1 )
            {

            }
            //SURVIVAL
            if (thirst < 0)
            {
                thirst = 0;
            }
            if (hunger < 0)
            {
                hunger = 0;
            }
            if (thirst == 0)
            {
                tmr_health.Start();
            }

            if (hunger == 0)
            {
                tmr_health.Start();
            }
            //BEAT GAME
            if (gameprogress == 0 && difficultynormal == 1)
            {
                tmr_health.Stop();
                MessageBox.Show("Normal win text", "Congratulations!");
                this.Close();
            }

            if (gameprogress == 0 && difficultyhardcore == 1)
            {
                tmr_health.Stop();
                MessageBox.Show("Hardcore win text", "Congratulations!");
                this.Close();
            }

            if (gameprogress == 0 && difficultyinsane == 1)
            {
                tmr_health.Stop();
                MessageBox.Show("Insane win text", "Congratulations!");
                this.Close();
            }

            if (gameprogress == 0 && difficultyimpossible == 1)
            {
                tmr_health.Stop();
                MessageBox.Show("Impossible win text", "Congratulations!");
                this.Close();
            }

            if (rb_crouching.Checked == true)
            {
                timehour = timehour + 1;
            }

            gameprogress = gameprogress - 1;
            //Int to Label
            lbl_gameprogressvalue.Text = gameprogress.ToString();
            lbl_locationDistrictValue.Text = locationDistrict.ToString();
            lbl_timeHour.Text = timehour.ToString();
            lbl_locationSectionValue.Text = locationSection.ToString();
            lbl_locationAreaValue.Text = locationArea.ToString();
            lbl_ingamehungervalue.Text = hunger.ToString();
            lbl_ingamethirstvalue.Text = thirst.ToString();

            //STAT DEPLEATION
            if (rb_walking.Checked == true)
            {
                thirst = thirst - 10;
                hunger = hunger - 5;
            }
            if (rb_jogging.Checked == true)
            {
                thirst = thirst - 15;
                hunger = hunger - 10;
            }
            if (rb_sprinting.Checked == true)
            {
                thirst = thirst - 20;
                hunger = hunger - 15;
            }
            if (rb_crouching.Checked == true)
            {
                thirst = thirst - 5;
                hunger = hunger - 5;
            }

            timehour = timehour + 1;
            locationSection = locationSection + 1;
            if (timehour > 12 && lbl_timeEnding.Text == "AM")
            {
                timehour = 1;
                lbl_timeEnding.Text = PM;
            }

            if (lbl_timeEnding.Text == PM && timehour > 12)
            {
                lbl_timeEnding.Text = "AM";
                timehour = 1;
                dateday = dateday + 1;
                dayssurvived = dayssurvived + 1;
                lbl_dayssurvivedvalue.Text = dayssurvived.ToString();
                lbl_dateDay.Text = dateday.ToString();




            }
            if (locationSection == 11)
            {
                locationSection = 0;
                locationDistrict = locationDistrict + 1;
            }

            if (locationDistrict == 6)
            {
                locationDistrict = 0;
                locationArea = locationArea + 1;
            }

        }

提前感谢您提供任何帮助

2 个答案:

答案 0 :(得分:2)

不要嵌套课程。缩小您的缩进级别。选择需要与问题处于同一级别,而不是问题内部。你在这里错误的缩进和堆栈跟踪就可以了。

答案 1 :(得分:1)

from django.db import models

class Question(models.Model):
     question_text = models.CharField(max_length=200)
     pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    question = models.ForeignKey(Question)
    choice_text = models.Charfield(max_length=200)
    votes = models.IntegerField(default=0)

认同是问题