Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
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' -
C++ pass function as template argument within constructor
I'd like to replace a std::function with a template parameter, since everything is known at compile time. No I know there a many answers here in the forum and over the internet how to pass and directly consume a templated function (for ex here https://rules.sonarsource.com/cpp/RSPEC-5213/?search=std%3A%3Afunction) However in my case: I am using the templated function in a private member. Therefore I have to set up the templated function within the constructor. Now I have 2 questions: how can I pass and store the templated function as a member parameter for later use in a private function is it possible to use concepts to enforce that all functions passed as a template argument are using a specific signature (in my case std::string(const uint32_t u32ReadOffset, const uint32_t u32MaxReadLength)) So far i have come up with this #include <string_view> #include <concepts> #include <string> #include <cstdint> template <typename T, typename U, typename V> concept IDmmy = requires(T a, const std::string_view b) { { a.template foo<U>() }; { a.template bar<V>(b) }; }; template<typename FnGetFunction_T> class Foo { public: explicit Foo(FnGetFunction_T fn); void publicFunction(); private: FnGetFunction_T m_fn; void privateFunction(); }; template<typename FnGetFunction_T> Foo<FnGetFunction_T>::Foo(FnGetFunction_T fn): m_fn(fn) { } template<typename FnGetFunction_T> void Foo<FnGetFunction_T>::publicFunction() { //do some checking first … -
Overload variadic function for a single specific type using C++17
I want to overload (or specialize) a variadic function, such that the overload (or specialization) takes only arguments of a specific type. In C++20 I would write: #include <type_traits> #include <iostream> // original version void foo(auto const&...) { std::cout << "default\n"; } // oveload/specialization takes only Bar instances struct Bar {}; void foo(std::same_as<Bar> auto const&...){ std::cout << "Bar\n"; } The code works as expected. The second version is chosen, if the arguments are all Bar, the first otherwise. How would I create the second overload with C++17? Ideally, I wouldn't have to modify the more general version. Here is a first failed attempt using std::enable_if: https://godbolt.org/z/9vn39jTd4 -
how to make timer_create and timer_delete multi-thread proof
I am stuck in a peculiar situation where I call timer_create from one thread and call the timer_delete from another thread. But I cant seem to get it work as it ends up in a deadlock: I cannot figure out how to make it thread safe, should I use mutexes? or should I use some other way to avoid deadlocks? my code is as follows: #include <iostream> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <signal.h> #include <time.h> #include "pthread.h" typedef struct { struct sigevent tmrSigEvt; timer_t tmr; }TMR_DATA_T; int a = 10; int b = 20; int c = 0; TMR_DATA_T tmrDataArray[5] = { 0 }; void TimerCallback( union sigval timer_data ) { std::cout<<"am i here\n"; c = a + b; } int32_t CreateTimer( int32_t timerId, const uint32_t msPeriod ) { int32_t ret = -1; uint8_t slot = timerId; timer_t *tmrPtr = &tmrDataArray[slot].tmr; struct itimerspec period; uint32_t tmpPeriod; tmrDataArray[slot].tmrSigEvt.sigev_notify = SIGEV_THREAD; tmrDataArray[slot].tmrSigEvt.sigev_notify_function = TimerCallback; tmrDataArray[slot].tmrSigEvt.sigev_signo = timerId; tmrDataArray[slot].tmrSigEvt.sigev_value.sival_ptr = ( void* )&tmrDataArray[slot]; tmrDataArray[slot].tmrSigEvt.sigev_notify_attributes = NULL; ret = timer_create( /*CLOCK_REALTIME*/ CLOCK_MONOTONIC, &tmrDataArray[slot].tmrSigEvt, tmrPtr ); std::cout<<"----------------DO I COME HERE AFTER CREATING THE TIMER---------\n"; tmpPeriod = msPeriod % 1000; // remainder or period less than 1sec period.it_value.tv_nsec = ( … -
django-oauth-toolkit error: Unable to parse query string
I'm trying to access the /o/authorize/ domain with the following parameters: I'm redirected to login at an admin portal and once I successfully login, I get this: "Error: invalid_request. Unable to parse query string" This is the code I'm using to generate the code_challenge: import random import string import base64 import hashlib code_verifier = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(random.randint(43, 128))) code_verifier = base64.urlsafe_b64encode(code_verifier.encode('utf-8')) code_challenge = hashlib.sha256(code_verifier).digest() code_challenge = base64.urlsafe_b64encode(code_challenge).decode('utf-8').replace('=', '') print(fr'code verifier: {code_verifier}') print(fr'code challenger: {code_challenge}') -
Django and Okta Login
I have been following the guide on "https://pypi.org/project/django-okta-auth/" to integrate and app on to okta, but for some reason on the login screen after I enter the credentials , it takes me back to login screen again rather than the actual home page. Please help and verify my if I'm doing it correctly. urls.py urlpatterns = [ path('accounts/', include(("okta_oauth2.urls", "okta_oauth2"), namespace="okta_oauth2")), path('admin/', admin.site.urls), path('classroom/',include('classroom.urls')), path('',HomeView.as_view(),name='home') ] Okta_Auth "SCOPES": "openid profile email", # this is the default and can be omitted "REDIRECT_URI": "http://localhost:8000/oauth2/callback", "LOGIN_REDIRECT_URL": "/", # default INSTALLED_APPS = [ 'okta_oauth2.apps.OktaOauth2Config', 'classroom.apps.ClassroomConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] Login.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script src="https://global.oktacdn.com/okta-signin-widget/5.0.1/js/okta-sign-in.min.js" type="text/javascript" ></script> <link href="https://global.oktacdn.com/okta-signin-widget/5.0.1/css/okta-sign-in.min.css" type="text/css" rel="stylesheet" /> </head> <body> <div id="okta-login-container"></div> <script type="text/javascript"> var oktaSignIn = new OktaSignIn({ baseUrl: '{{config.url}}', clientId: '{{config.clientId}}', redirectUri: '{{config.redirectUri}}', authParams: { issuer: '{{config.issuer}}', responseType: ['code'], scopes: "{{config.scope}}".split(" "), pkce: false, }, }); console.log(oktaSignIn) oktaSignIn.renderEl( {el: '#okta-login-container'}, /* function (res) {[![enter image description here][1]][1] console.log(res); }*/ ) </script> </body> </html> [ -
ckeditor in django has chenged to TextField
I was using postgresql and then I had to change my db to mysql . after changing all RichTextUploadingFields changed to TextFields in django admin ! How can I fix this ? also I try this code in settings.py but It does not working : STATIC_ROOT = '/home/yeganexu/public_html/static' STATIC_URL = '/static/' MEDIA_ROOT = '/home/yeganexu/public_html/media' MEDIA_URL = '/media/' CKEDITOR_UPLOAD_PATH = 'uploads/' CKEDITOR_IMAGE_BACKEND = "pillow" CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' CKEDITOR_CONFIGS = { 'default': { 'toolbar': 'full', 'width': 'auto', 'extraPlugins': ','.join([ 'codesnippet', ]), }, }` -
How can I use the ffi package to use c++ in my flutter app?
Right now I am trying to implement the mediapipe c++ library into my flutter app. At the beginning I wrote a simple function with a printf() function in it in c++ to try to to run it in flutter. I compiled as follows: g++ -shared -o produce_landmarks.so -fPIC produce_landmarks.cpp I put the compiled shared .so file into each following structur folder: android/app/src/main/jniLibs /arm64-v8a /armeabi-v7a /x86 /x86_64 Unfortunately I got an bad ELF error. Probably because I didn't compiled it for the correct processor architecture. "data/app/.../lib/arm64/produce_landmarks.so" has bad ELF magic: 4d5a9000" //on phone "/data/app/.../lib/x86_64/produce_landmarks.so" has bad ELF magic: 4d5a9000 // on emulator But do I really need to compile the c++ code, which is right now a simple function with a printf() function into different architectures? If that's the case then how can I do it? I would like to know what the exact steps are to run a simple c++ function the mediapipe c++ library in flutter. I am asking because I am just confused of the many ways that the ffi package was being used in youtube. Do I need to use ffigen? I saw many people create plugins? But I don't think that I need that because I …