Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ValueError: Field 'bid' expected a number but got ' '
I am making an Auction website using Django. When is use Migrate command it gives an error "ValueError: Field 'bid' expected a number but got ''.". The code of the models.py file is: from django.contrib.auth.models import AbstractUser from django.db import models from django.db.models.base import Model from django.db.models.deletion import CASCADE from django.db.models.fields import CharField from django.utils import timezone class User(AbstractUser): pass class Category(models.Model): category = models.CharField(max_length=64) def __str__(self): return f'{self.category}' class AuctionListing(models.Model): item_name = models.CharField(max_length=100) item_image = models.ImageField(upload_to="products", null=True, blank=True) detail = models.TextField() price = models.IntegerField() last_bid = models.ForeignKey('Bid', on_delete=models.CASCADE, blank=True, null=True, related_name='lst') user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='publisher_listing', null=True, blank=True) watchers = models.ManyToManyField(User, blank=True, related_name='watched_list') pub_date = models.DateTimeField(null=True) deadline = models.DateTimeField(null=True) list_category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True, related_name='sortion') closed = models.BooleanField(default=False) def __str__(self): return f'{self.item_name} - {self.price}' class Bid(models.Model): p_bid = models.IntegerField() user = models.ForeignKey(User, on_delete=CASCADE) auction = models.ForeignKey(AuctionListing, on_delete=CASCADE) bid_date = models.DateTimeField(timezone.now) def __str__(self): return '%s' % (self.bid) class Comment(models.Model): user = models.ForeignKey(User, on_delete=CASCADE) com = models.TextField() pub_date = models.DateField() com_item = models.ForeignKey(AuctionListing, on_delete=models.CASCADE, related_name='get_comment') def __str__(self): return f'{self.user} - {self.pub_date}' The code of views.py is: from django.contrib.auth import authenticate, login, logout # from django.contrib.auth.decorators import login_required from django.db import IntegrityError from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render … -
Heroku H12 Request timeout on Django application
I am running a Django application on Heroku. when i make a request longer than 30 seconds, it stopped and the request returns 503 Service Unavailable. These are the heroku logs 2021-10-20T07:11:14.726613+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/ajax/download_yt/" host=yeti-mp3.herokuapp.com request_id=293289be-6484-4f11-a62d-bda6d0819351 fwd="79.3.90.79" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https I tried to do some research on that and i found that i could increase the gunicorn (i am using gunicorn version 20.0.4) timeout in the Procfile. I tried increasing to 60 seconds, but the request still stops after 30. This is my current Procfile: web: gunicorn yetiMP3.wsgi --timeout 60 --log-file - these are the buildpacks i'm using on my heroku app: heroku/python https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git How can i increase the request timeout? Did i miss some heroku configuration? -
Django heroku Programming Error after deployed
My Django site was working perfectly fine locally but after deploying my Django site on Heroku, I got this error. enter image description here This error belongs to the frontend and also I had another error in my admin site. I'm not sure they are related or not.enter image description here I searched on google and some people say I need to run this command and it will be fine. heroku run python manage.py migrate So I run that command and I got no error while running but still doesn't fix the error. But there is something weird. When I'm creating my site on local, I misspelled the word installation_record as installtion_record in my models.py and I migrated it. After a few days, I found my misspelled word and fixed it again in the models.py. And so on I finally push my code on heroku and when I open my heroku website, I got the error that said Programming Error at / column installation_record does not exist at LINE 1:.... Perhaps You means installtion_record . I can't precisely remember the error. I changed the word back to the misspelled word (installtion_record) as the Django suggestion said and it worked. I … -
Django CMS not changing child page slugs after parent slug is changed
I have a problem where the url slug for a section of a website has been changed using the CMS admin interface, and now the children pages which are descended from it still have the old (incorrect) slug in their urls, leading to 404 errors. How can the child page slugs be updated to reflect the new, correct parent page slug? -
postdetail() got an unexpected keyword argument 'post'
I have have error in django/python. I get this error when I enter the post list and try to open the post details: postdetail() got an unexpected keyword argument 'post' when i try views.py codes: from django.shortcuts import render, get_list_or_404 from django.http import HttpResponse from django.urls.base import reverse from django.urls.converters import SlugConverter from .models import post def index(request): tpost = post.objects.all() return HttpResponse("Welcome to the django website") def postlist(request): tpost = post.objects.filter(status = "published") return render(request, "blog/post/list.html", {"posts": tpost}) def postdetail(request, npost, pk): post = get_list_or_404(npost, slug = npost, id = pk) return render(request, "blog/post/detail.html", {"fpost": post}) models.py Codes: from django.contrib import auth from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.urls import reverse class post(models.Model): STATUS_CHOICES = ( ("draft", "Draft"), ("published", "Published"), ) title = models.CharField(max_length = 250) slug = models.SlugField(max_length = 250, unique_for_date = "publish") author = models.ForeignKey(User, on_delete = models.CASCADE, related_name = "blog_post") body = models.TextField() publish = models.DateTimeField(default = timezone.now) created = models.DateTimeField(auto_now_add = True) updated = models.DateTimeField(auto_now = True) status = models.CharField(max_length = 10, choices = STATUS_CHOICES, default = "draft") objects = models.Manager() class Meta: ordering = ("-publish",) def get_absolute_url(self): return reverse("blog:post_detail", args = [self.slug, self.id]) def __str__(self): return self.title … -
Hello. How can I add user automatically in Django when he/she creates new object?
I have simple model where user writes some text and saves it, I need to add current user to this created object. Right now I have such code where user can be chosen manually, how do I make it automatically? I know about user=self.request.user, but I don't know how to use it in Models. Sorry if this question is silly, I'm new to Django class SomeText(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) keyword = models.TextField(verbose_name='Add your text here') -
Why FormView misses ipdb.set_trace() for post request?
I have the following code: urls.py: urlpatterns = [ ... url(r'^upload_file', FileFieldFormView.as_view(), name='upload_file'), url(r'^success', lambda request: HttpResponse('Hello World!'), name='hello_world'), ] upload_file.py: from django.views.generic.edit import FormView from ..forms import FileFieldForm import ipdb def handle_uploaded_file(f): ipdb.set_trace() with open(f.name, 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk) class FileFieldFormView(FormView): form_class = FileFieldForm template_name = 'reports/upload_file.html' # Replace with your template. success_url = '/reports/success' # Replace with your URL or reverse(). def post(self, request, *args, **kwargs): form_class = self.get_form_class() form = self.get_form(form_class) files = request.FILES.getlist('file_field') if form.is_valid(): for f in files: print("hello") handle_uploaded_file(f) return self.form_valid(form) else: print("invalidated") return self.form_invalid(form) forms.py: from django import forms class FileFieldForm(forms.Form): title = forms.CharField(max_length=50) file = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True})) and upload_file.html template: {% extends "core/layout.html" %} {% block content %} <br/> <h3>{{ title }}</h3> <br/> {% block controls %}{% endblock %} <form enctype="multipart/form-data" method="post"> {% csrf_token %} {{ form.as_table }} <button type="submit">Upload</button> </form> {% endblock %} Instead of landing to ipdb.set_trace() in upload_file.py, I get success page. Why does django miss the breakpoint? -
How to add aggregate values in Django Rest Framework ModelViewSets
In my DRF app I have the following model, serializer and view. models.py class Log(models.Model): plant = models.ForeignKey(Plant, on_delete=models.CASCADE) date_time = models.DateTimeField() water_consumption = models.PositiveSmallIntegerField() elec_consumption = models.PositiveSmallIntegerField() serializers.py class ConsumptionSerializer(serializers.ModelSerializer): class Meta: model = Log fields = ("water_consumption", "elec_consumption") views.py class ConsumptionViewSet(viewsets.ModelViewSet): permission_classes = [permissions.IsAuthenticated, ] serializer_class = ConsumptionSerializer def get_queryset(self): # Get params from url start_date = self.request.query_params.get('start_date') end_date = self.request.query_params.get('end_date') # Make sure params are not null if start_date is not None and end_date is not None: queryset = queryset.filter(date_time__range=[start_date, end_date]) return queryset else: raise ValidationError({"ERROR": ["No params found in url"]}) This works and it outputs something like this in JSON: [ { "water_consumption": 1, "electrical_consumption": 1 }, { "water_consumption": 1, "electrical_consumption": 1 }, { "water_consumption": 1, "electrical_consumption": 1 }, ] What I would like to achieve is to receive some aggregated data alongside those data, like this: { "total_water_consumption": 3, "total_elec_consumption": 3, "detailed_logs": [{ "water_consumption": 1, "electrical_consumption": 1 }, { "water_consumption": 1, "electrical_consumption": 1 }, { "water_consumption": 1, "electrical_consumption": 1 }] } How should I customise the queryset to have the total values added? Thank you in advance. -
Django login not working. Page just refreshes a new login page
I have a project called django_swing. Within this project i have 2 different app. One is interface and the other is users. Within the django_swing folder for urls.py, I have the following: path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), Within the interface folder for urls.py, I have the following: path('', views.home, name='interface-home'), Within the interface folder for views.py, I have the following: def home(request): return render(request, 'interface/home.html', {'title':'Home'} ) I have the file for home.html. As it is very long, I cant paste here. When i run the project, 127.0.0.1 loads the page for home.html. Lastly, within the django_swing folder for settings.py, I have the following at the bottom of the file: STATIC_URL = '/static/' LOGIN_REDIRECT_URL='interface-home' LOGIN_URL = 'login' But when i access 127.0.0.1/login and key in with a account i just made followed by pressing the login button, the page refreshes with the same login page and the url becomes http://127.0.0.1:8000/login/?#. It is not jumping to interface-home as declared in settings.py. Can anyone advise me on how to solve this? I am a beginner at this. Thank you very much! -
error of the Query set error in REST framework
I from this code I get the query set error( because the query set method). previously I got the result when I define the queryset outside of the GET, but that action was not proper.... Now I want to define the DonorContactInfo.objects.filter(email__iexact=email) anywhere but in the GET method... what should I do? class DonorInformationDetailAPI(ListAPIView): """ A sample endpoint to list all donors in the system. * Requires token authentication. * Only admin users are able to access this view. """ serializer_class = DonorContactInfoSerializer queryset = DonorContactInfo.objects.all() permission_classes = [IsAuthenticatedOrReadOnly] # TODO change pagination_class = AdminPanelsPagination def get(self, request, *args, **kwargs): """return the list of the donor detail with that specific email""" # queryset = self.get_queryset() email = kwargs["email"] self.get_queryset = DonorContactInfo.objects.filter(email__iexact=email) serializer = self.get_serializer(self.get_queryset, many=True) return Response(serializer.data, status=status.HTTP_200_OK) # def get_queryset(self): # return ?? here is my URL path( "donors/donor_information/<str:email>/", DonorInformationDetailAPI.as_view(), name="donors_information", ), this is the Error 'QuerySet' object is not callable -
How can i verify if the refer code is valid and sent by another user?
I am working on refer and earn module and been struck in on how to check if the refer code is valid and been sent by another user, so that i can give back commission to him. For the time being, I have created a model named Referral, which stores a random string, which is being generated within the model using a function as we can see below. Currently, I am generating referral code by the admin just by adding a refer user and automatically the unique string has been generated. Now I want to check to verify whether the code provided to the user has been the code referred by another user and grant him some rewards on each referrals. But I am thinking of how to achieve this solution. Please help me with the views part. Any kind of help would be appreciated. Thank you. Models.py: class Referral(models.Model): user = models.ForeignKey(AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="referral_codes", null=True, blank=True) label = models.CharField(max_length=100, blank=True) code = models.CharField(max_length=40, unique=True, blank=True) comm_amount = models.PositiveIntegerField(max_length=20, null=True, blank=True) expired_at = models.DateTimeField(null=True, blank=True) redirect_to = models.CharField(max_length=512,blank=True) created_at = models.DateTimeField(default=timezone.now) def __str__(self): if self.user: return f"{self.user} ({self.code})" else: return self.code def generate_refer_code(self): return get_random_string(8).upper() def save(self, *args, **kwargs): if … -
Can anyone that how to convert Django Api's as websocket Api?
Please tell me the answer, I wondering since long but didn't get anything. I have the API's which are working correctly with flutter but now I want to connect all those API's with web socket. Can anyone tell me how to do it? Api's Example: path('editpinnames/', myapp_view.devicePinNames), Suppose this is the api and I want to use this work with web sockets. Please I am very thankful to you. -
Make sure celery task exits after database commit
I have a Django application in which the app creates a celery task to process user input, check the progress of the task, and update the page as soon as the task is completed. I am well aware of the fact that the celery task should only be started after the record being processed is committed, using code such as transaction.on_commit(lambda: my_task.apply_async(args=(pk,))) However, when the task exits with something like @celery.task def my_task(pk): record = Record.objects.get(pk) # do something record.save() The django app still gets the old value of the record when it reads from the database (Record.objects.get(pk)), likely because the database has not been updated yet. How can I make sure that the celery task exits only after the transaction has been committed? I tried to add transaction.commit() after record.save() and it does not appear to help. -
Is Django REST Framework and Bootstrap enough to build a complete webapp?
I'm totally new backend developer and i want to create a website .I have an API which created in Django REST Framework. I want to use Bootstrap 5 as frontend. My question is that, whether these tools enough for building my site or i need more tools? Exactly my question is that are there any options in Bootstrap for sending request and getting responses from server or not? -
Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'error')1
`const loadAllProducts = () => { 41 | Object(helper_coreapicalls__WEBPACK_IMPORTED_MODULE_1_["getProducts"])().then(data => { 42 | if (data.error) { | ^ 43 | setError(data.error); 44 | console.log(error); 45 | }` -
ManagementForm data is missing or has been tampered with. Missing fields: servicesprice_set-TOTAL_FORMS
When i am changing and saving from Inclusive To Exclusive Django admin give me following error: (Hidden field TOTAL_FORMS) This field is required. (Hidden field INITIAL_FORMS) This field is required. ManagementForm data is missing or has been tampered with. Missing fields: servicesprice_set-TOTAL_FORMS, servicesprice_set-INITIAL_FORMS. You may need to file a bug report if the issue persists. This is happening after i override inline field. What does this mean? @admin.register(Services) class ServicesAdmin(ImportExportModelAdmin, EmptyFieldListFilter): ... inlines = [ SubServiceInline, ServicePriceInline ] ExclusiveInlines = [ ExclusiveServicePriceInline ] InclusiveInlines = [] ... def get_inlines(self, request, obj): if not obj.parent_id: return self.inlines elif obj.type == 1: return self.InclusiveInlines else: return self.ExclusiveInlines -
Change pending status to submitted after uploading of file in django
I am creating an assignment management system where students are uploading their assignments and the status of assignments are pending before uploading. I want to change the status when the assignment is saved at backend and change the status to submitted. template code <tr> <td>{{assignment.assignment_date}}</td> <td>{{assignment.assignment_creator}}</td> <td>{{assignment.assignment_title}} </td> <td> <form enctype="multipart/form-data" action="{% url 'assignment' %}" method="POST"> {% csrf_token %} <input required type="file" name="inputFile" id="" placeholder="upload"> <button>Upload</button> {{s.assignment_status}} </form> </td> <td> <span class="bg-success text-white">Pending </span></td> </tr> views.py print('file uploaded') if request.method == "POST": print('file uploaded Post') uploaded_file = request.FILES['inputFile'] print(uploaded_file) student = Student.objects.get(student_username=request.user) std_instance = student document = Submissions.objects.create(submitted_by=std_instance, submission_file=uploaded_file) document.save() print('saved') -
Uploading image file from React Native to Django
So on the React Native side the console.log is printing this for the image file as in I'm doing console.log(image_file) and getting this {"fileName": "rn_image_picker_lib_temp_0d752f09-0fab-40f0-8c89-13dec3695de0.jpg", "fileSize": 374466, "height": 810, "type": "image/jpeg", "uri": "file:///data/user/0/com.cheersfe/c ache/rn_image_picker_lib_temp_0d752f09-0fab-40f0-8c89-13dec3695de0.jpg", "width": 1000} Here is my React Native Code const createFormData = (photos, body = {}) => { const data = new FormData(); if (photos.length > 1) { console.log(photos[1]) data.append("images", photos[1]); } Object.keys(body).forEach((key) => { data.append(key, body[key]); }); return data; }; const onAddButtonClick = () => { if (value === null) { Alert.alert("Hold On!", "Please select a goal"); } else if (descriptionText === "") { Alert.alert("Hold On!", "Update description required"); } setLoading(true); const body = createFormData(photos, { join_goal: value, body: descriptionText }); postGoalUpdatePost(body).then(response => { // navigation.navigate("PostsScreen"); setLoading(false); }).catch(error => { const errorMessage = `${error.name}: ${error.message}`; }); setLoading(false); }; export async function postGoalUpdatePost(body) { return constructConfig().then(config => { return axios.post(`${url}/posts/update`, body, config).then(response => { return response.data; }); }); } But on the Django side when I look at request.data['images'] I get this crazy hexstring: \x7f.x�������uJr|�����a=e��|�\x00��^�=J0�^������\x08\x1a\\\x02;�H�a�a�\x19=�u�K\x01�x䞧�\x0e�{{�\x07\x14���}H�2\x06?.)%�\x7f\x1f�\x0c�RvI������=H-���[��䌏ÿ^��\x00玵�$��<g�\x1d}�\x1d�\x00®7�\x1e���Yr\x7f�\x1f���+&��wт�I�?������$�Ӯz���N?Z�+�\x07�Oo\x7f�?����\x7f\x13���ܒ1����\r����V=J0M�\x7f5�I5�ϹVG���\x189��`�\x7fJ�$��u�1���{\x7f.�չ:7���kuO��\x15���m,����{\x18x�\x7f.]�\x7f�W��s�\x0e=��1�\x00֬�e^��0y$sӧ�\x0ez՛���\x7f3YS\x13��|��+�\x7f\x13��#���;>�k�o�\x7fñ\x1c�\x03�\x0f\x18�;s�\'��ߥ\x19$$�{���O���SI�\x1b�U\x1f�\x0f�O�\x15���}^����֥\x08���u���\x002��|����|���Y�$�\x003�^�A�9�>�j��\x1f����z\x1f��U��\x17�u=z\x10\\��O����b9�V\x18\x04p\x08������Vd�G\x1f��2O�V��\x1f�ک\\u?C��qԛJI[���zT"����_�W+�\x02\x06\x0f$u����\x00����\x15\x19�\x1f��4W\x0b��z$w���' so clearly it's coming in as a string rather than a file. How do I fix this? -
Microservices- how can I call the api in django template
How can I call the rest api in django template.I want to design the microservices and just got thinking about calling a api in the front end.How could I achieve this. Usually when I work in monolithic I directly call it from the database in the html but not case in microservices part. -
Recursive and nested serializer for CreateAPIView
I know there are a few other threads about this topic but none of the solutions seem to work for me. I have a simple django-treebeard model that allows me to bulk add nested children to a parent via a load_bulk model method. The POST payload is essentially: items = [ {"data": {"title": "1"}, children: []}, {"data": {"title": "2"}, children: [ {"data": {"title": "2_1"}, children: []}, {"data": {"title": "2_2"}, children: [ {"data": {"title": "2_2_1"}, children: []}, ]}, ]}, ] payload = { "parent_id": parent_id, "items": items } I have a view that takes the parent_id and the items list of objects from the payload and passes it to load_bulk to create all the nested objects: Model.load_bulk(items, parent=Model.objects.get(id=parent_id) It works fine for the top-level of items but seems to ignore the nested children. In fact, I can't even get the get_children method in my serializer (commented below) to run. # models.py class Item(MP_node): id = UUIDField() title = CharField() # views.py class BulkCreateView(generics.CreateAPIView): queryset = Item.objects.all() serializer_class = BulkCreateSerializer # serializers.py class BulkCreateSerializer__item(serializers.ModelSerializer): class Meta: model = Item fields = ["title"] class BulkCreateSerializer__wrapper(serializers.ModelSerializer): data = TextBulkCreateSerializer__chapter() children = serializers.SerializerMethodField() class Meta: model = Item fields = ["data", "children"] def get_children(self, obj): … -
Django Boostrap TimePicker/Forms not working
I am working on a project and have ran into an issue with my forms. In particular, I want the form to use Bootstrap4 (from CDN) elements, yet when I try to use the widgets feature of ModelForm, it isn't working quite right forms.py: class Meta(object): model = ScheduleItem fields = ( 'name', 'time_start', 'time_end', 'day', ) widgets = { 'name': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'test' } ), 'time_start': forms.TimeInput( attrs={ 'class': "form-control" } ) } def __init__(self, *args, **kwargs): super(ScheduleItemForm, self).__init__(*args, **kwargs) self.fields['name'].label = "" self.fields['time_start'].label = "" self.fields['time_end'].label = "" self.fields['day'].label = "" html page: (The first two are ones using the form and the latter are not using it) <form action="" method="POST"> {% csrf_token %} <div class="input-group mb-3"> <label class="input-group-text" for="inputGroupSelect01">Description</label> {{schedule_item_form.name|as_crispy_field}} </div> <div class="input-group mb-3"> <label class="input-group-text" for="inputGroupSelect01">Start Time</label> {{schedule_item_form.time_start|as_crispy_field}} {% comment %} <input type="time" class="form-control" aria-label="Username" name="start_time" required> {% endcomment %} </div> <div class="input-group mb-3"> <label class="input-group-text" for="inputGroupSelect01">End Time</label> <input type="time" class="form-control" aria-label="Username" name="end_time" required> </div> <div class="input-group mb-3"> <label class="input-group-text" for="inputGroupSelect01">Day of the Week</label> <select class="form-select" id="inputGroupSelect01"> <option selected>Choose...</option> <option value="0">Monday</option> <option value="1">Tuesday</option> <option value="2">Wednesday</option> <option value="3">Thursday</option> <option value="4">Friday</option> <option value="5">Saturday</option> <option value="6">Sunday</option> </select> </div> <button type="submit" class="btn btn-primary mb-2 mt-2">Add item to … -
Django no User with same username in database
I'm particularly new to django and still in the learning process. I have this code where it would have the user input any text into the field and once the user hits the submit button it would grab the text they inputted and look for it in the django database for that item. It's able to do what I want, except when there are no users with that username. I don't know where I would do an if statement, or a work around for that. views.py from .forms import RequestPasswordResetForm from django.contrib.auth.models import User def request_password(request): next = request.POST.get('next', '/') if request.method == "POST": user = request.POST['passUsername'] users = User.objects.get(username=user) form = RequestPasswordResetForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'Request has been sent! Admin will be with you shortly.') return HttpResponseRedirect(next) -
Populate HTML table (dataTables) with AJAX+JS data in Django
I have an HTML page on Django which currently has two tables. The first table contains certain data related to a unique id key. Once the user clicks on an "Edit" button, Django populates a form using the available data using the id key. However, I also want to populate a second table ( different from the first one in the DB) by only showing the records related to the id under edition, passing it using a view. If no record is intended to edit, the table must appear empty to the user. I'm able to load the records from both tables using ajax: $(document).ready(function() { var 1Table= $('#FirstTable').DataTable( { "ajax": {"type":"GET", "url" :"/Deal/request_first/, "data":function( e ) { e.placeholder = "asdf"; } }, "columns": [ { "className": 'edit-control', "width": "12px", "defaultContent": '<button type="button" class="btn-primary"></button>' }, { "data": "id" }, { "data": "A" }, { "data": "B" }, ], } ); var 2Table = $('#Secodntable').DataTable( { "ajax": {"type":"GET", "url" :"/Deal/request_second/", "data":function( d ) { d.placeholder = "asdf"; } }, "columns": [ { "data": "id" }, { "data": "C" }, { "data": "D" }, ], } ); If the 'edit-control' is clicked, I'm calling a view that passes the data from the … -
Connect Google Cloud Platform SQL to Visual Studio
I am trying to connect VS to my GCP SQL Server but I'm running into a bunch of issues. I tried following a youtube tutorial (https://youtu.be/l4nPaSXE3QE) and it has an option for Google Cloud SQL in there Photo of Option, but when I download it, mine doesn't show that option. My Visual 2019 version is 16.11.2 Thanks in advance -
Move a data from one department to another using django
I have a webpage where it will show all the data, how do I move this data from this department to another department with just a click of a button. Lets say this data is currently at the customer service page and when I click on the view button the data will go to another department, for example logistic. So after clicking on the button view, it should appear here as shown from the picture below, how to do that Below are my codes for the customer service page and logistic page, they are both the same code. views.py (customer service) @login_required() def ViewMCO(request): search_post = request.GET.get('q') if (search_post is not None) and search_post: allusername = Photo.objects.filter(Q(reception__icontains=search_post) | Q(partno__icontains=search_post) | Q( Customername__icontains=search_post) | Q(mcoNum__icontains=search_post) | Q(status__icontains=search_post) | Q(serialno__icontains=search_post)) if not allusername: allusername = Photo.objects.all().order_by("-Datetime") else: allusername = Photo.objects.all().order_by("-Datetime") # new important part part = request.GET.get('sortType') valid_sort = ["partno", "serialno", "Customername", "mcoNum"] if (part is not None) and part in valid_sort: allusername = allusername.order_by(part) page = request.GET.get('page') paginator = Paginator(allusername, 6) try: allusername = paginator.page(page) except PageNotAnInteger: allusername = paginator.page(1) except EmptyPage: allusername = paginator.page(paginator.num_pages) context = {'allusername': allusername, 'query': search_post, 'order_by': part} return render(request, 'ViewMCO.html', context) views.py (logistic) @login_required(login_url='login') def …