Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I recently updated pycharm and now having trouble with django-heroku
I'm getting this error message when I attempt to run the server: "/Users/brandonstockwell/Dropbox_Gmail/Dropbox/mindbrain/mindbrain/settings.py", line 15, in import django_heroku ModuleNotFoundError: No module named 'django_heroku' Process finished with exit code 1 Same thing happens with rollbar. Everything worked fine before I updated. -
How to make AJAX post request in Django
I want to post comment using ajax in Django. I have Message Class related to Post class, and I using PostDetailView to show content of the post and coments. I succeeded to show posted comment on the console. I'm getting error jquery.js:9664 POST http://127.0.0.1:8000/post/39 403 (Forbidden) this is my code views.py class PostDetailView(DetailView): model = Post def post(self,request,*args,**kwargs): if request.method == 'POST': postid = request.POST.get('postid') comment = request.POS.get('comment') # post = Post.objects.get(pk=postid) user = request.user Message.objects.create( user = user, post_id = postid, body = comment ) return JsonResponse({'bool':True}) html(where is corresponds to comment section) {% if request.user.is_authenticated %} <div> <form method="POST" action="" id="form_area"> {% csrf_token %} <input class="form-control mr-sm-2 comment-text" type="text" name="body" placeholder="Write Your message here..." /> <button class="btn btn-outline-success my-2 my-sm-0 save-comment" type="submit" data-post="{{object.id}}" data-url="{% url 'post-detail' object.id %}" > Comment </button> </form> </div> {% else %} script.js function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != "") { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == name + "=") { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } var csrftoken = getCookie("csrftoken"); function csrfSafeMethod(method) { … -
View decorator @verified_email_required takes user back to original view instead of to the clicked view after verifying email, django-allauth
When a user with an unverified email clicks a link in their profile page to go to a new page ServiceSignupView, they are redirected to verify their email first. Once verified they are redirected again back to the profile view instead of the intended view: @verified_email_required def ServiceSignupView(request): return render(request, 'service_signup.html', {}) My settings.py has the login redirect view set to the profile view, except this is not login redirect, this is verifying the email and clicking the link in the email. LOGIN_REDIRECT_URL = 'profile' How can I get the view to proceed to the ServiceSignupView instead of back to the profile view after clicking the verification link in the django-allauth email? -
prevent django test runner from creating stale table
I have mariadb database that used to have CHARSET utf8 COLLATE utf8_general_ci config but now CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci. All tables have the same CHARSET and COLLATE as those of the database. When I run ./manage.py test, stacktrace looks like this: .... django.db.utils.OperationalError: (1118, 'Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.') I managed to find out what the troubling table is, and the sql query looks like the following. Note that I changed names of table and fields for security: CREATE TABLE `troubling_table` ( `id` INTEGER auto_increment NOT NULL PRIMARY KEY, `no_tax` VARCHAR(20) NOT NULL, `cd_pc` VARCHAR(7) NOT NULL, `cd_wdept` VARCHAR(12) NOT NULL, `id_write` VARCHAR(20) NULL, `cd_docu` VARCHAR(10) NULL, `dt_acct` VARCHAR(8) NULL, `st_docu` VARCHAR(3) NULL, `tp_drcr` VARCHAR(3) NULL, `cd_acct` VARCHAR(20) NULL, `amt` NUMERIC(19, 4) NULL, `cd_partner` VARCHAR(20) NULL, `nm_partner` VARCHAR(50) NULL, `tp_job` VARCHAR(40) NULL, `cls_job` VARCHAR(40) NULL, `ads_hd` VARCHAR(400) NULL, `nm_ceo` VARCHAR(40) NULL, `dt_start` VARCHAR(8) NULL, `dt_end` VARCHAR(8) NULL, `am_taxstd` NUMERIC(19, 4) NULL, `am_addtax` NUMERIC(19, 4) NULL, `tp_tax` VARCHAR(10) NULL, `no_company` VARCHAR(20) NULL, `dts_insert` VARCHAR(20) NULL, `id_insert` VARCHAR(20) NULL, `dts_update` VARCHAR(20) NULL, `id_update` VARCHAR(20) NULL, `nm_note` VARCHAR(100) NULL, `cd_bizarea` VARCHAR(12) … -
How to gettext from django.contrib.auth
I am working on translate my Django app, But there are some messages text don't appear in django.po like: This password is too common. A user with that username already exists. The password is too similar to the email address. and they from django.contrib.auth i did run django-admin makemessages -l ** Any idea how to fix this? -
Google OAuth2 integration with kiwi tcms
I have followed exact steps on the documentation provided to integrate google OAuth2. From Kiwi github page. social-auth-app-django - extra authentication backends Google sign-in details. https://python-social-auth.readthedocs.io/en/latest/backends/google.html#google-sign-in I have included relevant settings in /tcms/settings/common.py AUTHENTICATION_BACKENDS = [ "django.contrib.auth.backends.ModelBackend", "guardian.backends.ObjectPermissionBackend", "social_core.backends.google.GooglePlusAuth", ] SOCIAL_AUTH_GOOGLE_PLUS_KEY = "XXXXXXX-XXXXXXXX.apps.googleusercontent.com" SOCIAL_AUTH_GOOGLE_PLUS_SECRET = "XXXXXXXXXXXXXXXXXXXXX" With above configuration, i am able to runserver and get to localhost page. The UI page doesn't contain expected way of sign in via SSO. Am i missing something? How to get the changes in the kiwi tcms UI like https://public.tenant.kiwitcms.org/accounts/login/?next=/ Or Continue With Google section of sign in. -
creating dinamic link in views according to urls.py
I want to create a dinamic link in my view according to path in urls.py urls.py path('link_path/', views.link_view, name="link") this is how it works in a template in any.html <a href="{% url 'link' %}"> this link</a> how can i create dinamic link in views.py which will lead to my path in urls.py? def link_view(request): link = ??? print(link) i want link variable output be like this 127.0.0.1:8000/link_path -
Using mock to create a 'request' attribute for testing a class method in Django
I am new to testing and need help testing a method in Django. I have tried using Client() and RequestFactory(), but because of the method's reliance on other methods, I feel that it is easier to test the method in isolation. Here is the test: class EmailVerificationViewTest(TestCase): def setUp(self): User = get_user_model() self.view = EmailVerificationCode() self.view.time_diff = Mock(return_value=False) self.view.user_code = '0000000000' self.view.code = '0000000000' def test_library(self): self.view.check_code() The problem is that I keep getting an error whenever self.request is called: user_record = User.objects.get(pk=self.request.user.pk) AttributeError: 'EmailVerificationCode' object has no attribute 'request' OR (depending whether time_diff is set to True or False) messages.info(self.request, AttributeError: 'EmailVerificationCode' object has no attribute 'request' The class and method to be tested: (login is required through the OTPRequiredMixin) class EmailVerificationCode(OTPRequiredMixin, FormView): def check_code(self): try: if self.time_diff(): if str(self.user_code) == str(self.code): user_record = User.objects.get(pk=self.request.user.pk) user_record.is_user_verified = True user_record.save() messages.success(self.request, _('Your email has been verified - thank you' )) return redirect(reverse('account:user_profile')) else: messages.error(self.request, mark_safe(_( 'Sorry, but your code did not match.' ))) return redirect(reverse('account:verify_email_code')) else: messages.info(self.request, mark_safe(_('Sorry, but your code has expired.<br>' ))) return redirect(reverse('account:verify_email')) except (AttributeError, ObjectDoesNotExist): messages.warning(self.request, mark_safe(_('We are very sorry, but something went wrong. 'Please try to login again' ))) return redirect(reverse('two_factor:login')) My question is, how … -
Request.get blocked coming from Atom only
I am writing a django app with communcitaion to external python scripts in other software. As I am currently checking all basi requirements and their functionality, I am working with the standard django sql lite testserver. While testing, I am facing a weird firewall/ site blocking issue. A simple request.get() is working fine from windows cmd, receiving my json response. Opening the page in any browser from any computer within my company network works as well. However, when simply launching the request from atom on the local host pc, it fails with 403 - response.content.decode() showing the site is receiving a prompt due to being uncategorized and I would have to click to "continue browsing for work related purposes". As this is only happening from within atom - any ideas how to prevent this? What I tried so far: Adding headers (not change) launching a subprocess calling cmd with the command (works, but sort of failing the purpose of the script) Goal is to simply retrieve a json response from a view so I can transfer the information to my program. Thanks a lot Thomas -
create auto increment integer field in django
i want to create auto increment integer field. I want to create an ID for each user. I am a beginner and please explain completely and clearly :) I want to automatically assign an ID to each user. my Model: from django.db import models class User_account(models.Model): email = models.EmailField() fullname = models.CharField(max_length=30) username = models.CharField(max_length=20) password = models.CharField(max_length=30) marital_status = models.BooleanField(default=False) bio = models.CharField(default='' ,max_length=200) def __str__(self): return f"(@{self.username}) {self.fullname}" def save(self, *args, **kwargs): self.username = self.username.lower() self.email = self.email.lower() return super(User_account, self).save(*args, **kwargs) my View: from django.shortcuts import render from .models import User_account def profile(request, username): users = User_account.objects.all() for user in users: if username == user.username: return render(request, 'account_app/profile.html', context={"user_info":user}) def users_list(request): users = User_account.objects.all() return render(request, 'account_app/users_list.html', context={"user_info":users}) -
Not able to load images from static folder in django
I a not able to load image from static dir in Django. Below is the picture of my file structure. In settings.py S STATIC_URL = '/static/' STATICFILES_DIR = [ os.path.join(BASE_DIR,'static') When I try to load the image file from STATIC_URL, it is producing this error: it is just not loading images but the text from my home-view.html is loading file thus django is not able to locate the image files. Could you please advise why are images not loading? My complete settings.py file : """ Django settings for myproject project. Generated by 'django-admin startproject' using Django 4.0.4. For more information on this file, see https://docs.djangoproject.com/en/4.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent print("Path is : ", os.path.join(BASE_DIR, 'myproject/template')) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-(ep(j)h+$(zro2!9r3bm0fj^!84-1c9d+)$be4hgrq4_#6d^r-' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myproject' ] MIDDLEWARE … -
How to get a relation from a relation in a serializer?
I have 3 models: class Artist(Timestamps): name = models.CharField('Name', max_length=255, blank=True) ... class Festival(Timestamps): name = models.CharField(max_length=255, blank=True) ... class Event(Timestamps): artist = models.ForeignKey(Artist, on_delete=models.CASCADE, null=True) festival = models.ForeignKey(Festival, on_delete=models.CASCADE, null=True) Now I wan't all the id's from the festivals an artist is playing. I have a serializer like this: class ArtistFestivalSerializer(serializers.ModelSerializer): class Meta: model = Artist fields = ('id', 'name', 'event_set') But this only gives me the id's of the event. Any ideas how to get trough the Event to the Festival? Thanks in advance -
Django : Inheritance error- TemplateSyntaxError at / “Could not pass the remainder”
I have a website running using Django that uses the following dgango blocktag to render text within a base.html file. {% block content %} <h1>Welcome </h1> <p1> This is the site template </p1> {% endblock content %} However, to describe a page content and not the site itself, I have the following page.html which is meant to inherit the code from base.html {% extends “base.html” %} {% block content %} <h1>Greetings</h1> <p>The_page_template</p> {% endblock content %} Changing views.py from render base.html to render page.html as follows causes the error. from django.shortcuts import render def index(request): #return render(request, "base.html") // this works return render(request, 'pages/page.html') // this does not The uploaded image is a screenshot of the broken webpage. The best explanation I can offer is that there is an error in the spacing of the code or the pathing to page.html. With pathing I do notice the broken webpage does point to page.html. The following is a relevant statement from settings.py ‘DIRS’: [BASE_DIR / ‘site/templates’] 'APP_DIRS' : TRUE For the sake of completeness, the following paths are described. root/site/templates/base.html root/pages/templates/pages/page.html root/pages/views.py root/site/settings.py Any help appreciated in resolving this error - thanks -
I am new to Django and I can't understand a few errors related to os.environ.setdefault
I found a GitHub repo for reference and practice but when I'm trying to run it on my system it is giving me this error: Traceback (most recent call last): File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\homiechat\manage.py", line 22, in main() File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\homiechat\manage.py", line 9, in main os.environ.setdefault('DJANGO_SETTINGS_MODULE', config('LOCAL_SETTINGS_MODULE')) File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\env\lib\site-packages\decouple.py", line 199, in call return self.config(*args, **kwargs) File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\env\lib\site-packages\decouple.py", line 83, in call return self.get(*args, **kwargs) File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\env\lib\site-packages\decouple.py", line 68, in get raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option)) decouple.UndefinedValueError: LOCAL_SETTINGS_MODULE not found. Declare it as envvar or define a default value. I can't understand what this error means. I installed the requirements.txt but it's the same. On searching the project for LOCAL_SETTINGS_MODULE, I found: os.environ.setdefault('DJANGO_SETTINGS_MODULE', config('LOCAL_SETTINGS_MODULE')) in settings.py, asgi.py, and wsgi.py. I need to understand what this LOCAL_SETTINGS_MODULE is and how to fix this error. -
NGINX slow static file serving
I have a web service served by nginx. I'm using protected routes and nginx X-Accel header from my web server. However these files served slowly compared to other services on the same server. For example downloading media files is around 1MB/s. Server usual upload link is around 400-500Mbps. This is the relevant nginx configuration: server { listen 80; # Set correct charset charset utf-8; sendfile on; sendfile_max_chunk 0; proxy_max_temp_file_size 0; tcp_nopush on; tcp_nodelay on; keepalive_timeout 5; types_hash_max_size 2048; server_tokens off; client_body_buffer_size 1k; client_header_buffer_size 1k; client_max_body_size 4M; large_client_header_buffers 2 1k; client_body_timeout 10; client_header_timeout 10; send_timeout 10; location /protected/media/ { internal; alias /media/; try_files $uri $uri/ =404; } } This nginx instance is running in Docker, files are mapped as volumes for this container. Eg.: the /media/ folder is mapped as a volume from host. The host folder is a local folder, so it is not a mounted network folder. -
TypeError: super(type, obj): obj must be an instance or subtype of type in Django
I have two forms-- userthesisForm and thesisForm-- that have the same model to save on. Basically, the thesisform is for the Admin and the userthesisForm is for the student (normal user). I do not encounter any problem with the Admin saving the thesisForm, but i do get this error TypeError: super(type, obj): obj must be an instance or subtype of type in my def submit_thesis for student submitting the userthesisForm. How do I resolve it? Thanks in advance This my code for saving the thesisForm in views.py: def add(request): if request.method == "POST": form = thesisForm(request.POST, request.FILES) if form.is_valid(): obj = form.save(commit=False) obj.uploader = request.user; obj.save() messages.success(request, "Project created successfully!" ) return redirect('/manage') else: form = thesisForm() return render(request,'Add.html',{'form':form}, ) This is for saving the userthesisForm: def submit_thesis(request): if request.user.is_superuser: return redirect('/manage') else: if request.method == "POST": form = thesisForm(request.POST, request.FILES) if form.is_valid(): obj = form.save(commit=False) obj.uploader = request.user; obj.status = 'Pending'; obj.save() messages.success(request, "Project submitted successfully!" ) return redirect('/myrepository') else: form = thesisForm() return render(request,'submit_thesis.html',{'form':form}, ) And the userthesisForm the student will fill up class userthesisForm(forms.ModelForm): class Meta: model = thesisDB fields = ('title', 'author', 'published_date','tags','short_description', 'pdf', 'image_banner', 'status') readonly_fields = ['course', 'shell_location', 'date_created'] widgets = { 'title': forms.TextInput(attrs= … -
another -> django.db.utils.OperationalError: (1709, 'Index column size too large. The maximum column size is 767 bytes')
I have the following problem, but first my development environment: ubuntu 18.04 python 3.7.4 mariadb 10.7.4 django 3.2.13 Attempt to configure django-allauth 0.50.0 I follow the steps of the official website and everything is ok, but, when it comes time for python manage.py makemigrations all right, but when I give python manage.py migrate I got this error: django.db.utils.OperationalError: (1709, 'Index column size too large. The maximum column size is 767 bytes') I already try all kinds of solutions that I found here, Like This , but all relate about mariadb 10.1 and 10.2, where it is assumed that in this last version the problem should be solved, but here I have it. pd: excuse my english -
data from database is not showing in html template in django
I fetched data from books table in views.py and passed to show.html as dictionary.It is not showing.also i wanted to check if there is key passed in html..so purposely wrote paragraph after {%if key1 %} ,it is not showing that paragraph also.what will be the reason or my fault? here is my code snippet views.py def show(request): books = Books.objects.all() return render(request,'app/show.html',{'key1':books}) urls.py from django.urls import path from . import views urlpatterns = [path("",views.index,name = 'home'), path('show/',views.show,name= 'show'), ] models.py class Books(models.Model): book_num = models.IntegerField() auth_name = models.CharField(max_length = 50) book_name = models.CharField(max_length = 100) def __str__(self): return self.auth_name show.html <center> <table> <tbody> <th>Available books</th> {%if key1%} <P>please check if issued</p> {% for i in key1 %} <tr> <td>Author name:{{i.auth_name}}</td> <td>Book title:{{i.book_name}}</td> </tr> {% endfor %} {% endif %} </tbody> </table> </center> -
django login / register auth safe?
I knew that django already has the auth system . However, I heard that either session and token are needed for security. should I build login, logout, registeration with session or token in view? or is it included in django's auth? -
How can I fix my code For Django's reply comment
When entering a reply comment, It will be redirected to my post with comments How can I fix it? Please Someone help me post_detail.html <!-- Reply Button Area --> <button class="btn btn-sm btn-secondary" type="button" style="float:right" data-toggle="collapse" data-target="#replyBox{{comment.id}}" aria-expanded="false" aria-controls="replyBox{{comment.id}}"> Reply </button> <div class="collapse" id="replyBox{{comment.id}}"> <div class="card card-body my-2"> <form action="/blog/{{ comment.pk }}/reply_comment/" method="post"> {% csrf_token %} <div class="form-group"> <label for="comment">Reply </label> <input type="text" class="form-control" name="comment" placeholder="type the comment"> <input type="hidden" name="parentSno" value="{{comment.id}}"> </div> <input type="hidden" name="post.pk" value="{{post.pk}}"> <button type="submit" class="btn btn-sm btn-primary">Complete</button> </form> </div> </div> <!-- Reply Button Area END --> Views.py def reply_comment(request , comment_pk) : if request.user.is_authenticated : comment = get_object_or_404(Comment , pk=comment_pk) if request.method == 'POST' : recomment_form = ReCommentForm(request.POST) if recomment_form.is_valid() : recomment = recomment_form.save(commit=False) recomment.author = request.user recomment.comment = comment recomment.save() return redirect(comment.get_absolute_url()) return redirect(comment.post.get_absolute_url()) else : raise PermissionError -
django model data returns none in html but shows in admin panel
ive created a model that lets users create a simple post however when the data is submitted it registers in the admin panel but will not display in the html. I can edit in admin and the images even up in the folder unfortunately I cannot find out what the issue is models.py from distutils.command.upload import upload from django.db import models from django.forms import CharField, ImageField from django.forms.fields import DateTimeField from matplotlib import image from sqlalchemy import true from django.contrib import admin # Create your models here. class Posts(models.Model): image = models.ImageField(upload_to='images/') quote = models.TextField(null=True) date = models.DateTimeField(auto_now_add=True, null=True) views.py from django.contrib.auth import login, authenticate from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from django.shortcuts import render, redirect from requests import request from users.forms import SignUpForm from matplotlib.style import context from django.http import HttpRequest, HttpResponse from .models import Posts def signup(request): if request.method == 'POST': form = SignUpForm(request.POST)# was UserCreationForm if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('profile') #profile else: form = SignUpForm() #was UserCreationForm return render(request, 'signup.html', {'form': form}) def posts(request): userpost = Posts.objects.all() return render(request, 'posts.html', {'userpost': Posts} ) urls.py from django.urls import path from … -
Join django tables
I need to connect the Alumno table with the Horario, how could I do the syntax? I need to get the id_curso of each Alumno, and with that id_curso join it to the Horario table but I don't know how to do it I think you have to use select_related or prefetch_related, which I don't know very well how to use, I tried to create a variable to get the id_course and with that variable use filter but I didn't take it Helpme please models.py class Alumno(models.Model): rut_alumno = models.IntegerField(primary_key=True) dv_alumno = models.CharField(max_length=1) p_nombre = models.CharField(max_length=15) s_nombre = models.CharField(max_length=15, blank=True, null=True) ap_paterno = models.CharField(max_length=15) ap_materno = models.CharField(max_length=15, blank=True, null=True) fecha_nac = models.DateField() genero = models.CharField(max_length=1) direccion = models.CharField(max_length=25, blank=True, null=True) nivel_socio = models.CharField(max_length=10) id_examenes = models.OneToOneField('ExamenCono', models.DO_NOTHING, db_column='id_examenes') rut_apoderado = models.ForeignKey('Apoderado', models.DO_NOTHING, db_column='rut_apoderado') id_colegio = models.ForeignKey('Colegio', models.DO_NOTHING, db_column='id_colegio') id_curso = models.ForeignKey('Curso', models.DO_NOTHING, db_column='id_curso') id_comuna = models.ForeignKey('Comuna', models.DO_NOTHING, db_column='id_comuna') class Meta: managed = True db_table = 'alumno' class Curso(models.Model): id_curso = models.IntegerField(primary_key=True) grado = models.CharField(max_length=1) educacion = models.CharField(max_length=10) letra = models.CharField(max_length=1) id_colegio = models.ForeignKey(Colegio, models.DO_NOTHING, db_column='id_colegio') rut_profesor = models.OneToOneField('Profesor', models.DO_NOTHING, db_column='rut_profesor') class Meta: managed = True db_table = 'curso' class Horario(models.Model): id_horario = models.IntegerField(primary_key=True) dia = models.CharField(max_length=10) hora_inicio = models.CharField(max_length=5) hora_termino … -
insert ₹ in python Django mysql. i'm using frontend react and backend Python
Hi There when i was entering ₹ in a textfield i'm getting django.db.utils.OperationalError: (1366, "Incorrect string value: '\\xE2\\x82\\xB9' for column 'sk_ver_reason' at row 1") this textfield is a description box, mysql acception other countries curreny sign but not in indian currency, i have chages much collation from utf8mb... when i hit api this sign failed, but the entry for this api enter in db, same i hit again it run succefully, is it python django error or purely mysql db error. in below image you can see collation of that perticualr field. -
ApplicationOAuth using PyGithub in Django
I am building Github App. I have tried to access repository from Github by using Access tokens, It will work fine Here is the Code username = "user" reponame = "test" g = Github("my_access_token") repo = g.get_repo(username + "/" + reponame) files = repo.get_contents("") But now I want to access the repository by using Application authorizing, for this I am using PyGithub library. Here is the link which demonstrate what i am trying to do exactly. (Must read this..Please) and This is the PyGitHub Docs to achieve above functionality. I am not Getting how to implement this exactly. -
Batch Complete Tasks in DRF
I have my Django website where i can have tasks created and subtasks under tasks i have mark complete option which is working fine i need them to be completed in batch like selecting multiple tasks at once and complete them. serializers.py: class TaskCompleteSerializer(serializers.ModelSerializer): class Meta: model = Task fields = ( 'is_done', ) def update(self, instance, validated_data): person = self.context['request'].user.person task_is_done = validated_data.get('is_done', False) if task_is_done: instance.subtasks.update(is_done=True) instance.is_done = task_is_done instance.done_by.set([person]) instance.save() return instance models.py: class TaskUpdateAPIView(UpdateAPIView): permission_classes = " " serializer_class = TaskCompleteSerializer queryset = Task.objects.all() model = Task lookup_url_kwarg = 'task_id'