django-templates

Django WebApp for Mobile and Desktop [closed]

可紊 提交于 2019-12-07 17:31:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I made web-app with django which is perfectly looking nice over desktop-browser but in mobile-browser some pages are not looking perfectly. My template directory is myproject/template/ I want to make new templates for mobile browsers myproject/template_mobile/ and whenever

Adding Google Map Markers with DJango Template Tags in Javascript

两盒软妹~` 提交于 2019-12-07 17:24:55
问题 I am trying to add a bunch of map markers to a map using Django template tag variables as the latitude and longitude but things aren't working too well. Here is what I have in the view javascript code. I load the code in as an external JS file. Here is what i have to initialize everything. Also when I did this the google map didn't even show up any more. It disappeared. function initialize() { var latLng = new google.maps.LatLng(41.85, -87.65); map = new google.maps.Map(document

django - how to reuse a template for nearly identical models?

假装没事ソ 提交于 2019-12-07 15:59:14
问题 Still fairly new to django and python. I've defined two nearly identical models that inherit from a base class: class addressbook(models.Model): name = models.CharField(max_length=50) class company(addressbook): address = models.CharField(max_length=50) class contact(addressbook): telephone - models.CharField(max_length=30) I want to do very similar things with company and contact objects. However in my templates it looks like I need to use separate templates for each object since to access

Django 1.11 404 Page while Debug=True

时间秒杀一切 提交于 2019-12-07 15:24:39
问题 Without making things difficult , I just want to show a special 404 render with staticfiles. If you set DEBUG = False you can use in urls.py handler404 = 'app.views.handler404' But it is without staticfiles. I don't want to install a web server for a simple app. With DEBUG = True in urls url(r'^404/$', views.handler400) is not overriding the default Page not found (404) page. What is the easy way to achieve a render e.g. when you type localhost/asdfhjfsda with staticfiles when DEBUG=True ?

Passing request.user to template in Django

蓝咒 提交于 2019-12-07 14:47:57
问题 Is there another way to get the request.user by not passing it from the views? I think passing request.user from all functions in views to the template is quite wrong. Is there any method or way that the template will get the user or any object in the database? 回答1: By default (I am talking about Django version 1.3) you do not need change TEMPLATE_CONTEXT_PROCESSORS. Because default value already contains *django.contrib.auth.context_processors.auth*. So to your question: By default, you

Passing request to custom Django template loader

时光总嘲笑我的痴心妄想 提交于 2019-12-07 13:53:07
问题 I want to write custom template loader for my Django app which looks for a specific folder based on a key that is part of the request. Let me get into more details to be clear. Assume that I will be getting a key on every request(which I populate using a middleware). Example: request.key could be 'india' or 'usa' or 'uk'. I want my template loader to look for the template " templates/<key>/<template.html> ". So when I say {% include "home.html" %} , I want the template loader to load

Can't load image in my django template

左心房为你撑大大i 提交于 2019-12-07 13:47:26
My project folders is : mrdoorbeen manage.py mr_doorbeen setting.py mrdoorbeen migrations templates index.html profile profile.html I want to include a image in my profile.html file. i use {% load staticfiles %} in top of the profile.html and use this code at image source : <img src="{% static "image/example.jpg" %}" alt="cant'load"/> and i make a folder in a mr_doorbeen and call it static and in static folder make a image folder and image i put a example.jpg but it doesn't work . my static folder path is wrong or what? where should i put my static folder in this project For the given

How to make a Template extend another one?

夙愿已清 提交于 2019-12-07 13:43:04
问题 I've got some templates which I'm building from some data I've got stored in my DB: my_template = Template(string_data) Now I want that template to extend another one (also stored as text in the DB). How can I do that? Looking for something like: my_template.base = other_template Or whatever the syntax is. Can't find documentation on this. I see template.nodelist in the source; can I maybe prepend some kind of extends node? Added a bounty... will grant to first person who can tell me how to

How to remove spaces and empty lines from HTML in Django?

大兔子大兔子 提交于 2019-12-07 12:56:42
问题 I use Python 3.4 + Django 1.7.1 with Eclipse - PyDev and I use AcroEdit to edit HTML. I think AcroEdit uses two soft spaces for indent. I made a custom template tag named custom_tag in custom_tag_library.py like: # -*- coding: utf-8 -*- from django import template from _ast import Num register = template.Library() @register.inclusion_tag('custom_tag.html') def custom_tag(content): return {'content': content, 'children': content.children.all()} and for custom_tag.html : {% load custom_tag

Using regular expression in Django templates

怎甘沉沦 提交于 2019-12-07 12:12:46
问题 I wonder if it is possible using regular expression in Django templates: <a href="#{{form.deal_template_name.value}} ????" data-toggle="tab">{{form.deal_template_name.value}}</a> I would like to replace both spaces and dot's with _. (Otherwise the link would have trouble with the target) {{form.deal_template_name.value}} .replace(/ /g,"_").replace(/\./g,"_") How to do that though in template directly, is that possible? 回答1: If you really want to shoot yourself in the foot: Custom django