0

I have created a project called class , and an application called students when I write views, I have to use

items = class.objects.all()

which is giving me error :( please tell me way to overcome the error without changing my project name..

Thanks :)

5
  • "please tell me way to overcome the error without changing my project name" Funny. You cannot use Python reserved words. "class" is reserved. You cannot use it. Rename your project. Don't ask for miracles that don't exist. Commented Sep 22, 2010 at 1:32
  • 1
    Your model class should have a capitalized name anyway (PEP8). Commented Sep 22, 2010 at 1:41
  • lol ,I changed the project name to school :P , please excuse me as I am still learner ( 2nd day of using django ) but, I expect django to give error while creating the project itself, I get it when I create a project called test .. Commented Sep 22, 2010 at 4:10
  • na: "I expect django to give error". "2nd day of using django ". Please don't depend on your expectations. With no experience, having expectations is a bad habit. After you get more experience, you'll learn that -- as I said -- You cannot use Python reserved words. That is the fact of life. Expectations are a problem, try to live without them. Just read the documentation for Python and Django carefully and treat it as being all new to you. Because it is. Commented Sep 22, 2010 at 9:57
  • Thanks for enlightening me .. Commented Sep 22, 2010 at 13:09

1 Answer 1

3

I think you'll have to rename it. 'class' is a keyword in python.

http://docs.python.org/reference/lexical_analysis.html#keywords

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.