django-templates

Using forloop.counter value as list index in a Django template

自作多情 提交于 2020-12-29 05:14:28
问题 in my Django 1.1.1 application I've got a function in the view that returns to his template a range of numbers and a list of lists of items, for example: ... data=[[item1 , item2, item3], [item4, item5, item6], [item7, item8, item9]] return render_to_response('page.html', {'data':data, 'cycle':range(0,len(data)-1]) Inside the template I've got an external for loop, that contains also another for cycle to display in output the contains of the inner lists of data in this way ... {% for page in

Using forloop.counter value as list index in a Django template

五迷三道 提交于 2020-12-29 05:14:20
问题 in my Django 1.1.1 application I've got a function in the view that returns to his template a range of numbers and a list of lists of items, for example: ... data=[[item1 , item2, item3], [item4, item5, item6], [item7, item8, item9]] return render_to_response('page.html', {'data':data, 'cycle':range(0,len(data)-1]) Inside the template I've got an external for loop, that contains also another for cycle to display in output the contains of the inner lists of data in this way ... {% for page in

Using forloop.counter value as list index in a Django template

╄→гoц情女王★ 提交于 2020-12-29 05:14:00
问题 in my Django 1.1.1 application I've got a function in the view that returns to his template a range of numbers and a list of lists of items, for example: ... data=[[item1 , item2, item3], [item4, item5, item6], [item7, item8, item9]] return render_to_response('page.html', {'data':data, 'cycle':range(0,len(data)-1]) Inside the template I've got an external for loop, that contains also another for cycle to display in output the contains of the inner lists of data in this way ... {% for page in

Using forloop.counter value as list index in a Django template

坚强是说给别人听的谎言 提交于 2020-12-29 05:13:57
问题 in my Django 1.1.1 application I've got a function in the view that returns to his template a range of numbers and a list of lists of items, for example: ... data=[[item1 , item2, item3], [item4, item5, item6], [item7, item8, item9]] return render_to_response('page.html', {'data':data, 'cycle':range(0,len(data)-1]) Inside the template I've got an external for loop, that contains also another for cycle to display in output the contains of the inner lists of data in this way ... {% for page in

Django/Js: how to post a form without reloading whole page

别等时光非礼了梦想. 提交于 2020-12-26 04:57:28
问题 My application currently flows through 3 pages: User selects question in index page User submits answer in answer page User is presented with result in results page. I want to compress that down to a single page where the user submits an answer to the question and result is shown on the same page. The following django-template code separates questions with Bootstrap accordion. How do I post the form without refreshing the whole page? I want to be able to display the result on the page, update

How to correctly use Django reverse FK lookup to show instances of the child model in CBV

ぃ、小莉子 提交于 2020-12-15 07:02:12
问题 I have two models, field of one of them pointing to the other as shown below: class Group(models.Model): group_company_id = models.CharField(primary_key=True, ...) class Company(models.Model): company_id = models.CharField(primary_key=True, ...) group_company = models.ForeignKey(Group, related_name="related_grp_company", ...) I am trying to get all the Companies that have been created for a particular Group . So I am trying to get the company_id (and other) values in Djnago UpdateView as a

data doesn't appear in my html page when i add new record - Django

旧街凉风 提交于 2020-12-15 06:26:13
问题 when i add new record from admin panel it should appear in html page , but it doesn't do that how to fix it models.py : class BestArticals(models.Model): name = models.CharField(max_length=240) url = models.URLField(default="",max_length=240) image = models.ImageField(upload_to='images/',null=True, blank=True) def get_image(self): if self.image and hasattr(self.image, 'url'): return self.image.url else: return '/path/to/default/image' def __str__(self): return self.name views.py : from

Dropdown select option to filter a Django list

…衆ロ難τιáo~ 提交于 2020-12-12 01:47:27
问题 Coming from Angular, this was easy to do, but I am not sure where to begin on creating a dropdown form that will filter from a list of objects. Basically, I have the code below, that will pull in and display all real estate listings; I would like to create a dropdown that will have 2 selections, 'Featured' and 'New Listing' and when a user selects one, the list will filter out and display only those listings that match. Thank you for your help. Here is my model from django.db import models

Dropdown select option to filter a Django list

我的未来我决定 提交于 2020-12-12 01:47:09
问题 Coming from Angular, this was easy to do, but I am not sure where to begin on creating a dropdown form that will filter from a list of objects. Basically, I have the code below, that will pull in and display all real estate listings; I would like to create a dropdown that will have 2 selections, 'Featured' and 'New Listing' and when a user selects one, the list will filter out and display only those listings that match. Thank you for your help. Here is my model from django.db import models

Django - download file from FileField()

人走茶凉 提交于 2020-12-06 16:52:57
问题 I'm struggling with the following problem. I have a database model with FileField() . models.py class InputSignal(models.Model): input_file = models.FileField(upload_to='signals/', null=False, ) A view that displays records from this table. It also supports deleting specific rows. views.py def storage_list(request): signals = InputSignal.objects.filter(author=request.user) if request.method == 'DELETE': id = json.loads(request.body)['id'] signal = get_object_or_404(InputSignal, id=id) signal