Ну, я что-то разработал, но я не уверен, как реализовать .Включить блок не отображается в шаблоне django
models.py
class Notificaciones(models.Model):
IDcliente = models.ManyToManyField(User)
Tipo_de_notificaciones = ((1,'Ofertas'),(2,'Error'),(3,'Informacion'))
Tipo = models.IntegerField('Tipo de notificacion',choices=Tipo_de_notificaciones, default=3,)
Nombre_not = models.CharField("Nombre de la notifiacion",max_length=50)
Descripcion_not = HTMLField("Descripcion de la notificacion")
Imagen_not = models.ImageField("Imagen de la notificacion",upload_to="notificaciones")
Fecha_Caducidad_notificacion = models.DateTimeField("Fecha de caducidad de la notificacion",auto_now_add=False)
class Meta:
verbose_name = 'Notificacion'
verbose_name_plural = 'Notificaciones'
def __str__(self):
return self.Nombre_not
views.py
def notifi(request):
notifi = Notificaciones.objects.all()
return render_to_response('app/notificaciones.html',{ 'notifi' : notifi })
Теперь я хочу, чтобы показать уведомление в заголовке в лайтбокс, то в моем layout.html, где заголовок, нижний колонтитул и т. д. Но когда я вызываю уведомление, оно не появляется.
<div id="notifiaciones" class="notificaciones notificacionesTrans" tabindex="-1" role="dialog" aria-hidden="true" >
{% include 'app/notificaciones.html' %}
</div>
Может кто-нибудь объяснить, могу ли я вызвать уведомление из представлений или это должно быть сделано каким-то еще?
URL.PY
url(r'^tinymce/', include('tinymce.urls')),
url('', include('django.contrib.auth.urls', namespace='auth')),
url(r'^social/',include('social.apps.django_app.urls', namespace='social')),
#url(r'^s$', 'app.views.CategoriaProductoss', name='servicios'),
#url(r'^s/(?P<id>\d+)$', 'app.views.servicioscategoria', name='servicioscategoria'),
url(r'^notificaciones/$', 'app.views.notifi', name='notificaciones'),
url(r'^media/(?P<path>.*)$','django.views.static.serve', {'document_root':settings.MEDIA_ROOT,}),
url(r'^$', 'django.contrib.auth.views.login',{'template_name':'app/index.html'}, name='Vulpini.co'),
url(r'^$', 'django.contrib.auth.views.logout', name='logout'),
url(r'start$', 'app.views.start', name="start"),
url(r'ajax-upload$', 'app.views.import_uploader', name="my_ajax_upload"),
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
Notificación.html
<ul>
{% for notifi in notifi %}
<li>{{ notifi.Tipo }}
{{ notifi.Nombre_not }}
<img src="{{ notifi.Imagen_not }}" alt="{{ notifi.Nombre_not }}"/>
{{ notifi.Fecha_Caducidad_notificacion }}
</li>
{% endfor %}
</ul>
Логиниться Внутри layout.html
<form action="/login" class="form-horizontal" method="post">
{% csrf_token %}
<h4>Iniciar Sesion.</h4>
<hr />
<div class="login-social">
<a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}" target="iframe">Iniciar sesion con Facebook</a>
<a href="{% url 'social:begin' 'twitter' %}?next={{ request.path }}" target="iframe">Iniciar sesion con Twitter</a>
</div>
<hr />
<div class="form-group">
<label class="control-label" for="inputEmail">Usuario</label>
<div class="controls">
<input name="username" type="text" id="inputEmail" placeholder="Usuario"/>
</div>
</div>
<div class="form-group">
<label class="control-label" for="inputPassword">Contraseña</label>
<div class="controls">
<input name="password" type="password" id="inputPassword" placeholder="Contraseña"/>
</div>
</div>
<div class="form-group">
<label class="checkbox">
<input type="checkbox" />Recordar</label>
<button type="submit" class="btn btn-info">Ingresar</button>
<a href="/">Registrar</a>
</div>
</form>
Кажется, все в порядке. Покажите свое 'приложение/notificaciones.html'. Как насчет 'urls'? Блок «вкл.» способен только вставлять html, а не данные из представления, поэтому вы должны привязать его к нужному шаблону самостоятельно. – chem1st
@ Alfredhb.q вы можете отредактировать свое сообщение, чтобы показать нам приложение/notificaciones.html и ваш файл URLs.py? – user2719875
@ user2719875 done, я отредактировал сообщение и покажу свои notificaciones.html и URLs.py –