Skip to content

Commit 229be01

Browse files
committed
Initial commit of completed app
1 parent 8dd42bd commit 229be01

25 files changed

+489
-0
lines changed

.vscode/launch.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File (Integrated Terminal)",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
},
14+
{
15+
"name": "Python: Attach",
16+
"type": "python",
17+
"request": "attach",
18+
"port": 5678,
19+
"host": "localhost"
20+
},
21+
{
22+
"name": "Python: Django",
23+
"type": "python",
24+
"request": "launch",
25+
"program": "${workspaceFolder}/web_project/manage.py",
26+
"console": "integratedTerminal",
27+
"args": [
28+
"runserver",
29+
"--noreload",
30+
"--nothreading"
31+
],
32+
"django": true
33+
},
34+
{
35+
"name": "Python: Flask",
36+
"type": "python",
37+
"request": "launch",
38+
"module": "flask",
39+
"env": {
40+
"FLASK_APP": "app.py"
41+
},
42+
"args": [
43+
"run",
44+
"--no-debugger",
45+
"--no-reload"
46+
],
47+
"jinja": true
48+
},
49+
{
50+
"name": "Python: Current File (External Terminal)",
51+
"type": "python",
52+
"request": "launch",
53+
"program": "${file}",
54+
"console": "externalTerminal"
55+
}
56+
]
57+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "${workspaceFolder}\\env\\Scripts\\python.exe"
3+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
This sample contains the completed program from the tutorial, [Using Django in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-django). Intermediate steps are not included.
2+
3+
Contributions to the sample are welcome. When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is [tutorial-django.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-django.md).
14

25
# Contributing
36

web_project/hello/__init__.py

Whitespace-only changes.

web_project/hello/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

web_project/hello/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class HelloConfig(AppConfig):
5+
name = 'hello'

web_project/hello/forms.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django import forms
2+
from .models import LogMessage
3+
4+
class LogMessageForm(forms.ModelForm):
5+
class Meta:
6+
model = LogMessage
7+
fields = ('message',) # NOTE: the trailing comma is required
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 2.1.1 on 2018-09-11 22:31
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='LogMessage',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('message', models.CharField(max_length=300)),
19+
('log_date', models.DateTimeField(verbose_name='date logged')),
20+
],
21+
),
22+
]

web_project/hello/migrations/__init__.py

Whitespace-only changes.

web_project/hello/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.db import models
2+
3+
class LogMessage(models.Model):
4+
message = models.CharField(max_length=300)
5+
log_date = models.DateTimeField('date logged')
6+
7+
def __unicode__(self):
8+
"""Returns a string representation of a message."""
9+
return "'" + self.text + "' logged on " + log_date.strftime('%A, %d %B, %Y at %X')

0 commit comments

Comments
 (0)