-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
from .models import Person | ||
|
||
|
||
class PersonAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"first_name", | ||
"last_name", | ||
) | ||
|
||
|
||
admin.site.register(Person, PersonAdmin) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.db import models | ||
|
||
|
||
class Person(models.Model): | ||
first_name = models.CharField(max_length=100) | ||
last_name = models.CharField(max_length=100, blank=True) | ||
last_name = models.CharField(max_length=100) | ||
country = models.CharField(max_length=100, blank=True) | ||
mobile_number = models.CharField(max_length=20, blank=True) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
|
||
<body> | ||
<h1>Welcome to the Pacific Connect Community Database</h1> | ||
On this site, you can find details of members of the Pacific Connect Community Database | ||
{% block content %}{% endblock %} | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
|
||
<body> | ||
This is my list of folks | ||
<ul> | ||
{% for person in object_list %} | ||
<li>{{ person.first_name }} {{ person.last_name }} | ||
from {{ person.country }}</li> | ||
{% endfor %} | ||
</ul> | ||
</body> | ||
|
||
</html> |
11 changes: 11 additions & 0 deletions
11
src/community_db/templates/community_db/person_list_in_base.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
This is my list of folks | ||
<ul> | ||
{% for person in object_list %} | ||
<li>{{ person.first_name }} {{ person.last_name }} | ||
from {{ person.country }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endblock %} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
from django.http import HttpResponse | ||
from django.shortcuts import render | ||
from django.template import loader | ||
from django.views.generic.list import ListView | ||
|
||
# Create your views here. | ||
from community_db.models import Person | ||
|
||
|
||
def list_persons(request): | ||
html = "<html><body>This is my list of folks<ul>" | ||
|
||
for person in Person.objects.all(): | ||
html += f"<li>{person.first_name} {person.last_name} from {person.country}</li>" | ||
|
||
html += "</ul></body></html>" | ||
return HttpResponse(html) | ||
|
||
|
||
# def list_persons_with_template(request): | ||
# persons = Person.objects.all() | ||
# template = loader.get_template("community_db/person_list.html") | ||
# context = {"object_list": persons} | ||
# return HttpResponse(template.render(context, request)) | ||
|
||
|
||
def list_persons_with_template(request): | ||
persons = Person.objects.all() | ||
template = loader.get_template("community_db/person_list_in_base.html") | ||
context = {"object_list": persons} | ||
return HttpResponse(template.render(context, request)) | ||
|
||
|
||
# def list_persons_with_template(request): | ||
# persons = Person.objects.all() | ||
# context = {"object_list": persons} | ||
# return render(request, "community_db/person_list.html", context) | ||
|
||
|
||
class PersonListView(ListView): | ||
model = Person | ||
template_name = "community_db/person_list_in_base.html" |
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