django-templates

How to do mapping user input HTML page to view.py in django?

北慕城南 提交于 2020-05-17 09:04:09
问题 I am a newbie in Django and not able to map my user-input to my stored procedure query. views.py from django.db import connection from django.shortcuts import render from .forms import InputForm def home_view(request): print("woooooooooooo",request) context1 ={} context1['form']= InputForm() print("context1::::", context1) return render(request, "input.html", context1) def itemnumber(request): cursor = connection.cursor() try: itemnumber = "23241715" C=cursor.execute(f"EXEC

Django not rendering CSS

不打扰是莪最后的温柔 提交于 2020-05-17 06:22:38
问题 I am new to programming and currently Django will not render my CSS. This is the html request GET http://127.0.0.1:8000/static/blog/main.css net::ERR_ABORTED 404 (Not Found) Here's my current set up and what I know to be required for using static files. I don't understand how my paths are wrong if they are? My current DIR BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] In my settings.py...it is installed. /Users

Django - Render a List of File Names to Template

左心房为你撑大大i 提交于 2020-05-17 04:36:06
问题 I am generating a template for an image gallery page. My approach is as follows: Host the images from a sub directory of an images folder The image folder will be titled the same as the gallery title The view passes a list of filenames to the template The template loops through the list and creates img tags So my view would be def some_gallery(request): #LOGIC TO GET A LIST OF FILENAMES variables = RequestContext(request,{ 'user' : request.user, 'title' : 'something', 'files' : fileList })

Django - Render a List of File Names to Template

谁都会走 提交于 2020-05-17 04:33:29
问题 I am generating a template for an image gallery page. My approach is as follows: Host the images from a sub directory of an images folder The image folder will be titled the same as the gallery title The view passes a list of filenames to the template The template loops through the list and creates img tags So my view would be def some_gallery(request): #LOGIC TO GET A LIST OF FILENAMES variables = RequestContext(request,{ 'user' : request.user, 'title' : 'something', 'files' : fileList })

django include a template into another template

故事扮演 提交于 2020-05-16 03:28:05
问题 I am trying to include a template into another template but the problem I am having now is the embedded templates doesnt display contents rendered on it in the new template I am trying to embed it into. detail.html in profile application {% include "list.html" with instance=user.posts_created.all %} and I have the template in the templates folder. The template is seen but the content does not show up in the detail.html additional codes would be provided on request thanks views.py in posts app

django include a template into another template

狂风中的少年 提交于 2020-05-16 03:27:06
问题 I am trying to include a template into another template but the problem I am having now is the embedded templates doesnt display contents rendered on it in the new template I am trying to embed it into. detail.html in profile application {% include "list.html" with instance=user.posts_created.all %} and I have the template in the templates folder. The template is seen but the content does not show up in the detail.html additional codes would be provided on request thanks views.py in posts app

Display foreign key value in django template

老子叫甜甜 提交于 2020-05-13 18:53:47
问题 I've looked through the similar questions and was unable to find a solution that fits or I'm missing something? I have two models(SafetyCourse and SafetyCourseTaken) I have a foreign key relationship that points from "safety courses taken" to safety course, shown below: models.py class SafetyCourse(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) name = models.CharField(max_length=128, unique=True) def __str__(self): return self.name class

Display foreign key value in django template

老子叫甜甜 提交于 2020-05-13 18:52:37
问题 I've looked through the similar questions and was unable to find a solution that fits or I'm missing something? I have two models(SafetyCourse and SafetyCourseTaken) I have a foreign key relationship that points from "safety courses taken" to safety course, shown below: models.py class SafetyCourse(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) name = models.CharField(max_length=128, unique=True) def __str__(self): return self.name class

Display foreign key value in django template

て烟熏妆下的殇ゞ 提交于 2020-05-13 18:52:25
问题 I've looked through the similar questions and was unable to find a solution that fits or I'm missing something? I have two models(SafetyCourse and SafetyCourseTaken) I have a foreign key relationship that points from "safety courses taken" to safety course, shown below: models.py class SafetyCourse(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) name = models.CharField(max_length=128, unique=True) def __str__(self): return self.name class

TemplateSyntaxError: 'with' expected with atleast one variable assignment

只谈情不闲聊 提交于 2020-05-13 05:53:48
问题 I am trying to send the data of a meeting object from template to view via GET method. To give the attribute meeting.date a simpler alias i.e date I am using the with template tag. But it ends up with a TemplateSyntaxError. urls.py url(r'^meeting/$', meeting_display, name="meeting"), views.py def meeting_display(request): date = request.GET.get('date') ob_mem = memo.objects.get(subject='Meeting', rcv_username=username, date=date) ob_mee = memo.meeting_set.all() variables = RequestContext