Conjunto 59e991d en sapic
- Fecha y hora:
- 25/09/2017 15:52:36 (hace 7 años)
- Branches:
- gestion_usuarios, taller_django
- Children:
- af91b4e
- Parents:
- 371f822
- Ubicación:
- curso_django
- Ficheros:
-
- 2 añadidos
- 5 editados
Leyenda
- No modificado
- Añadido
- Eliminado
-
curso_django/curso/encuesta/templates/encuesta/index.html
r371f822 r59e991d 79 79 {% endif %} 80 80 {% block contenido %} 81 81 82 <div class="post-preview"> 82 83 <a href="#"> -
curso_django/curso/encuesta/urls.py
r371f822 r59e991d 1 1 from django.conf.urls import url 2 2 from encuesta.views import QuestionListView,QuestionDetailView 3 3 from . import views 4 4 … … 13 13 url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'), 14 14 url(r'^addencuesta/$', views.addencuesta, name='addencuesta'), 15 url(r'^preguntas-list/$',QuestionListView.as_view(),name='preguntas-list'), 16 url(r'^preguntas-detail/(?P<pk>[-\w]+)/$',QuestionDetailView.as_view(), name='preguntas-detail'), 15 17 ] -
curso_django/curso/encuesta/views.py
r371f822 r59e991d 8 8 from encuesta.models import Question 9 9 from encuesta.forms import QuestionForm 10 from django.views.generic.list import ListView 11 from django.views.generic.detail import DetailView 12 from django.utils import timezone 13 10 14 11 15 def index(request): … … 43 47 formset = QuestionFormSet() 44 48 return render(request, 'encuesta/addencuesta.html',{'formset':formset}) 49 50 51 class QuestionListView(ListView): 52 model = Question 53 54 def get_context_data(self, **kwargs): 55 context = super(QuestionListView,self).get_context_data(**kwargs) 56 # context['now'] = timezone.now() 57 return context 58 59 60 class QuestionDetailView(DetailView): 61 62 model = Question 63 64 def get_context_data(self, **kwargs): 65 context = super(QuestionDetailView, self).get_context_data(**kwargs) 66 context['now'] = timezone.now() 67 return context 68 -
curso_django/curso_django.tex
r371f822 r59e991d 842 842 from django.views.generic.list import ListView 843 843 from django.utils import timezone 844 845 from articles.models import Article 846 847 class ArticleListView(ListView): 848 849 model = Article 850 844 from articles.models import Question 845 846 847 class QuestionListView(ListView): 848 model = Question 849 851 850 def get_context_data(self, **kwargs): 852 context = super(ArticleListView, 853 self).get_context_data(**kwargs) 854 context['now'] = timezone.now() 851 context = super(QuestionListView,self) 852 .get_context_data(**kwargs) 855 853 return context 854 856 855 857 856 \end{verbatim} … … 863 862 # En el archivo urls.py 864 863 from django.conf.urls import url 865 866 from article.views import ArticleListView 864 from encuesta.views import QuestionListView 867 865 868 866 urlpatterns = [ 869 url(r'^$',ArticleListView.as_view(),name='article-list'), 867 ... 868 url(r'preguntas-list/^$',QuestionListView.as_view(), 869 name='preguntas-list'), 870 870 ] 871 872 # El template 873 <h1> Articles</h1>871 # El template crear un directorio 872 templates/encuesta/question-list.html 873 <h1>Preguntas</h1> 874 874 <ul> 875 {% for articlein object_list %}875 {% for question in object_list %} 876 876 <li> 877 {{ article.pub_date|date }} - {{ article.headline}}877 {{ question.pub_date|date }} - {{ question.question_text }} 878 878 </li> 879 879 {% empty %} 880 <li>No articles yet.</li>880 <li>No hay preguntas.</li> 881 881 {% endfor %} 882 882 </ul> … … 893 893 from django.utils import timezone 894 894 895 from articles.models import Article896 897 class ArticleDetailView(DetailView):898 899 model = Article895 from encuesta.models import Question 896 897 class QuestionDetailView(DetailView): 898 899 model = Question 900 900 901 901 def get_context_data(self, **kwargs): 902 context = super( ArticleDetailView, self).902 context = super(QuestionDetailView, self). 903 903 get_context_data(**kwargs) 904 904 context['now'] = timezone.now() … … 915 915 from django.conf.urls import url 916 916 917 from article.views import ArticleDetailView917 from encuesta.views import QuestionDetailView 918 918 919 919 urlpatterns = [ 920 url(r'^ (?P<slug>[-\w]+)/$',ArticleDetailView.as_view(),921 name=' article-detail'),920 url(r'^preguntas-detail/(?P<pk>[-\w]+)/$',QuestionDetailView.as_view(), 921 name='preguntas-detail'), 922 922 ] 923 923
Nota: Vea TracChangeset
para ayuda en el uso del visor de conjuntos de cambios.