I am starting the polls project for the second time. I decided this time to go through the beginning instructions religiously. I work my way down to “python manage.py run server” which should work fine, but I get "No module named “able2.settings”. Of course, right there it is in the file structure — able2/able2/settings.py.
able2 is the name I gave the project in PyCharm. So, the project actually looks like this: Able2/able2/able2/settings.py
Best guess is that you’re in the wrong directory when trying to run this.
For “able2.settings” to be a valid reference, you’d need to be in Able2/able2 as your current directory.
What directory is your manage.py in?
(Also, and I’m guessing it’s a typing error when composting your message, but it’s python manage.py runserver - runserver as 1 word, not “run server” as 2 words.)
Now I get an error that Django is not installed, which of course it is. I am throwing everything away and starting over. I did this just fine the first time.
Wow. So, I put everything at the right level and Django disappeared.
Starting over once again. I could not find a way to resolve the issue
of “no polls.detail” when it is right there in plain sight. So, I am
going to try to work all the way down to it again and see if it is still
a problem. It simply doesn’t make any sense.
Plus, I got through the “NoReverse…” stuff and how have " TemplateDoesNotExist for a template name “polls/question_detail.html” which definitely DOES NOT exist. I have looked through my code to find where the program came up with this address and can’t find. It is the result of clicking on one of the questions that appear in the questions list. It has to be in the code somewhere doesn’t it. I am going to try a search in PyCharm on “question_detail”
That would be an indication of something going wrong in the latter steps of part 4.
See Amend views and the text below the example where it explains about question_detail being the default template being looked for if you don’t have the generic view defined correctly.
This is driving me crazy. There is something fundamentally wrong with what I am doing. I am going back into projects in PyCharm and trying to run them. I can’t even get to the index page with getting a 404 telling me its tried the URL patterns, say polls/ or admin/ and the empty path doesn’t match any these. This is projects that were working. Now I am going back into them looking for hints and I get this all the time. I always check the pwd and it is correct. I just don’t understand what has happened.
Sounds more like a Python environmental issue rather than a Django configuration issue. I’d look at how your packages are installed and see how things work directly from the command line rather than through PyCharm to see what might be going wrong that may be masked by PyCharm.
Hi Ken,
I think you are right on. I had to stop for the day I was just so
frustrated. But, of course, I couldn’t stop thinking about and I
started wondering about PyCharm. I am pretty sure that I haven’t had
these problems when I have started everything from the command line in
Terminal. I will try that tomorrow. Plus, maybe I am not using PyCharm
correctly.
Including the full and complete statement being entered along with the error message may help.
You’re trying to reference a field named pub_date_year - no such field exists. What you’re really trying to get to is the year component within the pub_date object, which is referenced with the double underscore, which means you want pub_date__year.
Thanks, but not sure what the “full and complete statement” means. The shell command is Question.objects.get(pub_date_year). I thought that this code would set up the the pub_date object access:
I am referring to what you were entering in the shell, followed by the error message you received as a response.
The statement Question.objects.get(pub_date_year) isn’t valid syntactically, and doesn’t match any of the examples in the docs. So I’m just trying to establish what it is you’re trying to do, and then use that information to try and explain why you’re getting the error message you’re receiving.
If you print out the tutorial, which is the only way I can reference the reference, on page 8, about ½ way down is:
“>>> Question.objects.get(pub_date_year=current_date)”
Sorry, I truncated it in the “help” message, but that command produces the error:
FieldError: Cannot resolve keyword ‘pub_date_year’ into field. Choices are: choice, id, pub_date, question_text
That formatting, which I don’t understand, produces a coding error, so I erased the dash and move the line datetime.timedelta(days=1) down two lines and left justified it.
I didn’t include that in the code snippet above. But, it’s two lines down and in line with “Class” above. That was the only way I could get the interpreter to accept it.
You’re trying to reference a field named pub_date_year - no such field exists. What you’re really trying to get to is the year component within the pub_date object, which is referenced with the double underscore , which means you want pub_date__year .