django-templates

Django Template not displaying model data

ぐ巨炮叔叔 提交于 2020-01-05 07:41:26
问题 I've looked through different tutorials and Stack Overflow questions and I'm not sure why I'm still running into this issue: I am running into an issue with displaying my model data onto my template, I can see that the python code is executing, but no matter what I've tried I can't get my data to come through, my relevant code snippets are below: models.py class GoogleData(models.Model): placeID = models.CharField(max_length=999) name = models.CharField(max_length=200) phoneNumber = models

Django Template not displaying model data

柔情痞子 提交于 2020-01-05 07:41:09
问题 I've looked through different tutorials and Stack Overflow questions and I'm not sure why I'm still running into this issue: I am running into an issue with displaying my model data onto my template, I can see that the python code is executing, but no matter what I've tried I can't get my data to come through, my relevant code snippets are below: models.py class GoogleData(models.Model): placeID = models.CharField(max_length=999) name = models.CharField(max_length=200) phoneNumber = models

Django - using different apps together in a project

怎甘沉沦 提交于 2020-01-05 06:52:16
问题 In the basic Django tutorials and documentations I have found so far, apps are treated as some standalone parts of the project. I haven't yet found, though, solutions of using them together in a complex project. We can sign up at some url domain/signup , and it is handled by users.views.signup . For a GET request signup renders signup.html . For a POST request, after evaluating the posted data, it either renders signup.html with some message or registers a new user, logs him/her in and

What's the correct way to print a matrix with labels in a Django template?

[亡魂溺海] 提交于 2020-01-05 04:35:10
问题 I want to do something very simple in Django: Print a matrix as an HTML table, and add labels for the rows and columns. These are the variables in my view: matrix = np.array([ [101, 102, 103], [201, 202, 203], ]) colnames = ['Foo', 'Bar', 'Barf'] rownames = ['Spam', 'Eggs'] I want a to get a table that looks like this: Foo Bar Barf Spam 101 102 103 Eggs 201 202 203 My template code looks like this: <table> <tr> <th></th> {% for colname in colnames %} <th>{{ colname }}</th> {% endfor %} </tr>

Load CSS/images in Django

做~自己de王妃 提交于 2020-01-05 02:31:08
问题 I've read the official Django Docs and many other posts here in SO. Still I'm unable to figure out the way to load my CSS files in HTML pages. I'm running Django 1.4 . Here is my whole structure of mysite project having auth as the app. mysite/ manage.py settings.py __init__.py urls.py auth/ __init__.py forms.py models.py views.py templates/ index.html home.html media/ common.css How can I load my common.css file in index and home template files? 回答1: Take a look at static files : https:/

How to iterate over cms plugin instances from a page in a Django template?

馋奶兔 提交于 2020-01-04 18:32:13
问题 I want to display a list of YouTube videos and let my user edit this list. I thought of doing it like this: Make a template where this will be displayed. In this template do something like <ul>{% for plugin in page %}<li>plugin</li>{% endfor %}</ul> . Make a youtube_videos placeholder and configure it to be limited to only that type of plugin. But I don't know how to make this iteration over the plugin instances in the current page in the template. I didn't see anything about this in django

How to iterate over cms plugin instances from a page in a Django template?

和自甴很熟 提交于 2020-01-04 18:32:08
问题 I want to display a list of YouTube videos and let my user edit this list. I thought of doing it like this: Make a template where this will be displayed. In this template do something like <ul>{% for plugin in page %}<li>plugin</li>{% endfor %}</ul> . Make a youtube_videos placeholder and configure it to be limited to only that type of plugin. But I don't know how to make this iteration over the plugin instances in the current page in the template. I didn't see anything about this in django

Context Rendering in Django

北战南征 提交于 2020-01-04 14:13:29
问题 I am new in django.So while i was practising django template in shell i saw two different output of "render()" .So here it goes. from django.template import Template,Context t = Template("My name is {{name}}.") c = Context("name":"sraban") t.render(c) So while i hit enter in shell it shows u'My name is sraban' But while i wrote from django.template import Template,Context t = Template("My name is {{name}}.") c = Context("name":"sraban") print t.render(c) It's output is My name is sraban So I

Extracting a value from inside a django loop

倾然丶 夕夏残阳落幕 提交于 2020-01-04 14:05:54
问题 I have a django app where i am using the following in the templates: {% load mptt_tags %} <ul> {% recursetree nodes %} <li> {{ node.name }} {% if not node.is_leaf_node %} <ul class="children"> {{ children }} </ul> {% endif %} {% if node.is_leaf_node %} <span ng-bind="progid = {{node.program_id}}"></span> {% endif %} </li> {% endrecursetree %} </ul> The values of the node will be gone once the recursion takes place. I would like to know how to extract a values outside this loop in the template

Can't change Django admin template

北城余情 提交于 2020-01-04 13:47:27
问题 just started an official Django tutorial and already ran into a problem, can't change page name in admin panel. I'm trying to replace a default Django administration with something custom in the base_site.html as suggested in the tutorial (a file which I copied from the django source directory into my app, tried to move it in/out polls directory etc.), I have added in settings TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')] , and in installed apps also 'polls', but nothing changes. Any