django models - NameError: name 'u1' is not defined -


I'm trying to follow the django tutorial but by my own work.

The Models.py file appears from imported model class user (models.Model) from Django.db: alias = model. CHAfild (max_land = 30) password = model.ccarfield (max_long = 30) email = model.mailfield (

) Reg_date = models.DateField () class questions (models.Model): head = model. Carfield (max_long = 50) content = model. TextField () Writer = Model. Fergenky (user) date = model.defild () Category Answer (Models.Model): Content = Model Textfield () Question = Model Foreign (Question) Author = Model. Date of Fenarki (user) = Model DataField () Validity = Model Booleanfield ()   

I created "python manage.py shell" and wrote something like this:

  & gt; & Gt; & Gt; U1 = User (alias = 'Alex', password = '123', email = 'xx_mail.ru', reg_date = '2013-01-07')> gt; & Gt; & Gt; U1.save ()> gt; & Gt; & Gt; U2 = User (alias = 'kate', password = 'abcde', email '' kitten@mail.ru '', reg_date = '2012-12-15')> gt; & Gt; & Gt; User.weet ()   

User_list sent me

  [& lt; User: User Object & gt;, & lt; User: User Object & gt;]   

But then I left and made some changes to the code. After this I got the U 1 Delete () or U2 Can not delete () because it denotes the name error: The name 'U1' is not defined, but still shows me a list of two users. I can also create new u1 and u2 and remove them How can I now apply those past users to clean the database?

If you have all user rows:

 < Code> User.objects.all (). Delete ()   

If you want to search two and create the code you want to delete:

  User.objects.get (alias = 'Alex') . Delete () User.objects.get (alias = 'kate'). Delete ()    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -