Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to restore deleted files from a GitHub account
I accidentally deleted the code from my GitHub account using Github Interface and wanted to recover it through.Is there anyway I can run commands directly through my github account and not through github console? -
AttributeError: 'str' object has no attribute '_meta' Migrating django 4.1
Whenever I try to use the migrate command on django, this error pops up for the migration file in app "fonte". The model inside uses a ManyToMany field with the through argument on the model "FonteVariavel", which then connects to "Variavel". Applying fonte.0001_initial...Traceback (most recent call last): File "/APP/manage.py", line 22, in <module> main() File "/APP/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 402, in run_from_argv self.execute(*args, **cmd_options) File "/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 448, in execute output = self.handle(*args, **options) File "/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 96, in wrapped res = handle_func(*args, **kwargs) File "/.venv/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 349, in handle post_migrate_state = executor.migrate( File "/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 135, in migrate state = self._migrate_all_forwards( File "/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards state = self.apply_migration( File "/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 252, in apply_migration state = migration.apply(state, schema_editor) File "/.venv/lib/python3.9/site-packages/django/db/migrations/migration.py", line 130, in apply operation.database_forwards( File "/.venv/lib/python3.9/site-packages/django/db/migrations/operations/models.py", line 96, in database_forwards schema_editor.create_model(model) File "/.venv/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 453, in create_model if field.remote_field.through._meta.auto_created: AttributeError: 'str' object has no attribute '_meta' Here is the relevant code from django.db.models import DateField, ManyToManyField, Model, TextField from core.fonte_variavel.models import FonteVariavelModel from core.variavel.models import VariavelModel from .managers import FonteManager from .querysets import FonteQuerySet class FonteModel(Model): nome … -
Send user's email to developers email django
Lets say i have an email when a user logs in . Could there a way to recieve an email that {user's email} has logged in and for log outs too. I have tried to do reaserch on this but didnt know how to start as i am a new to making websites -
Having an error 'AttributeError at /register/ '
Full of error : AttributeError at /register/ 'DataEbotUser' object has no attribute 'session' I abstracted the User and created a DataEbotUser as models then created a form which takes this as a model. But when I try to add user with using this form Im taking such an error. And there is also one more problem. When I try to add user with Django Administraion having an KeyError 'first_name' (if I delete the init function in forms it becomes normal). I need a proper register form which works properly. I cant understands the problems clearly. (I created the models in different app and imported) class DataEbotUser(AbstractUser): phone=models.CharField(max_length=20) LastClientLogin = models.DateTimeField(null=True , blank = True) LastServerLogin = models.DateTimeField(null=True , blank=True) AllowServerLogin = models.BooleanField(default=False) LoginType = models.IntegerField(null=True , blank=True) class DataLoginType(models.Model): user = models.ForeignKey(DataEbotUser, null=True , on_delete=models.CASCADE) name = models.CharField(max_length=200) detail = models.CharField(max_length=200) isActive = models.BooleanField(default=False) def __str__(self): return self.name class CustomUserCreationForm(UserCreationForm): class Meta: model = DataEbotUser fields = ['username','first_name','last_name','email','phone','password1','password2'] def __init__(self, *args, **kwargs): super(UserCreationForm, self).__init__(*args, **kwargs) self.fields['username'].widget.attrs.update( {'class': 'form-control', 'placeholder': 'Enter username...'}) self.fields['first_name'].widget.attrs.update( {'class': 'form-control', 'placeholder': 'Enter First Name...'}) self.fields['last_name'].widget.attrs.update( {'class': 'form-control', 'placeholder': 'Enter Last Name ...'}) self.fields['email'].widget.attrs.update( {'class': 'form-control', 'placeholder': 'Enter Email...'}) self.fields['phone'].widget.attrs.update( {'class': 'form-control', 'placeholder': 'Enter Phone...'}) self.fields['password1'].widget.attrs.update( {'class': … -
Django - adding gamification features
I have a medium size Django REST app that I'm looking to add gamification features to. The application in question is a school webapp where students can create mockup quizzes, participate in exams that teachers publish, and write didactical content that gets voted by other students and teachers. I want to add some gamification features to make the app more interesting and to incentivize participation and usage of the various features: for example, each student will have a personal "reputation" score, and gain points upon completing certain actions--a student may gain points when completing a quiz with a high score, when submitting some content, or when receiving upvotes to such content. The tricky part is I want to be able to have this logic be as separate as possible from the existing codebase, for various reasons: separation of concerns, ability to plug the engine in/out if needed, ability to easily deactivate features for certain groups of users, etc. What I'm looking for here is some software engineering advice that's also Django-specific. Here's a high level description of what I'm thinking of doing--I'd like some advice on the approach. create a new gamification app. Here I will have models that describe … -
Django formset error for ID "Select a valid choice. That choice is not one of the available choices"
I am posting a formset in Django. The form on the client side is generated dynamically using a file uploaded by the user. I render it like this: <form method="post" id="add3"> {{ formset.management_form }} {% csrf_token %} <table id="forms"> <tbody> {% for lst in result %} <input type="hidden" name="form-{{ forloop.counter0 }}-id" value="{{ forloop.counter }}" id="id_form-{{ forloop.counter0 }}-id"> <tr> <td> <input type="hidden" name="form-{{ forloop.counter0 }}-expense" id="id_form-{{ forloop.counter0 }}-expense" value="{{lst.0}}"/> </td> <td> <input type="hidden" name="form-{{ forloop.counter0 }}-amount" id="id_form-{{ forloop.counter0 }}-amount" value="{{lst.1}}"/> </td> {% endfor %} </tbody> </table> </form> I get the following error on the server side when I receive the formset. Formset is_valid returns False and I get the error: id: Select a valid choice. That choice is not one of the available choices How can I fix this? What's the right way to pass an ID? Note: I am updating management_form total-forms using Javascript. If that matters. -
Django NoReverseMatch after deleting object
Im hard stuck here, everything is connected via pk, and on group of accounts can see only their data whiel an other group can see all data from the other group. But I have a model where ONLY the staff group can add update and delete while the other group can only update. While it works fine and all when the staff group deletes all 'teachers' in that case I get no reverse match error. The thing is, In the view the staff needs to see everything compact in their template like the school and teacher and so on. right now I either have atleast two type of teacher and the template works or the school is sorted normaly while the teachers are all shown under every school template hope you get what I mean. I only need something that dont break if a FK is deleted so that if staff makes a new teacher everything works template <ul> <li>{{Ansicht.Lehrer_FK.Leitung_der_Klasse}}</li> <a href="{% url 'LehrerAktualisierenVerwaltung' Ansicht.Lehrer_FK.pk %}" >Lehrer Aktualisieren</a> <a href="{% url 'LehrerEntfernenVerwaltung' Ansicht.Lehrer_FK.pk %}" >Lehrer L&ouml;schen</a> </ul> form class LehrerAktualisierenVerwaltung(LoginRequiredMixin, UpdateView): model = LehrerTabelle fields = '__all__' template_name = 'SCHUK/LehrerAktualisierenVerwaltung.html' context_object_name = 'LehrerAktualisierenVerwaltung' def get_success_url(self): return reverse('Dashboard') url path('LehrerAktualisierenVerwaltung/<int:pk>/', LehrerAktualisierenVerwaltung.as_view(success_url="Dashboard"), … -
How to build Django external URLs with differing protocols
I am soliciting and parsing user content for all types of URLs (starting with http|https|ftp as well as only www.xxx.xxx), e.g. http://www.foo.bar and www.google.com and https://guardian.co.uk. At a later stage I am presenting these URLs back in a template and want to create links that go straight to those destinations: <a href="//{{resource.text}}" target="_blank" role="button">{{resource.text}}</a> However, if I don't prefix with // I get relative URLs (which obviously isn't working), but if I do add the prefix and create absolute URLs, I'm up the creek as the protocols differ between the various URLs. Is there a way to tell Django to treat the URLs naively and let the browser sort out the context? -
How to set relation between Product Sales and Product Costs Tables in Django
probably basic question but I need help how to set up relations between my models. I have the first model SalesData, where I import from csv sales data of products for particular periods - so this table can contain a product multiple times with different dates, quantities and sales: class SalesData(models.Model): date = models.DateField("Date", null=True, blank=True) product = models.CharField("Product", max_length=150, null=True, blank=True) sales = models.DecimalField("Sales", max_digits=10, decimal_places=2, null=True, blank=True) quantity = models.IntegerField("Quantity", null=True, blank=True) I have the second model ProductCosts, where I have the product and its production costs. And one product can have only one specific production costs. class ProductCosts(models.Model): product = models.CharField("Product", max_length=150) costs = models.DecimalField("Costs", max_digits=10, decimal_places=2) And I need help with: how to connect these two tables to be able to get production costs for particular product to each row in SalesData table, so I will be able to calculate profit, margin etc. for particular rows? what to do, to be able to create form, where I can fill production costs for rows, where are these costs missing for new sales data inputed to table? And if it is possible to have the form as a table with products with missing costs in the first column … -
I want to collect visitors information on a website im building
I want to be able to get my web visitors email only when the signup and get notified when the logout. How should i go about this -
Django: How can I use inlineformset to save multiple forms that all share the same FK as another object being created on the same form page?
I have two models Animal and Gene_Animal_Bridge. I have a form page that allows a user to add a new animal to the database and attach any genes that they have. The genes are stored in Gene_Animal_Bridge which contains the FK of the animal it belongs to, and the FK of the Gene that is stored in the GeneInfo Model. Everything works fine but when it comes to iterating over the formset, only 1 gene will be saved and any other gene forms added on the page won't save. Models.py from django.db import models import datetime class Animal(models.Model): animal_id = models.AutoField(primary_key=True, editable=False, null=False) gender = models.CharField(max_length=6, choices=(('m','male'), ('f','female')), null=True) name = models.CharField(max_length=14) description = models.CharField(max_length=75,blank=True, null=False) dob = models.DateField(default=datetime.date.today, blank=True, null=True) purchase_date = models.DateField(default=datetime.date.today, blank=True, null=True) image = models.ImageField(blank=True, null=True) prey_type = models.CharField(max_length=20,choices=(('1','2XL Multi'),('2','Large Weaner'),('3','Live Multi'),('4','Small Rat'),('5','Small Weaner')),blank=True, null=True) last_feed = models.DateField(default=datetime.date.today, blank=True, null=True) last_shed = models.DateField(default=datetime.date.today, blank=True, null=True) weight = models.IntegerField(blank=True, null=True) class GeneInfo(models.Model): gene_id = models.AutoField(primary_key=True, editable=False, null=False) gene_name = models.CharField(max_length=20, null=False) type = models.CharField(max_length=20,choices=(('1','pos het'),('2','het'),('3','visual'),('4','co-dominant'),('5','super'),('6','dominant')),null=False) def __str__(self): return (self.gene_name) class Gene_Animal_Bridge(models.Model): animal_id = models.ForeignKey(Animal, on_delete=models.CASCADE, related_name="bridge_animal_id", null=True) gene_id = models.ForeignKey(GeneInfo, on_delete=models.CASCADE, related_name="bridge_gene_id", null=True) class Breeding(models.Model): sire_id = models.ForeignKey(Animal, on_delete=models.CASCADE, related_name="breeding_sire_id", null=True) dame_id = models.ForeignKey(Animal, on_delete=models.CASCADE, related_name="breeding_dame_id", null=True) … -
How to use form.as_table and crispy forms together?
I want to use form.as_table and crispy forms together, but it is generating an error as shown in the screenshot below :- Here is my code :- <form action="{% url 'create' %}" method="post"> {% csrf_token %} <table> {{form.as_table|crispy}}<br> </table> <input class="btn btn-outline-primary" type="submit" value="Create" id="create"> </form> -
Django: Get count of specific values by month in queryset
my model is like so: class Project(models.Model): name = models.CharField(max_length=1000, null=True, blank=True) date_created = models.DateTimeField(auto_now=True) status = models.CharField(max_length=1000, null=True, blank=True) The status field has about 5 different options (won, lost, open, pending, cancelled). I need to know how to get the number of projects with x status in each month in a given time range query. I was able to get the sum total of projects each month with the following annotation: Project.objects.all().annotate(month=TruncMonth('date_created')).values( 'month').annotate(total=Count('pk'), ).order_by('date_created') However, I am looking for an output like this: [{date: 'January 2020', total: 30, won: 10, lost:10, open: 10, pending: 0, cancelled: 0}, {date: 'February 2020', total: 30, won: 10, lost:10, open: 10, pending: 0, cancelled: 0}, {date: 'March 2020', total: 30, won: 10, lost:10, open: 10, pending: 0, cancelled: 0}] Ideally I would like the keys within the final output to be dynamic (i.e. if a new status is added, we won't need to hardcode a new key into the query) but I don't know if this is possible or not. Thanks for your time! -
How to add a custom button beside the list display in django admin panel? To edit the form from list display it self
Here is my admin.py code: `from django.contrib import admin from .models import * from django.utils import * import csv from django.http import HttpResponse class ProductAdmin(admin.ModelAdmin): search_fields = ('name',) list_display = ('name','price',) admin.site.register(Product,ProductAdmin)` [I have attached my admin panel screenshot][1] -
Django CheckConstraint not enforcing check on model field
I am using Django 3.2. Backend database used for testing: sqlite3 I have a model Foo: class Foo(models.Model): # some fields ... some_count = models.IntegerField() class Meta: models.constraints = [ models.CheckConstraint( check = ~models.Q(some_count=0), name = 'check_some_count', ), ] I also have a unit test like this: def test_Foo_some_count_field_zero_value(self): # Wrap up the db error in a transaction, so it doesn't get percolated up the stack with transaction.atomic(): with self.assertRaises(IntegrityError) as context: baker.make(Foo, some_count=0) When my unit tests are run, it fails at the test above, with the error message: baker.make(Foo, some_count=0) AssertionError: IntegrityError not raised I then changed the CheckConstraint attribute above to: class Meta: models.constraints = [ models.CheckConstraint( check = models.Q(some_count__lt=0) | models.Q(some_count__gt=0), name = 'check_some_count', ), ] The test still failed, with the same error message. I then tried this to check if constraints were being enforced at all: def test_Foo_some_count_field_zero_value(self): foo = baker.make(Foo, some_count=0) self.assertEqual(foo.some_count, 0) To my utter dismay, the test passed - clearly showing that the constraint check was being ignored. I've done a quick lookup online to see if this is a known issue with sqlite3, but I haven't picked up anything on my radar yet - so why is the constraint check … -
Django: Setting IntegerField after form submit
How do i increase the "availability" IntergerField after the form is submitted? Each new product_type is created in the admin panel since i'll only ever need a few of them. Each new product is created through a form. views.py def new_product(request): if request.method != 'POST': # No data submitted, create blank form form = ProductForm() else: # POST data submitted, process the data form = ProductForm(data=request.POST) if form.is_valid(): product = form.save(commit=False) product.owner = request.user #product.product_type.availability += 1 # This didn't work #product.product_type.add_product() # And this didn't work product.save() return redirect('store') context = {'form': form} return render(request, 'store/new_product.html', context) models.py class ProductType(models.Model): availability = models.IntegerField(default=0) ## How to increase this on the fly? price = models.DecimalField(max_digits=7, decimal_places=2, default=6.99) product_type = models.CharField(max_length=200, default="Tier1") cores = models.IntegerField(default=1) ram = models.IntegerField(default=2) disk = models.IntegerField(default=10) def __str__(self): return self.product_type def add_product(self): self.availability = self.availability + 1 print(self.availability) forms.py class ProductForm(forms.ModelForm): class Meta: model = Product fields = ['host_name', 'host_password', 'product_type'] -
How to assign function to button in Django
I am designing a website based on django. I want to update the user information and delete the user if wanted in the same page. I created updating and it works properly. But when I address the delete user function to same html file , the button that I want it to delete user also updates just like the other button. I need both buttons to work for their own purposes. I thought that without changing anything assigning delete function to button might help thats why I wrote the title like that. Thank you! <div class="login--wrapper"> <form method="POST" class="form"> {% csrf_token %} <div class="center"> <h1>Kullanıcı Ayarları</h1> {% csrf_token %} {% for field in form %} <div class="mb-3"> <label for="exampleInputPassword1" class="from-label">{{field.label}}</label> {{field}} </div> {% endfor %} <button type="submit" class="btn btn-primary">Update Info</button> <button type="submit" class="btn btn-primary">Delete User </button> </div> def DeleteUser(request,pk): user=DataEbotUser.objects.get(id=pk) if request.method=='POST': user.delete() context={'user':user} return render(request,'home/DeleteUser.html',context) def users(request,pk): user=DataEbotUser.objects.get(id=pk) form=EditUserForm(instance=user) if request.method=='POST': form=EditUserForm(request.POST, instance=user) if form.is_valid(): form.save() context={'form':form , 'users':users} return render(request,'home/UsersPage.html',context) -
How to get cookie values when it's coming different subdomains?
I have a cookie value set in wordpress site and I would need to read this value when the page redirects to the app which is a django backend. How do I retrieve this value in the app? So this value should persist from www.example.com to app.example.com -
Django is_staff: when User registered he is staff but not have any Permissions i want when he register he will get all Permissions by default
hare i do the save what i need to add for he will get all Permissions by default myuser = User.objects.create_user(username, email, pass1,is_staff=True) myuser.first_name = fname myuser.last_name = lname myuser.is_active = False myuser.save() -
Django ImageField Form upload works in admin but not in actual user form
I am trying to upload an image within a form that has an animal type, description, and the image file. This should save to image in an "images" file within my project and this works fine when adding a model object from the admin page but when trying to use the actual form on my site, only the animal type and description gets saved to the admin page. model code: class Post(models.Model): BISON = 'Bison' WOLF = 'Wolf' ELK = 'Elk' BLACKBEAR = 'Black Bear' GRIZZLY = 'Grizzly Bear' MOOSE = 'Moose' MOUNTAINLION = 'Mountain Lion' COYOTE = 'Coyote' PRONGHORN = 'Pronghorn' BIGHORNSHEEP = 'Bighorn Sheep' BALDEAGLE = 'Bald Eagle' BOBCAT = 'Bobcat' REDFOX = 'Red Fox' TRUMPETERSWAN = 'Trumpeter Swan' YELLOWBELLIEDMARMOT = 'Yellow-bellied Marmot' RIVEROTTER = 'River Otter' LYNX = 'Lynx' SHREW = 'Shrew' PIKA = 'Pika' SQUIRREL = 'Squirrel' MULEDEER = 'Mule Deer' SANDHILLCRANE = 'Sandhill Crane' FLYINGSQUIRREL = 'Flying Squirrel' UINTAGROUNDSQUIRREL = 'Uinta Ground Squirrel' MONTANEVOLE = 'Montane Vole' EASTERNMEADOWVOLE = 'Eastern Meadow Vole' BUSHYTAILEDWOODRAT = 'Bushy-tailed Woodrat' CHIPMUNK = 'Chipmunk' UINTACHIPMUNK = 'Uinta Chipmunk' WHITETAILEDJACKRABBIT = 'White-tailed Jackrabbit' BEAVER = 'Beaver' AMERICANMARTEN = 'American Marten' MOUNTAINCHICKADEE = 'Mountain Chickadee' BOREALCHORUSFROG = 'Boreal Chorus Frog' CUTTHROATTROUT = … -
Django Rest: How to use user_get_model() in different apps created in a project?
As I'm creating one project which contain one core app and rest apps for different purpose and in core app models.py I've created Custom User model and I' using "from django.contrib.auth import get_user_model" for accessing current user but as I'm using this in other app apart from core app it is giving me error:'function' object has no attribute 'objects'. recipe myapp - core app recipe - project user - user app myapp/models.py- custom user model is created I want to access get_user_model() in user/views.py so that I can list users on the basis of admin or non admin users. -
Where heroku save files downloaded by celery?
I have the following problem. I have a django web application with a celery task that downloads a video to a location I set. On local the application works fine but on heroku I get the error(Incorrect Path). The name of the video its correct selenium save from the last word in link (de07fb663fbf470ead9b3f9509c2bf96.mp4). [2022-08-17 17:31:53,721: ERROR/ForkPoolWorker-2] Task AppVimeoApp.tasks.download[18a4d723-e485-4844-919d-4012fa38ca5d] raised unexpected: OSError('MoviePy error: the file /app/media/AppVimeoApp/video/de07fb663fbf470ead9b3f9509c2bf96.mp4 could not be found!\nPlease check that you entered the correct path.') celery.py from celery import shared_task import time from selenium import webdriver from django.conf import settings from selenium.webdriver.common.by import By from moviepy.editor import * @shared_task def download(): chrome_options = webdriver.ChromeOptions() chrome_options.binary_location = str(os.getenv('GOOGLE_CHROME_BIN')) chrome_options.add_argument("--headless") chrome_options.add_argument("--start-maximized") chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--disable-extensions") chrome_options.add_argument('--disable-dev-shm-usage') chrome_options.add_argument("--disable-gpu") chrome_options.add_argument('--disable-software-rasterizer') chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166") chrome_options.add_argument("--disable-notifications") chrome_options.add_argument('--window-size=1920,1080') chrome_options.add_experimental_option("prefs", { "download.default_directory": f"{settings.MEDIA_ROOT}\\AppVimeoApp\\video", "download.prompt_for_download": False, "download.directory_upgrade": True, "safebrowsing_for_trusted_sources_enabled": False, "safebrowsing.enabled": False } ) driver = webdriver.Chrome(executable_path=str(os.getenv('CHROMEDRIVER_PATH')), chrome_options=chrome_options) driver.get('https://pastedownload.com/loom-video-downloader/#url=https://www.loom.com/share/de07fb663fbf470ead9b3f9509c2bf96') time.sleep(5) while True: try: driver.find_element(by=By.XPATH, value='/html/body/div[2]/div[1]/div[6]/div[2]/div[1]/a').click() break except: time.sleep(1) continue time.sleep(5) video = VideoFileClip(f"{settings.MEDIA_ROOT}/AppVimeoApp/video/de07fb663fbf470ead9b3f9509c2bf96.mp4") # get seconds of video video_seconds = video.duration print(video_seconds) return (f"Downloaded - {video_seconds}") -
Django form filter pk of multiple related tables
I´m learning Django and working on a sports team management project I am trying to create a form with multiple components: Some descriptive fields from model PersonnelFormation with a choice of a Personnel group (newtest in the screenshot): OK Based on the selected group, get a list of required players from model PersonnelGroup (should be QB, Z in the example): current issue For each player a list of available positions from PersonnelRolePosition (for ex Gun/Center for QB, Wing for Z) with a formset according to my research Current state of the form in edit view The issues I have currently are with step 2: I can´t get the filter quite right on the form. I use self.instance.id to show the concept but, I need a way to get the pk of the related personnel_group? I can see in the table that the field is there, I just don´t know if/how to access it from the form PostgreSQL screenshot of the relevant table When creating a form, how could I process step 2 ? Do I need to save the form to access the value of the selected group ? Simplified models (some character fields ommited): class PersonnelRole(models.Model): """Model used to … -
Counting Array Values by a Filtered Value in Javascript
I am trying to count the number of values in the array I calculated (const C) that fall into a given range, for instance the array returns [2,2,1.5,1.5], I'm trying to count the number of values in the array that is <1, 1<x<2, 2<x, etc. So it should return, count x<1 = 0, 1<x<2 = 4, 2<x = 0. Thanks for the help! <div id="id"></div> <script> for(let i = 0; i < 1; i++) { Array.prototype.zip = function (other, reduce, thisArg) { var i, result = [], args, isfunc = typeof reduce == "function", l = Math.max(this.length, other.length); for (i=0; i<l; i++) { args = [ this[i], other[i] ]; result.push( isfunc ? reduce.apply(thisArg, args) : args ); } return result; } const A = [4,6,12,18] const B = [2,3,4,6] const C = A.zip(B, function (l, r) { return l / (l - r); }); //[2,2,1.5,1.5] let id = document.querySelectorAll(`[id^="id"]`)[i] let problemTypeChoice = 0; if (problemTypeChoice === 0) { id.innerText = `${C}` } } </script> -
Django class based view: saved value not loading correctly in a select field
I have a Django 3.2 application running in a production environment, with around 10 simulatenous users. In some of my forms, the saved value for a select field is not loading correctly in the form edit view. This happens after the system is running for a while. If I restart the service, the value loads correctly again on the select field. Some additional information: Django 3.2 / class based views Python 3.8.10 Django default cache system Postgres 12.11 Ubuntu 20.04.4 More than enough RAM and disk space. The model for which the value doesn't load correctly has ~ 130k objects. Sometimes it loads with a void value, sometimes a completely wrong value. Thanks in advance for any hints! best alan