Created
November 2, 2019 01:50
-
-
Save ggamit1/a45ddfbc71a83fc5ecc0f1937a6f6571 to your computer and use it in GitHub Desktop.
django Hello
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from .models import Question | |
admin.site.register(Question) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
class PollsConfig(AppConfig): | |
name = 'polls' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 3.1 on 2019-10-20 17:54 | |
from django.db import migrations, models | |
import django.db.models.deletion | |
class Migration(migrations.Migration): | |
initial = True | |
dependencies = [ | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Question', | |
fields=[ | |
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
('question_text', models.CharField(max_length=200)), | |
('pub_date', models.DateTimeField(verbose_name='date published')), | |
], | |
), | |
migrations.CreateModel( | |
name='Choice', | |
fields=[ | |
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
('choice_text', models.CharField(max_length=200)), | |
('votes', models.IntegerField(default=0)), | |
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.Question')), | |
], | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from django.db import models | |
from django.utils import timezone | |
class Question(models.Model): | |
# ... | |
def was_published_recently(self): | |
return self.pub_date >= timezone.now() - datetime.timedelta(days=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from . import views | |
urlpatterns = [ | |
path('', views.index, name='index'), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
def index(request): | |
print("jdfkdjfjdfjdjflsd") | |
return HttpResponse("Hello,sh pycharm.sh world. You're at the polls index.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment