Learning Circle : django #7 - Tutorial07, IPV6 #1

This commit is contained in:
youngjin.han 2020-07-23 00:39:21 +09:00
parent 435eb4f35a
commit 7abf1acb46
18 changed files with 86 additions and 5 deletions

View File

@ -60,7 +60,7 @@ ROOT_URLCONF = 'mysite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [

View File

@ -4,6 +4,34 @@ from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.
from .models import Question
from .models import Choice, Question
admin.site.register(Question)
#admin.site.register(Question)
#class QuestionAdmin(admin.ModelAdmin):
# fields = ['pub_date', 'question_text']
#class QuestionAdmin(admin.ModelAdmin):
# fieldsets = [
# (None, {'fields': ['question_text']}),
# ('Date information', {'fields': ['pub_date']}),
# ]
#class ChoiceInline(admin.StackedInline):
class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3
class QuestionAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question_text']}),
('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
]
inlines = [ChoiceInline]
#list_display = ('question_text', 'pub_date')
list_display = ('question_text', 'pub_date', 'was_published_recently')
list_filter = ['pub_date']
search_fields = ['question_text']
admin.site.register(Question, QuestionAdmin)
admin.site.register(Choice)

View File

@ -19,6 +19,9 @@ class Question(models.Model):
# return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
now = timezone.now()
return now - datetime.timedelta(days=1) <= self.pub_date <= now
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)

View File

@ -0,0 +1,10 @@
{% extends "admin/base.html" %}
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">Polls Administration</a>
</h1>
{% endblock %}
{% block nav-global %}{% endblock %}

View File

@ -0,0 +1,3 @@
* 2020-07-22
** note
- none

View File

@ -0,0 +1,17 @@
from sys import argv
import ipaddress
script, ip1, ip2 = argv
network_1 = ipaddress.ip_network(ip1)
network_2 = ipaddress.ip_network(ip2)
#print(list(network_1))
#print(list(network_2))
if True == network_1.overlaps(network_2):
print('overlap')
else:
print('no overlap')

View File

@ -1,13 +1,33 @@
* 2020-07-22
*** IPv6 #1: IPv6 address uniqueness
**** DONE Lecture content
CLOSED: [2020-07-23 목 00:06]
- Ensure Uniqueness
- Every IPv6 address we register should REPRESENT a /48
- We need to ensure that we don't register overlapping networks
- Write a python script that checks whether two IPv6 networks are overlapping
- *overlap.py ip1 ip2*
- It should output "overlap" or "no overlap"
- Use the following test IPv6 addresses:
- 2001:db8::
- 2001:db8:0:2::
- 2001:db8:1::
- Assume a netmask of /48 for all of them
- Step 2: Make your script parse ipv6 networks (like
2001:db8::/48 and 2001:db8::/64) ) and check whether they overlap
- Make use of the python3 module *ipaddress*
* 2020-07-15
*** Django #7: Tutorial 6
**** Lecture content
**** DONE Lecture content
CLOSED: [2020-07-22 수 22:25]
- Environment like in Django 1 and Django 3
- Ensure your nginx is working
- Paste the URL of your Django server into the chat
- Ensure you can reach the other Django servers
- Follow steps on https://docs.djangoproject.com/en/3.0/intro/tutorial06/
*** Django #8: Tutorial 7
**** Lecture content
**** DONE Lecture content
CLOSED: [2020-07-22 수 22:25]
- Environment like in Django 1 and Django 3
- Ensure your nginx is working
- Paste the URL of your Django server into the chat