Skip to content

Commit 94f8408

Browse files
committed
updates from old bugs
1 parent 0756832 commit 94f8408

3 files changed

+33
-40
lines changed

docs/python/learn-django-in-visual-studio-step-04-full-django-project-template.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description: A walkthrough of Django basics in the context of Visual Studio proj
55
ms.date: 02/16/2022
66
ms.custom: devdivchpfy22
77
ms.topic: tutorial
8-
author: ijoosong
9-
ms.author: joesong
8+
author: cwebster-99
9+
ms.author: cowebster
1010
manager: jmartens
1111
ms.technology: vs-python
1212

@@ -35,7 +35,7 @@ The template also provides basic authentication, which is covered in [Step 5](le
3535

3636
1. In Visual Studio, go to **Solution Explorer**, right-click the **LearningDjango** solution created earlier in this tutorial. Then, select **Add** > **New Project**. (If you want to use a new solution, select **File** > **New** > **Project** instead.)
3737

38-
1. In the **New Project** dialog, search for and select the **Django Web Project** template. Call the project "DjangoWeb", and then select **OK**.
38+
1. In the **New Project** dialog, search for and select the **Django Web Project** template. Call the project "DjangoWeb", and then select **Create**.
3939

4040
1. As the template includes a *requirements.txt* file, Visual Studio prompts for the location to install the dependencies. When prompted, choose the option, **Install into a virtual environment**, and in the **Add Virtual Environment** dialog select **Create** to accept the defaults.
4141

@@ -171,34 +171,30 @@ The Django project's *urls.py* file as created by the "Django Web Project" templ
171171

172172
```python
173173
from datetime import datetime
174-
from django.conf.urls import url
175-
import django.contrib.auth.views
174+
from django.urls import path
175+
from django.contrib import admin
176+
from django.contrib.auth.views import LoginView, LogoutView
177+
from app import forms, views
176178

177-
import app.forms
178-
import app.views
179179

180180
urlpatterns = [
181-
url(r'^$', app.views.home, name='home'),
182-
url(r'^contact$', app.views.contact, name='contact'),
183-
url(r'^about$', app.views.about, name='about'),
184-
url(r'^login/$',
185-
django.contrib.auth.views.login,
186-
{
187-
'template_name': 'app/login.html',
188-
'authentication_form': app.forms.BootstrapAuthenticationForm,
189-
'extra_context':
190-
{
191-
'title': 'Log in',
192-
'year': datetime.now().year,
193-
}
194-
},
195-
name='login'),
196-
url(r'^logout$',
197-
django.contrib.auth.views.logout,
198-
{
199-
'next_page': '/',
200-
},
201-
name='logout'),
181+
path('', views.home, name='home'),
182+
path('contact/', views.contact, name='contact'),
183+
path('about/', views.about, name='about'),
184+
path('login/',
185+
LoginView.as_view
186+
(
187+
template_name='app/login.html',
188+
authentication_form=forms.BootstrapAuthenticationForm,
189+
extra_context=
190+
{
191+
'title': 'Log in',
192+
'year' : datetime.now().year,
193+
}
194+
),
195+
name='login'),
196+
path('logout/', LogoutView.as_view(next_page='/'), name='logout'),
197+
path('admin/', admin.site.urls),
202198
]
203199
```
204200

docs/python/learn-django-in-visual-studio-step-05-django-authentication.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description: A walkthrough of Django basics in the context of Visual Studio proj
55
ms.date: 02/16/2022
66
ms.custom: devdivchpfy22
77
ms.topic: tutorial
8-
author: ijoosong
9-
ms.author: joesong
8+
author: cwebster-99
9+
ms.author: cowebster
1010
manager: jmartens
1111
ms.technology: vs-python
1212

@@ -154,18 +154,15 @@ The following steps exercise the authentication flow and describe the parts of t
154154

155155
1. Install the docutils Python package into your environment. A great way to install is to add "docutils" to your *requirements.txt* file. Then, go to **Solution Explorer**, expand the project, expand the **Python Environments** node, and then right-click the environment you're using and select **Install from requirements.txt**.
156156

157-
1. Open the Django project's *urls.py* file and remove the default comments from the following entries:
157+
1. Open the Django project's *urls.py* file and add the following:
158158

159159
```python
160160
from django.conf.urls import include
161161
from django.contrib import admin
162162
admin.autodiscover()
163163

164-
# ...
165164
urlpatterns = [
166-
# ...
167-
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
168-
url(r'^admin/', include(admin.site.urls)),
165+
path('admin/doc/', include('django.contrib.admindocs.urls'))
169166
]
170167
```
171168

@@ -178,7 +175,7 @@ The following steps exercise the authentication flow and describe the parts of t
178175
1. The final part to the authentication flow is logging off. As you can see in *loginpartial.html*, the **Log off** link simply does a POST to the relative URL "/login", which is handled by the built-in view `django.contrib.auth.views.logout`. This view doesn't display any UI and just navigates to the home page (as shown in *urls.py* for the "^logout$" pattern). If you want to display a logoff page, first change the URL pattern as follows to add a "template_name" property and remove the "next_page" property:
179176

180177
```python
181-
url(r'^logout$',
178+
path('logout/',
182179
django.contrib.auth.views.logout,
183180
{
184181
'template_name': 'app/loggedoff.html',

docs/python/managing-python-environments-in-visual-studio.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Manage Python environments and interpreters
33
description: Use the Python Environments window to manage global, virtual, and conda environments. Install Python interpreters and packages and assign environments to Visual Studio projects.
4-
ms.date: 12/11/2021
4+
ms.date: 12/12/2022
55
ms.customL: devdivchpfy22
66
ms.topic: how-to
7-
author: ijoosong
8-
ms.author: joesong
7+
author: cwebster-99
8+
ms.author: cowebster
99
manager: jmartens
1010
ms.technology: vs-python
1111
ms.workload:
@@ -296,7 +296,7 @@ To correct an environment you wish to keep, first try using its installer's **Re
296296
Use the following steps to modify the registry directly. Visual Studio automatically updates the**Python Environments** window when you make changes to the registry.
297297

298298
1. Run *regedit.exe*.
299-
1. Navigate to **HKEY_LOCAL_MACHINE\SOFTWARE\Python** or **HKEY_CURRENT_USER\SOFTWARE\Python**. For IronPython, look for **IronPython** instead.
299+
1. Navigate to **HKEY_LOCAL_MACHINE\SOFTWARE\Python** or **HKEY_CURRENT_USER\SOFTWARE\Python**. For 32-bit versions of Python, the registry key can under **HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python**. For IronPython, look for **IronPython** instead.
300300
1. Expand the node that matches the distribution, such as **Python Core** for CPython or **ContinuumAnalytics** for Anaconda. For IronPython, expand the version number node.
301301
1. Inspect the values under the **InstallPath** node:
302302

0 commit comments

Comments
 (0)