Categories
Mastering Development

Agora – unable to merge video .ts files into one single video file

I am using agora.io for video calling. I am running script on my localhost. I am able to record the video successfully but they are multiple .ts files. I downloaded python script from agora website and ran it. It runs successfully without any error But it does not generate any single video file, in short […]

Categories
Mastering Development

Defining path to a file with argparse

I have the following piece of python code: # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument(“-p”, “–detector”, required=True, help=”path to detector .dat file”) ap.add_argument(“-a”, “–warning”, type=str, default=””, help=”path to warning .WAV file”) ap.add_argument(“-w”, “–webcam”, type=int, default=0, help=”index of webcam on system”) args = vars(ap.parse_args()) I have two files named as […]

Categories
Development

Add entry in Admin stopped working due to default timezone setting on field

I tried to add a new entry into my model yesterday via the Django Admin panel, but I got an exception. The problem seems to be with the default value of the new field last_spreadsheet_update that I added recently. If I change the default date to timezone.now() everything works. last_spreadsheet_update = models.DateTimeField(blank=False, null=False, default=timezone.now) Traceback: […]

Categories
Development

filtering documents using multy properties (refrenced and nrml) in mongoose and express using request query

so i want to get sales that r available in a specific date and by price (min,max) and place(wilaya,daira and commune),so the booking is a reference in sale and contains the date property and contacte contains the place where is the sale. const contacteSchema = new mongoose.schema({ telephone:[{ type:Number, minlength:10, maxlength:10, required:true }], adress:{ wilaya:{ […]

Categories
Development Django

Django Error: type object ‘Invoice_Line’ has no attribute ‘objects’

I defined a method in admin.py to add up after-tax amounts: def _grand_total(self, object_id): line_amounts = Invoice_Line.objects.filter(appointment_ref=object_id).values_list(‘total_after_tax’, flat=True) return reduce((lambda x,y: x + y), line_amounts) The ORM query defined in this line: Invoice_Line.objects.filter(appointment_ref=object_id).values_list(‘total_after_tax’, flat=True) generates the error below: type object ‘Invoice_Line’ has no attribute ‘objects’ Models code shown below: models.py: class Appointment(models.Model): create_date = models.DateField(auto_now_add=True, […]

Categories
Development

How to exclude a foreign’s key field from a form

Having my models Yacht and Offer, I created an intermediate table OfferHasYacht in order to connect a yacht with an offer. I have already created instances for both models. I want to exclude in my form the field date_created from the Offer model because when I am trying to included it in my form it […]

Categories
Development

How to test an Flask API that is using context arguments

I’m pretty new at programming and I’m blocked trying to create an unit test for this application, its pretty simple: from flask import Flask, request,jsonify,make_response app = Flask(__name__) @app.route(‘/header’) def my_route(): text = request.args.get(‘text’) tag = request.args.get(‘tag’,default=0,type=int) if text.find(‘.’)==-1: if tag==0: return jsonify(header=text.title()) else: return jsonify(header= ‘<h’ + str(tag) + ‘>’ + text.title() + ‘</h’ […]

Categories
Development Django

Subquery django query to get biggest disctint values from objects and return those objects

So I have this query that I need to re-filter to get just the biggest taken_at field’s value from distinct meter id, but I cannot get the django orm’s/sql part to makes this query. <QuerySet [<Reading: [127] meter installation: 29, type: 1, taken: 2019-10-07 16:06:48.101453+00:00 value: 78.0000, comment: , VAT: 22.00>, <Reading: [126] meter installation: […]

Categories
Development Django

How to edit value of a record when Django admin page of the model gets opened

In my Django app, I have a model that has an IntegerField for holding the number of queries done today and another field that holds the date of last modification of that field. class logs(models.Model): today_queries = models.IntegerField(“today’s queries”, default=0, help_text=”Total number of today’s queries.”) update_date = models.DateField(default=datetime.date.today) My problem is that every time I […]

Categories
Development

Parse command line argument in python

have to do command line parsing and I am getting this error. I’m very new to Python and I don’t know what the error means. ap = argparse.ArgumentParser() ap.add_argument(“-i”, “–image”, required=True, help=”path to input image”) ap.add_argument(“-m”, “–mask-rcnn”, required=True, help=”base path to mask-rcnn directory”) ap.add_argument(“-v”, “–visualize”, type=int, default=0, help=”whether or not we are going to visualize […]