Add API
This commit is contained in:
0
app/web/__init__.py
Normal file
0
app/web/__init__.py
Normal file
3
app/web/admin.py
Normal file
3
app/web/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
6
app/web/apps.py
Normal file
6
app/web/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class WebConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app.web'
|
0
app/web/migrations/__init__.py
Normal file
0
app/web/migrations/__init__.py
Normal file
26
app/web/templates/layouts/base.html
Normal file
26
app/web/templates/layouts/base.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}{% endblock %} | Djanker News</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{% url 'list' %}">List</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'add-news' %}">Add News</a>
|
||||
</li>
|
||||
</ul>
|
||||
</header>
|
||||
<main>
|
||||
<h1>Djanker News</h1>
|
||||
{% block main %}{% endblock %}
|
||||
</main>
|
||||
<footer>
|
||||
2021 Djanker News
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
10
app/web/templates/pages/add-news.html
Normal file
10
app/web/templates/pages/add-news.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
12
app/web/templates/pages/list.html
Normal file
12
app/web/templates/pages/list.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends 'layouts/base.html' %}
|
||||
{% block title %}Welcome{% endblock %}
|
||||
{% block main %}
|
||||
{% for item in news %}
|
||||
<article>
|
||||
<h2>{{ item.title }}</h2>
|
||||
<p>
|
||||
<a href="{{ item.url }}">Ver completo</a>
|
||||
</p>
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
3
app/web/tests.py
Normal file
3
app/web/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
12
app/web/views.py
Normal file
12
app/web/views.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.shortcuts import render
|
||||
from app.api.models import News
|
||||
|
||||
|
||||
def home(request):
|
||||
return render(request, 'pages/list.html', {
|
||||
'news': News.objects.all()
|
||||
})
|
||||
|
||||
|
||||
def add_news(request):
|
||||
return render(request, 'pages/add-news.html', {})
|
Reference in New Issue
Block a user