Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Anchor tags not working in DJANGO project do to Javascript file
I have a project with many anchor tags and urls that connect many apps and pages. I also have a javascript file with some functions and DOM events to make somethings in my project. If I add a the script element to my project base.html (thats extended to all my html files) at the head of my base document like this it doesnt load the javascript file and it lets me use the anchor tags normal. But if I add <script **defer ** src="{% static '/js/script.js' %}"> to the element it loads the javascript file but it doesnt let me use the anchor elements. I have tried adding the javascript tag at the end of the base.html before the and it loads the javascript file but it doenst -
How to create popover survey like Hotjar using javascript on client website?
I have been using Django to create post purchase form, much like Google Form, using iframe to embed the form to the clients website. But then I saw Hotjar and how they implement their form as a popover survey. In Hotjar, after the form is created, Hotjar gives a javascript trigger that can be pasted into the clients website. I can create those stuff on my own website, but I am a bit lost on how those can be implemented on another website using javascript trigger. Does anyone have any tips on how to go on about implementing it myself? P.S. I am not interested in tracking features of Hotjar, just survey. So far I thought of creating Django templates and views to create questions and answers, and based on the inputs, then convert it into javascript and save it to Google Cloud Storage. I thought maybe I can load it on clients website using Javascript. But not sure how or whether it is even a good idea. Basically, I just want the client to paste some javascript code. And in doing so the forms (Questions, answers, and buttons) I created would appear at the bottom right corner of their … -
django.http.request.RawPostDataException on file upload
When I try to upload a file to my Django application and try to get the body of the request, I get this error. File "/docs/geon/tenv/lib/python3.10/site-packages/django/http/request.py", line 330, in body raise RawPostDataException("You cannot access body after reading from request's data stream") django.http.request.RawPostDataException: You cannot access body after reading from request's data stream Then I tried using the debugger to inspect the middleware by creating a simple middleware that does nothing and adding it to the topmost place in the list of middleware, then adding a breakpoint just after entering the process_request function. Then I inspected the 'body' attribute of the request and it is RawPostDataException("You cannot access body after reading from request's data stream") Apparently, something is modifying the request before it gets to middleware at all, and if the body is empty, it should be an empty string and not raise an error. I don't know which stack before middleware to look. I have restframework installed in app if it means something -
Asgi:Daphne Django issue in production
Hey i have error in my project its kind of wired error because the code works totally fine locally but its not working when i deploy it on Railway i installed channels[Daphne] and created web-socket and it works great but on deploy it gives this error 2023-10-04 19:10:30,487 INFO /app/.env not found - if you're not configuring your environment separately, check this. Traceback (most recent call last): File "/opt/venv/bin/daphne", line 8, in <module> sys.exit(CommandLineInterface.entrypoint()) File "/opt/venv/lib/python3.10/site-packages/daphne/cli.py", line 171, in entrypoint cls().run(sys.argv[1:]) File "/opt/venv/lib/python3.10/site-packages/daphne/cli.py", line 233, in run application = import_by_path(args.application) File "/opt/venv/lib/python3.10/site-packages/daphne/utils.py", line 12, in import_by_path target = importlib.import_module(module_path) File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/app/./project/asgi.py", line 1, in <module> import notification.routing File "/app/notification/routing.py", line 2, in <module> from notification.consumer import NotificationConsumer File "/app/notification/consumer.py", line 7, in <module> from notification.models import Notification File "/app/notification/models.py", line 3, in <module> from posts.models import PublishedPost File "/app/posts/models.py", line 2, in <module> from django.contrib.auth.models import User File … -
Disable Shortcut:Conflicts of boilerplate with Django extension in VS Code
Tell me why we are unable to use boilerplate (!) shortcut in vs code to add html while having Django extension installed its creating conflict it disables shortcut to add html. I have to add html code manually why its happening tell me the reason and solution that I can use both on same time without any conflict and disabling. As I am a beginner in Django please do guide me. I tried to change extensions settings but unable to fix it. -
Static Files not being found
I'm having issues with serving static files to my production server. I keep getting "WARNING:django.request:Not Found: /static/admin/css/base.css" along with the other static files within my terminal upon loading the page at my domain. Here's some of my code in my settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'django_extensions', 'sslserver', 'allauth', 'allauth.account', 'allauth.socialaccount', 'axes', 'rest_framework', ] ... STATIC_URL = 'static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') And here's my code within my httpd.conf and httpd-ssl.conf in my Apache files. Alias /static/ "C:/Users/MyUser/Desktop/MyProject/static/" <Directory "C:/Users/MyUser/Desktop/MyProject/static"> Require all granted </Directory> and in my httpd-ssl.conf: Alias /static/ "C:/Users/MyUser/Desktop/MyProject/static/" <Directory "C:/Users/MyUser/Desktop/MyProject/static"> Require all granted </Directory> <Directory "C:/Users/MyUser/Desktop/MyProject/"> Options Indexes FollowSymLinks Require all granted </Directory> I have my DEBUG = False I am also using Apache and Waitress on a Windows VM. Im running my server via: waitress-serve --listen=127.0.0.1:8000 MyProject.wsgi:application Here's my project directory: MyProject/ ├── manage.py ├── db.sqlite3 ├── static/ │ └── ... (my static files) ├── staticfiles/ │ └── ... (collected static files) └── MyProject2/ ├── settings.py ├── urls.py ├── wsgi.py └── __init__.py also heres my wsgi.py: os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'HaltScanner.settings') if settings.DEBUG: application = StaticFilesHandler(get_wsgi_application()) else: application = get_wsgi_application() # Add the HaltProject directory to PYTHONPATH sys.path.append(r'C:\Users\MyUser\Desktop\MyProject') # Debugging prints print("PYTHONPATH:", sys.path) print("sys.path:", … -
React styling with variable classname
I am making a chat app and the message has a classname of the current user's username. And I want if a user send a message to appear in blue while if the other one send one to appear in red. So I wanna do something like this: {currentUser.username} { background:red } -
the notification mark shows only if i am inside notification page
this code is for navigation bar in my website. when a new notification comes the var has_new_notification will be true then the notification-mark should show in notification element in the navbar. also there is class called active that makes the element color in navbar change when i click on the element. the problem: i can only see the notification-mark on notification element when i am inside notification page. `{% load static %} .header__menuItem.active a{ background-color: #51546e; color: #fff; padding: 10px 20px; margin: -10px -20px; border-radius: 10px; } .header__menuItem.notification { position: relative; } .notification-mark { position: absolute; top: 0; right: 0; width: 10px; height: 10px; background-color: red; border-radius: 50%; } DevSearch Logo Menu <li class="header__menuItem {% if request.path == '/accounts/notofications/' %}active{% endif %} notification"> <a href="{% url 'notofications' %}">Notifications</a> {% if has_new_notification %} <span class="notification-mark"></span> {% endif %} </li> <li class="header__menuItem {% if request.user.is_authenticated and request.path == '/accounts/logout/' %}active{% endif %}"><a href="{% url 'logout' %}" >Logout</a></li> {% else %} <li class="header__menuItem {% if request.path == '/accounts/login/' %}active{% endif %}"><a href="{% url 'login' %}" >Login/Sign Up</a></li> {% endif %} </ul> var lis = document.querySelectorAll('.header__menu li'); for (var i = 0; i ` i tried removing class: notification and only having class: notification-mark … -
Django Q sends many emails instead of once a day
I wrote a code that sends a letter once a day def send_statistics_email(): statistics = StatisticsNewletter.objects.all() message = "Статистика отправленных сообщений:\n\n" for stat in statistics: message += str(stat) + "\n" subject = "Статистика отправленных сообщений" print('Letter sent') send_mail(subject, message, settings.EMAIL_HOST_USER, [settings.RECIPIENT_ADDRESS]) schedule('notifications.views.send_statistics_email',schedule_type=Schedule.DAILY) Here's the loggi 20:35:16 [Q] INFO Process-1 created a task from schedule [52] 20:35:16 [Q] INFO Enqueued 59 20:35:16 [Q] INFO Process-1 created a task from schedule [53] 20:35:16 [Q] INFO Enqueued 60 20:35:16 [Q] INFO Process-1 created a task from schedule [54] 20:35:16 [Q] INFO Enqueued 61 20:35:16 [Q] INFO Process-1 created a task from schedule [55] 20:35:17 [Q] INFO Process-1:1 processing [snake-rugby-fish-salami] Letter sent 20:35:18 [Q] INFO Process-1:1 processing [eleven-blossom-south-fish] Letter sent 20:35:18 [Q] INFO Processed [snake-rugby-fish-salami] 20:35:20 [Q] INFO Process-1:1 processing [sodium-item-quiet-blossom] Letter sent 20:35:20 [Q] INFO Processed [eleven-blossom-south-fish] 20:35:21 [Q] INFO Process-1:1 processing [mobile-quiet-early-eleven] Letter sent 20:35:21 [Q] INFO Processed [sodium-item-quiet-blossom] 20:35:22 [Q] INFO Process-1:1 processing [robin-spring-fanta-utah] Letter sent 20:35:22 [Q] INFO Processed [mobile-quiet-early-eleven] 20:35:23 [Q] INFO Process-1:1 processing [artist-mexico-india-muppet] Letter sent 20:35:24 [Q] INFO Processed [robin-spring-fanta-utah] 20:35:25 [Q] INFO Process-1:1 processing [bulldog-angel-aspen-hot] Letter sent 20:35:25 [Q] INFO Processed [artist-mexico-india-muppet] I thought it was a matter of workers, although it costs 1 Q_CLUSTER = … -
Doctor Appointment Booking Using Django Forms
I am new to Django. I was trying to built a basic Dentist website which can be used by Patients for booking appointment, as a practice project. The problem I am facing is that I am unable to show available time slots dynamically, to prevent duplicate bookings. The time slot field comes up blank. I tried building logic in the constructor of the Django form itself, so that only available time slots are shown when a user selects a date. The Django form is: `from django import forms from django.forms.widgets import DateInput from .models import Appointment class DatePickerInput(DateInput): def __init__(self, *args, **kwargs): attrs = kwargs.get('attrs', {}) attrs.update({'data-provide': 'datepicker','data-date-start-date': '0d'}) kwargs['attrs'] = attrs super().__init__(*args, **kwargs) class AppointmentForm(forms.Form): first_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control ', 'placeholder': 'First Name'})) last_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control ', 'placeholder': 'Last Name'})) age = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control ', 'placeholder': 'Age'})) date = forms.DateField( widget=DatePickerInput( attrs={'class': 'form-control datepicker px-2', 'placeholder': 'Date of visit'} ) ) time_slot = forms.ChoiceField(choices=[('', 'Select Time Slot')] + [(option, option) for option in [ '09:00 AM', '10:00 AM', '11:00 AM', '12:00 PM', '02:00 PM', '03:00 PM', '04:00 PM', '05:00 PM', '06:00 PM', '07:00 PM', ]], widget=forms.Select(attrs={'class': 'form-control'})) contact_number = forms.CharField(max_length=15, widget=forms.TextInput(attrs={'class': 'form-control ', 'placeholder': 'Contact Number'})) … -
Bokeh YearsTicker and still month on the ticker sometimes
I am using Bokeh for some charts in a Django project. For instance: [![This one is fine, showing YYYY on the x axis.][1] However, when I restrict the period of time to display (thanks to a DateRangeSlider), years are then displayed as "1/YYYY" [![This one is bad][2]][2] Axis are defined as follows: plot.yaxis.formatter = NumeralTickFormatter(format="€0,0") plot.xaxis[0].formatter = DatetimeTickFormatter(years="%Y") plot.xaxis[0].ticker = YearsTicker() Has anyone a clue of how to always have tickers as YYYY? Thanks in advance Richard [1]: https://i.stack.imgur.com/u9vq4.png [2]: https://i.stack.imgur.com/K9CBp.png -
python-redsys Redirect the user-agent with post method
i use python-redsys : https://pypi.org/project/python-redsys/ I'm stuck at the step 4. Communication step This is my view : @login_required def redsys_start(request): secret_key = DS_SECRET_KEY client = RedirectClient(secret_key) parameters = { "merchant_code": DS_MERCHANT_MERCHANTCODE, "terminal": DS_MERCHANT_TERMINAL, "transaction_type": STANDARD_PAYMENT, "currency": EUR, "order": "000000001", "amount": D("10.56489").quantize(D(".01"), ROUND_HALF_UP), "merchant_data": "test merchant data", "merchant_name": "Example Commerce", "titular": "Example Ltd.", "product_description": "Products of Example Commerce", "merchant_url": reverse('front:shop_cart_payment_callback'), } args = client.prepare_request(parameters) print(f"args = {args}") context = {'args': args, 'BANK_PAIEMENT_URL': BANK_PAIEMENT_URL} # STEP 3 args = client.prepare_request(parameters) What i have to do after that fo redirect my customer to the red sys payement system ? If i try to redirect it with parameters redsys refuse because it is with get method If i try to make a form with args redsys give me an error SIS0431 (json Ds_MerchantParameters issue) That is wahat the doc say : 4. Communication step Redirect the user-agent to the corresponding Redsys' endpoint using the post parameters given in the previous step. After the payment process is finished, Redsys will respond making a request to the merchant_url defined in step 2. 5. Create and check the response Create the response object using the received parameters from Redsys. The method create_response() throws a ValueError in … -
Include CUDA device functions from another file
I am building a CUDA program using global and device functions but I have been facing an issue. I created a file with some device functions for using them inside the global functions but when I compile de code the global functions cannot find the specific device functions. Example: //file1.hpp #ifndef FILE1_HPP #define FILE1_HPP #include "cuda_runtime.h" #include "device_launch_parameters.h" #include "tools.hpp" __global__ void show(); #endif //file1.cu #include "file1.hpp" __global__ void show() { double a = test(); } //tools.hpp #ifndef TOOLS_HPP #define TOOLS_HPP #include "cuda_runtime.h" #include "device_launch_parameters.h" __device__ double test(); #endif //tools.cu #include "tools.hpp" __device__ double test() { return 1.0; } Error: ptxas fatal : Unresolved extern function '_Z4testv' CMakeList.txt: # A CMake version 3.10 or higher is required cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) # set the project language to C++ project( Test LANGUAGES CXX CUDA ) find_package(CUDA REQUIRED) # set all targets to use C++14 set( CMAKE_CXX_STANDARD 14 ) # it is an error if C++14 is not available set( CMAKE_CXX_STANDARD_REQUIRED ON ) # set the output directory for executable files set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../bin" ) # increase the output level of the created makefile set(CMAKE_VERBOSE_MAKEFILE OFF) #set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS} --generate-line-info") set(CMAKE_CXX_FLAGS_DEBUG "-g") # Add CUDA files to the project set(CUDA_FILES tools.cu file1.cu … -
Is it possible to use GNU extensions unless pedantic?
Is there a way to conditionally enable features that rely on GCC extensions (such as __int128) if they would compile? I want to do something like void foo(int); void foo(long); void foo(long long); #if not_pedantic void foo(__int128); #endif I could not find a macro that is defined when -pedantic or pedantic-error is passed. -
Linking error for c++: multiple definition of static inline function [closed]
I have two files I am compiling together using CMake (smallest example that produce the error): main.cpp #include "lib.h" int main() { return -1; } test.cpp #include "lib.h" CMakeLists.txt cmake_minimum_required(VERSION 3.25) project(proj) set(CMAKE_CXX_STANDARD 20) add_executable(proj main.cpp test.cpp) Now through a couple of inclides the lib.h file includes a file where the problem occurs: problematic.h #ifndef problematic_H_ #define problematic_H_ namespace p{ struct s{ // some code static inline thread_local someReturnType problemFunction{}; // some code }} Here I get the error: "multiple definition of `TLS init function for ...problemFunction...". I get the error on my Windows computer where I am using Clion with g++ from MinGW with gcc 9.3. First of all when compiling on my Mac it works fine. Second with my understanding of static inline there should be a different identifier for the function *problemFunction * in each of the two compilation units (files), and thus no multiple definitions. Third, since the * problemFunction * is in the header only library I do not want to change anything in there, I believe the error is somehow in my build setup. Any help would be much appreciated. -
C++ client server program to send random numbers using pthreads. Use different classes and files for the program [closed]
Write a c++ program using pthreads to send random numbers from the range 100-10000. Use 3-4 files and oops concepts for the program. I’ve tried the required program but I’m always ending up having errors. I need a linux based program -
Artifacts in ray marched compute shader [closed]
I am getting odd artifacts in my compute shader. It is as if the memory writes to the outputImage are overlapping. My compute shader code follows: #version 430 core uniform vec2 textureSize; layout(std430, binding = 0, column_major) readonly buffer CameraBuffer { vec3 cameraPosition; mat4 inverseViewProjection; }; layout(rgba8, binding = 1) writeonly uniform image2D outputImage; layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in; #define EPSILON 0.00001 #define MAX_STEPS 200 #define MAX_DIST 1000. #define SURF_DIST .001 const int SPHERE = 1; struct RayMarchResult { float distance; int objectType; int hitObjectIndex; vec3 hitPoint; vec4 color; }; struct Object { int type; vec3 position; mat4 rotation; int index; }; layout(std430, binding = 2, column_major) readonly buffer ObjectBuffer { Object objects[]; }; struct Sphere { float radius; }; layout(std430, binding = 3) readonly buffer SphereBuffer { Sphere spheres[]; }; struct EmissiveMaterial { vec4 color; float intensity; }; layout(std430, binding = 4) readonly buffer EmissiveMaterialBuffer { EmissiveMaterial emissiveMaterials[]; }; float sphereSDF(in vec3 point, in vec3 position, in Sphere sphere) { return length(point - position) - sphere.radius; } float GetDist(in vec3 point, out int hitObjectIndex) { float minDist = MAX_DIST; hitObjectIndex = -1; int objectsLength = objects.length(); for (int index = 0; index < objectsLength; … -
ttyname_r on the same file descriptor from the same terminal does not return the same stream/tty on linux
I have a cpp application (process A) that obtains the terminal associated with the fd of stdin. int ttyName = ttyname_r(fileno(stdin),..........). When I run this process A directly, fileno(stdin) is 0 and ttyname_r on this returns 0 with the buffer set to 'dev/pts/0'. From the same terminal I have two different processes - process B and C spawning process A. I do not have control on what goes in B and C. Process B is launched by a bash script and I believe is a node.js process. Process C is a cpp application that spawns A by fork() and execv(). From the same terminal, when I launch processes B and C (either in bg), the ttyname_r call made by the spawned process A is different between B and C. From B, the ttyname_r call doesn't succeed and returns 25 (ENOTTY). From C, ttyname succeeds but the buffer is set to 'dev/pts/4'. I would expect the tty/stream returned on the fd of stdin to be the same i.e dev/pts/0 when called by multiple processes but all launched from the same terminal. I am currently reading the env 'SSH_TTY' to get the tty associated with the terminal and that seems to be … -
Issue with a code exception on my C++ code [closed]
I have just started to learn C++ but the first thing I have been taught seems to have an error. Part of the code is to test the setup of the various compilers including Clang++, g++ and MSVC. The code that has the error has <=> in it and the error occurs on the > as it shows up with a red line underneath. Why is this? I am using the code 20 standard on vscode ide. I have tried to look for a reason for the exception but nothing leads me to a resolve. -
staticfiles directory is managed but still it is showing error as "GET /static/css/style.css HTTP/1.1" 404 1798 while executing the program! and why?
I have been used staticfile in the project, STATICFILES_DIR = [ BASE_DIR / 'static', ] which contains css and image folders! and connected the css file, *style.css *,to the html page! <!DOCTYPE html> <html lang="en"> <head> {% load static %} <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link href="{% static 'css/style.css' %}" rel="stylesheet" type="text/css"/> </head> <body> {% include 'menu.html' %} <span class="name">Hello, World!</span> </body> </html> But the GET request not fetching the css file! "GET /static/css/style.css HTTP/1.1" 404 1798 I have tried by changing the directory of staticfile, STATICFILES_DIR = [ BASE_DIR / 'staticfiles/static', ] But still not working!!! -
Problem in defining of Vector class Copy Constructor (C++)
I tried to define Vector class and some functions of it manually. Everything seemed like okay, until i wrote the Copy Constructor where i get warning in in this part of loop. this->arr[i] = vec.arr[i]; C6386:Buffer overrun while writing to 'this->arr' #include <iostream> using namespace std; class Vector { private: int size, capacity; int* arr; public: Vector(int _capacity = 5) : capacity(_capacity) { size = 0; arr = new int[capacity]; cout << "constructor" << endl; } ~Vector() { delete[] arr; cout << "destructor" << endl; } Vector(const Vector& vec) { this->capacity = vec.capacity; this->size = vec.size; this->arr = new int[this->capacity]; for (int i = 0; i < size; ++i) { this->arr[i] = vec.arr[i]; //WARNING. C6386:Buffer overrun while writing to 'this->arr' } cout << "copy constructor" << endl; } void push_back(int n) { if (size==capacity) { resize(); } arr[size] = n; size++; } void resize() { int* tmp = new int[capacity*=2]; for (int i = 0; i < size; ++i) { tmp[i] = arr[i]; } delete[] arr; arr = tmp; } int Size() { return size; } }; int main() { Vector V1(3); V1.push_back(1); cout << V1.Size(); V1.push_back(4); cout << V1.Size() << endl; V1.push_back(4); cout << V1.Size() << endl; V1.push_back(4); cout … -
C/C++: Why does an iostream allocate more memory at runtime than printf?
I noticed this today and thought it was interesting: I compiled a basic "hello world" first in C and then in C++ #include <stdio.h> int main() { printf("a\n"); return 0; } #include <iostream> int main() { std::cout << "a" << std::endl; return 0; } And ran both of them through valgrind. The C version (even when compiled with g++) showed 1,024 bytes allocated, while the C++ version showed 73,728 bytes allocated That seems like a pretty massive difference -- what exactly is going on there? And a second thought, why is even a full kilobyte needed to run the C version? Thanks anyone who can help me understand! Update: Thanks everyone for your responses! It looks like including <iostream> has a one-time initialization cost of a little over 72,000 bytes, and the cout itself only uses the same kilobyte as printf. Just for kicks, I wrote the following and tested it: #include <stdio.h> class minified_output_stream { void output(const char* text) { printf(text); } public: minified_output_stream& operator<<(const char* text) { output(text); return *this; } }; int main() { minified_output_stream min_cout; min_cout << "A\n"; return 0; } And found that the binary which used this "imitation cout" only allocated 1 kilobyte of … -
foo(char*): call with hardcoded {...}
I have a function foo that takes a char*. I'd like to call that function with hardcoded {0x00, 0xff} without assigning it to variables first. // out of my control, uses char* as a byte array: void foo(const char*){} int main(void) { // First assigning to unsigned char (unsigned necessary for 0xff) // then casting to char* and calling works: unsigned char x[2] = {0x00, 0xff}; foo((char *)x); // foo({0x00, 0xff}); // err, cannot interpret the braces // Hint: const char foo((const char[]){0x00, 0x01}); // works (but not with 0xff) return 0; } Any hints? -
Why overload arithmetic operator minus has conflict with valgrind?
While implementing operator overloading for the class of decimal numbers, I ran into a problem. I made this operator constant, since none of the parameters change. But Valgrind gives the following problem, as I understand it, the problem is related to the disruptor. void Seven::resizeArrayMinus() { unsigned char* tmp = new unsigned char[_size - 1]; std::memcpy(tmp, _array, (_size - 1) * sizeof(unsigned char)); delete this->_array; _array = tmp; _size--; } And what say valgrind: ==10049== Mismatched free() / delete / delete [] ==10049== at 0x484BB6F: operator delete(void*, unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==10049== by 0x109CE4: Seven::resizeArrayMinus() (in /mnt/c/oop_lab/lab2/lab2) ==10049== by 0x10A4CE: Seven::operator-(Seven const&) const (in /mnt/c/oop_lab/lab2/lab2) ==10049== by 0x10A3A3: Seven::operator-(Seven const&) const (in /mnt/c/oop_lab/lab2/lab2) ==10049== by 0x109471: main (in /mnt/c/oop_lab/lab2/lab2) ==10049== Address 0x4dd6160 is 0 bytes inside a block of size 4 alloc'd ==10049== at 0x484A2F3: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==10049== by 0x10965F: Seven::Seven(unsigned long const&, unsigned char) (in /mnt/c/oop_lab/lab2/lab2) ==10049== by 0x10A3F8: Seven::operator-(Seven const&) const (in /mnt/c/oop_lab/lab2/lab2) ==10049== by 0x10A3A3: Seven::operator-(Seven const&) const (in /mnt/c/oop_lab/lab2/lab2) ==10049== by 0x109471: main (in /mnt/c/oop_lab/lab2/lab2) ==10049== If you remove the constant value from the operator, the problem disappears -
App Localization for date and file upload
I've got an issue with app localization where parts of the forms (picking the date and updating files) are in native language instead of english. I've tried various changing/adding various lines in settings.py LANGUAGES = [ ('en', 'English'), ] LANGUAGE_CODE = 'en-us' USE_L10N = False I also don't have the middleware line in my settings: 'django.middleware.locale.LocaleMiddleware'