GithubHelp home page GithubHelp logo

Comments (5)

jasonjoh avatar jasonjoh commented on June 2, 2024

Interesting. This may be a change to Django. I did not have to modify settings.py this way. I took a look at their documentation and don't see anything about a change here though.

From https://docs.djangoproject.com/en/3.1/intro/tutorial03/#write-views-that-actually-do-something, it looks like you shouldn't have to do this:

Your project’s TEMPLATES setting describes how Django will load and render templates. The default settings file configures a DjangoTemplates backend whose APP_DIRS option is set to True. By convention DjangoTemplates looks for a “templates” subdirectory in each of the INSTALLED_APPS.

Within the templates directory you have just created, create another directory called polls, and within that create a file called index.html. In other words, your template should be at polls/templates/polls/index.html. Because of how the app_directories template loader works as described above, you can refer to this template within Django as polls/index.html.

With 'APP_DIRS': True, the app should work, since the directory structure is following the app_name/templates/app_name convention. What version of Django are you using?

from msgraph-sample-pythondjangoapp.

natisdale avatar natisdale commented on June 2, 2024

Django==3.1.4

Looking at the diff I see that 3.1.4 uses pathlib whereas 3.0.4 used os, to build BASE_DIR.

BASE_DIR = Path(__file__).resolve().parent.parent   

instead of

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Swapping out settings.py with the one in this repo works fine.

from msgraph-sample-pythondjangoapp.

jasonjoh avatar jasonjoh commented on June 2, 2024

Interesting. I have 3.1.4 on my machine, but when it generates a project, settings.py still says it was generated by 3.0.4, and it uses the os.path.dirname approach. It looks like I've got an issue with multiple Python versions on this machine. I'll clean that up and get this straightened out in the tutorial. Thanks for reporting.

from msgraph-sample-pythondjangoapp.

jasonjoh avatar jasonjoh commented on June 2, 2024

I cleaned up my Python installs and started this over with Python 3.9.2 and Django 3.1.7. I did see the following line in settings.py:

BASE_DIR = Path(__file__).resolve().parent.parent

However, I still did not need to modify settings.py as you did. Did you add tutorial in the INSTALLED_APPS section as described in step 6? If I skip that step I also get a TemplateDoesNotExist error.

from msgraph-sample-pythondjangoapp.

msftbot avatar msftbot commented on June 2, 2024

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

from msgraph-sample-pythondjangoapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.