django-views

Django: ValueError at/ “The view To_do_list_app.views.home didn't return an HttpResponse object. It returned None instead.”

蹲街弑〆低调 提交于 2020-02-23 07:40:10
问题 Please, I am a newbie, if I didn't ask my question well, let me know. I am working on a To-Do List app. Anytime, I add a new task and time to the form on my web app and submit, I get the following error: ValueError at / The view To_do_list_app.views.home didn't return an HttpResponse object. It returned None instead. Below is my views.py file from django.http import HttpResponse from django.shortcuts import render,redirect from .forms import ListForm from .models import List def home(request)

How do I create list and detail views for django-taggit?

吃可爱长大的小学妹 提交于 2020-02-17 15:02:43
问题 I have a fairly simple model that uses Django Taggit for tagging. Everything works great, but now I'd like to expand some functionality and I'm a little confused. What I want is two views. One that shows all my tags in the system. One that shows all the content from my app with a specific tag. What makes sense to me is to do the following for each view. in views.py for myapp All Tags from myapp.models import App from taggit.models import Tag class TagList(ListView): """ Get all the tags in

'module' object has no attribute 'now' will trying to create a CSV

这一生的挚爱 提交于 2020-02-17 05:59:43
问题 Hello I'm having problems importing to csv, I get that error, the problem is that I have the same code running in other machine and it runs perfectly. What am I missing do I need to install an other library for this?. def exportar_a_csv_grl(request): #Fecha actual hoy = datetime.now().date() #Creado el: creado_hoy = hoy.strftime("%m/%d/%Y") response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment;filename="Reporte de Miembros ' + creado_hoy + '.csv"' response

Revert objects on site instead of admin using django simple history

谁都会走 提交于 2020-02-06 12:51:30
问题 I have employed django simple history package on the admin site to be able to track and revert to previous versions of the object of the model. I am designing a web form that allows users to change instances of the model object using model form on django and would like to allow the users to view and revert to previous versions. Also to allow them to see what are the changes compared to the current version. With the code below I am able to get the list of historical records on my template

Revert objects on site instead of admin using django simple history

我的未来我决定 提交于 2020-02-06 12:50:00
问题 I have employed django simple history package on the admin site to be able to track and revert to previous versions of the object of the model. I am designing a web form that allows users to change instances of the model object using model form on django and would like to allow the users to view and revert to previous versions. Also to allow them to see what are the changes compared to the current version. With the code below I am able to get the list of historical records on my template

Ajax call not updating template django

让人想犯罪 __ 提交于 2020-02-06 10:05:20
问题 Below are the details. I am able to get updated "questions_in_topic" variable in views when select option is changed i.e. ajax call is made. Ajax call is updating the "questions_in_topic" variable based on selected value in dropdown. But these changes are not reflected in template. i.e. on template, I still get old values. urls.py url(r'^interview/add/questions/library', recruiter_views.add_question_library, name='add_question_library'), views.py def add_question_library(request): question

Ajax call not updating template django

天涯浪子 提交于 2020-02-06 10:04:07
问题 Below are the details. I am able to get updated "questions_in_topic" variable in views when select option is changed i.e. ajax call is made. Ajax call is updating the "questions_in_topic" variable based on selected value in dropdown. But these changes are not reflected in template. i.e. on template, I still get old values. urls.py url(r'^interview/add/questions/library', recruiter_views.add_question_library, name='add_question_library'), views.py def add_question_library(request): question

Django--URL Caching Failing for Class Based Views

孤者浪人 提交于 2020-02-05 21:30:13
问题 I've built a RESTful API on top of the Django Rest Framework. The URL conf for the API is composed of class based views. I would like to cache these views, however, the following is failing. Any thoughts on why that might be and how I could change it? from django.views.decorators.cache import cache_page urlpatterns = patterns('', url(r'^dounces/?$', cache_page(60*60)(DounceListView.as_view(resource=DounceResource)), name='dounces_api'), I have the following middleware installed. 'django

How to pass Django request object in user_passes_test decorator callable function

橙三吉。 提交于 2020-01-29 03:35:31
问题 I am using Django user_passes_test decorator to check the User Permission. @user_passes_test(lambda u: has_add_permission(u, "project")) def create_project(request): ...... I am calling a callback function has_add_permission which takes two arguments User and a String. I would like to pass the request object along with it is that possible? Also, can anyone please tell me how are we able to access the User object inside the decorator directly. 回答1: No, you cannot pass request to user_passes

How to validate the registered users with login in django?

喜你入骨 提交于 2020-01-26 04:49:12
问题 Here I am using a non custom user model for saving the users registered and their details are stored in user_requirement model now I want to validate before logging in to the dashboard My models.py: class user(models.Model): username=models.CharField(max_length=20) email=models.CharField(max_length=50,unique=True) password=models.CharField(max_length=50,default='0000000') created_at = models.DateTimeField(default=datetime.now) updated_at = models.DateTimeField(default=datetime.now) def __str_