Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Backend doesn't return json to Angular frontend
I have web project, backend on Django , frontend on Angular Backend started as: python3 manage.py runserver 192.168.1.195:8080 Frontend started as: ng serve --host 192.168.1.195 on the 4200 port. On the Django in CORS_ORIGIN_WHITELIST section in settings.py CORS_ORIGIN_WHITELIST = ( 'http://192.168.1.195:8080', 'http://localhost:8081', 'http://192.168.1.195:4200', 'http://127.0.0.1:4200', ) On the frontend side in service.ts: var apiUrl = "http://192.168.1.195:8080"; var httpLink = { getAll: apiUrl + "/api/hosts_groups", When i call http://192.168.1.195:8080/api/hosts_groups django returns json as excpected and in console i see : "GET /api/hosts_groups HTTP/1.1" 200 85 But in case when i call http://192.168.1.195:4200 no json returned although in console i see: "OPTIONS /api/hosts_groups HTTP/1.1" 200 0 -
Choosing between Laravel and Django for a CRM project?
I need to build a CRM application for a medium-sized clothing factory that mainly produces t-shirts. The factory manages a large fabric storage with fabrics labeled by code (e.g., #001). Each fabric code corresponds to different models, and each model has various colors and materials. The goal is to store and display each fabric variety separately, along with showing the quantity of that model in the storage. Additionally, the factory frequently imports and exports fabrics, requiring tools for journaling these transactions. The application should log details such as the imported/exported model, quantity, color, and date. Currently, these activities are managed using Excel, and the aim is to create a user-friendly and comprehensive tool for these tasks. The application should include a search/filter tool to allow managers to easily find information. For instance, a manager might want to know which models and colors were imported/exported on a specific day or which fabric types were used for creating certain product models—an advanced search functionality is crucial. I've previously built something similar using Laravel but not at that scale (there was much less data). However, I'm uncertain if Laravel (with Postgres and NextJs) would be powerful enough for this specific application, considering the … -
Unable to connect to rmq hosted on openshift from my local machine
I'm trying to connect to rabbitMQ hosted/installed/deployed on openshit container from my local machine, and i'm facing issues. connection = pika.BlockingConnection(pika.ConnectionParameters(credentials=credentials, host=settings.RABBIT_MQ_HOST, port=settings.RABBIT_MQ_PORT)) here settings.RABBIT_MQ_HOST i have given container hostname got getaddrinfo failed error and tried ip of the container pod got pika.exceptions.AMQPConnectionError can some please help on this, thanks in advance. -
different scope throttle limits depending on the type of user in the same action of a single API
I have categorized my multiple APIs in 5 different categories now I want that throttling limit of those APIs should not be common all across. I want different limits for type of user eg. if it is user_1 scope throlling limits should {Category1: 100/hr; Category2: 100/min; Category3 : 10/hr; Category4: 10/min ;Category1: 20/sec;} and if it is user_2 scope throlling limits should {Category1: 230/hr; Category2: 40/min; Category3 : 120/hr; Category4: 15/min ;Category1: 50/sec;} I have tried multiple methods by creating custom class, creating dictionary and importing overring but nothing works this is what I tried have commented upperpart to make it distinguish from rest_framework.throttling import UserRateThrottle,ScopedRateThrottle # from backend.settings.base import VIEWSET_CATEGORIES from backend.settings.base import * # class APIThrottle(ScopedRateThrottle): # def allow_request(self, request, view): # category = self.determine_category(view) # if category: # self.set_rate_limit(category) # return super().allow_request(request, view) # def determine_category(self, view): # viewset_path = f"{view.__module__}.{view.__class__.__name__}" # return VIEWSET_CATEGORIES.get(viewset_path) # def set_rate_limit(self, category): # self.scope = category # if category == 'category1': # self.rate = '5/hour' # elif category == 'category2': # self.rate = '10/hour' class ExpectionUserRateThrottle(UserRateThrottle): def allow_request(self, request, view): if self.rate is None: return True self.key = self.get_cache_key(request, view) if self.key is None: return True self.history = self.cache.get(self.key, []) self.now … -
Django url with params(int), don't know how to test, i tried but failed
can anyone give help me how to test the following url in django? path('sendtokitchen/int:table_number/', send_to_kitchen, name='sendtokitchen'), So far I have this, but it does not contains the param, therefore it fails. def test_sendtokitchen_url_is_resolves(self): url = reverse('sendtokitchen', kwargs={'table_number': 1}) self.assertEquals(resolve(url).func, send_to_kitchen) -
Is there a way to get Django to reload after changes when using it with Docker?
I'm relatively new to Docker/deployment in general. I have a django app that utilizes rpy2 (not sure if relevant), that I have deployed using a docker container. However, I want to be able to continue developing the application and testing within the docker environment without having to spin the container up and down constantly. I read that using volumes could help to bring this functionality back, but I either have gotten the container working and don't see updates, or I get errors saying that manae.py can't be found. Is there any way to reintroduce the autoloading functionality? Here is my Dockerfile: FROM rocker/r-ver:4.1.1 ENV RENV_VERSION 0.14.0 # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ python3-pip \ python3-setuptools \ python3-dev \ libcurl4-openssl-dev \ libssl-dev \ libfontconfig1-dev \ libxml2-dev \ libharfbuzz-dev \ libfribidi-dev \ libfreetype6-dev \ libpng-dev \ libtiff5-dev \ libjpeg-dev \ libbz2-dev \ libopenblas-dev \ unixodbc-dev \ libcairo2-dev \ zlib1g-dev \ curl \ libpq-dev RUN apt-get update && apt-get install -y cmake RUN apt-get install -y --no-install-recommends libxt6 WORKDIR /app COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt RUN R -e "install.packages('remotes')" RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')" COPY renv.lock renv.lock RUN R -e "renv::restore()" RUN … -
Django tags being displayed as text
I am currently working on a Django project. I am having problem with the tags on my HTML, they are being displayed as text. The HTML for the page in question: <div class="row"> <div class="col s12"> <button type="button" class="btn waves-effect waves-light tool-pattern-btn btn-action-pattern" onclick="javascript:history.go(-1)"><i class="material-icons left">keyboard_return</i>Go Back</button> </div> <div class="col s12"> {% if submitted %} Employee included succefully! {% else %} <form action="{% url 'incluirPessoa' %}" method="post"> <div class="card hoverable"> <div class="card-content exib-pattern"> <span class="card-title-home"><i class="material-icons left">add</i>New Employee</span> {% csrf_token %} <div class="row"> <div class="input-field col s12 l6"> <input ng-model="pessoa.name" maxlength="255" type="text" class="form-control" id="nome" name="nome" /> <label for="nome">Name:</label> </div> <div class="input-field col s12 l4"> <input ng-model="pessoa.email" maxlength="255" type="text" class="form-control" id="nome" name="nome" /> <label for="nome">Email address:</label> </div> </div> <div class="row"> <div class="input-field col s12 l3"> <input ng-model="pessoa.identidade" maxlength="255" type="text" class="form-control" id="identidade" name="identidade" /> <label for="id">identidade:</label> </div> <div class="input-field col s12 l3"> <label for="id">Institute:</label> <input ng-model="pessoa.institute" maxlength="255" type="text" class="form-control" id="instituto" name="instituto"> </div> </div> {{ form.as_p }} <div class="row"> <div class="col s12"> <button type="submit" class="btn waves-effect waves-light tool-pattern-btn green"> <i class="material-icons left">add</i>Add</button> </div> </div> </div> </div> </form> {% endif %} </div> </div> I have already read a couple of questions, but couldn't find any answer. -
Why is this local django DATABASES configuration not honored in django 5.0.1?
I'm using a local.py settings inclusion so the devs can use sqlite3 and deployed sites can use things like postgres. This is the local_py_example.py (using /tmp just for this repro): DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': '/tmp/db.sqlite3', } } The settings file imports this thus: import os import sys from django.utils.translation import gettext_lazy as _ from utilities.find_base_dir import find_base_dir # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = find_base_dir() sys.path.insert(0, f"{BASE_DIR.parent}") # will look for local.py in the parent directory try: # noinspection PyPackageRequirements,PyUnresolvedReferences from local import * except ImportError: from club_site.settings.local_py_example import * sys.path.pop(0) ... (no DATABASES declared in settings (ONLY IN local.py)) print(f"sqlite: {DATABASES['default']['NAME']}") # at end just for debugging this An e.g. 'django migrate' creates the database at the wrong location (in the BASE_DIR) in spite of the print statement at the end of the settings showing the correct location (/tmp/db.sqlite3). -
Django: group by two columns and distinct without regard to order
I have a TextMessage model as you see: class TextMessaage(models.Model): id = models.UUIDField( _("Id"), primary_key=True, default=uuid.uuid4, editable=False, null=False, blank=False, ) created_at = models.DateTimeField(_("Created at"), auto_now_add=True) modified_at = models.DateTimeField(_("Modified at"), auto_now=True) sender = models.ForeignKey( User, on_delete=models.PROTECT, related_name="sent_messages", blank=False, null=False, verbose_name=_("Sender"), ) receiver = models.ForeignKey( User, on_delete=models.PROTECT, related_name="received_messages", blank=False, null=False, verbose_name=_("Receiver"), ) body = models.TextField( null=False, blank=False, validators=[MaxLengthValidator(4096)], verbose_name=_("Body"), ) What I am trying to do is to get last message of each conversation. I tried this: conversations = ( models.TextMessage.objects.filter(Q(sender=user) | Q(receiver=user)) .order_by( "sender__id", "receiver_id", "-modified_at", ) .distinct("sender__id", "receiver_id") ).all() The problem is that query that I have written will consider pair (sender=A, receiver=B) different from (sender=B, receiver=A) which is not I am looking for. I want these two pairs supposed the same since they share the same foreign keys regardless of their order. What should I do? To add more info, I am using Postgres by the way. -
Error when executing pipenv shell in python 3.9.12
I am trying to install and use pipenv on windows. The steps that I did: 1.pip install pipenv. 2.Added the path where pipenv was installed to the PATH. 3. Created a directory for the project and named it "work". 4. pipenv --python 3.9.12. 5.(ERROR) An error occurs when entering the "pipenv shell": E:\work>pipenv shell Launching subshell in virtual environment... Traceback (most recent call last): File "C:\Users\NickName\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\NickName\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\NickName\AppData\Roaming\Python\Python39\Scripts\pipenv.exe\__main__.py", line 7, in <module> # when invoked as python -m pip <command> File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1157, in __call__ return self.main(*args, **kwargs) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\cli\options.py", line 58, in main return super().main(*args, **kwargs, windows_expand_args=False) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1078, in main rv = self.invoke(ctx) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 783, in invoke return __callback(*args, **kwargs) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\decorators.py", line 92, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 783, in invoke return __callback(*args, **kwargs) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\cli\command.py", line 394, in shell do_shell( File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\routines\shell.py", line 44, in do_shell shell.fork(*fork_args) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\shells.py", line 100, in fork _handover(self.cmd, self.args + list(args)) File "C:\Users\NickName\AppData\Roaming\Python\Python39\site-packages\pipenv\shells.py", line 68, in _handover … -
How do I fix the module not found error in django
I created a django project which has 2 apps: Aceit and api, I am getting a module not found error when trying to make migrations or do anything that requires the manage.py file. I am using a virtual environment that uses python 3.10 it is worth noting that I had another project called AceIt(with a capital i as opposed to the one I have now), which I deleted. I am not sure if me deleting it is causing these problems but just thought to mention it. Below I have provided my file directory structure and stack trace of the error, if there is anything else I need to provide let me know. file directory structure: stack trace after calling python manage.py makemigrations: Traceback (most recent call last): File "C:\Users\mosta\Desktop\Desktop\Mostafa Azouz\Queen mary\Ace-It!\Code\Backend\api\manage.py", line 22, in <module> main() File "C:\Users\mosta\Desktop\Desktop\Mostafa Azouz\Queen mary\Ace-It!\Code\Backend\api\manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\mosta\miniconda3\envs\Aceit\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line utility.execute() File "C:\Users\mosta\miniconda3\envs\Aceit\lib\site-packages\django\core\management\__init__.py", line 416, in execute django.setup() File "C:\Users\mosta\miniconda3\envs\Aceit\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\mosta\miniconda3\envs\Aceit\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Users\mosta\miniconda3\envs\Aceit\lib\site-packages\django\apps\config.py", line 193, in create import_module(entry) File "C:\Users\mosta\miniconda3\envs\Aceit\lib\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 … -
CORS error in label studio on setting host and port
I am trying to run label-studio in my local server and do a reverse proxy. However following the website https://labelstud.io/guide/start#Run-Label-Studio-with-HTTPS I can run the label-studio but on sign-in and login-in I am getting CORS error. [2024-02-04 16:07:29,509] [django.security.csrf::log_response::224] [WARNING] Forbidden (CSRF cookie not set. -
Django JWT Changed but still valid
I have a project of mine in which I was veriyfing the authenticity of token, generated by library rest_framework_simplejwt. While playing around token I changed last character from 8 to 9 and it worked. I am not able to understand why and how it happened. My original token: { "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzA3MDY0NTc1LCJpYXQiOjE3MDcwNjA5NzUsImp0aSI6IjBhNDEyY2M5NjIwYjQxYzJhZDI5NzFhNzZkZGJhOGJhIiwidXNlcl9pZCI6NH0.jvylGlq3qkJPhvBkhbsqFPakwyMS7BBDwB-bMIAzWq8" } Tweaked yet valid token: { "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzA3MDY0NTc1LCJpYXQiOjE3MDcwNjA5NzUsImp0aSI6IjBhNDEyY2M5NjIwYjQxYzJhZDI5NzFhNzZkZGJhOGJhIiwidXNlcl9pZCI6NH0.jvylGlq3qkJPhvBkhbsqFPakwyMS7BBDwB-bMIAzWq9" } Focus on last character of token. Any opinions? -
Django pass error exception to error views handler
urls.py handler500 = 'main.views_error.view_error_500' main/views_error.py def view_error_500(request, exception=None): print("APP: view_error_500") print(exception) return render(request,"error/500.html", status=500) So when i'm asking for page with error look like Exception does not pass to views: APP: view_error_500 None 2024-02-04 18:24:58,641 - django.request 241 - ERROR - Internal Server Error: /office/order_14841/ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view return view_func(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view return view_func(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/main/views_admin.py", line 1453, in admin_orders_edit order = Company_Orders.objects.get(id=kwargs["order_id"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 647, in get raise self.model.DoesNotExist( main.models.Company_Orders.DoesNotExist: Company_Orders matching query does not exist. Like there is no view_error_500 handler, but i'm sure So the question is: is there and way to get error informations to my handler so i can work with error? -
Django fails to update environment variable from wsgi.py
I have a Django application that uses Apache in production. I store the Django secret key value in an external file, from which the key gets applied on startup. I let Apache know the location of the file using SetEnv directive in my application config file: SetEnv DJANGO_KEY_LOC /data/www/ref/.myKey I've written a function in wsgi.py to get the path from the Apache env variable and apply the key value inside to the SECRET_KEY setting in settings.py. If the code doesn't find that variable it pulls the location from an os env variable I use for dev DJANGO_KEY='/data/www/ref/.myKey: import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myApp.settings') os.environ['DJANGO_SETTINGS_MODULE'] = 'myApp.settings' _application = get_wsgi_application() def application(environ, start_response): try: # DJANGO_KEY_LOC set in Apache conf for prod. file_loc = environ['DJANGO_KEY_LOC'] with open(file_loc, 'r') as f: os.environ['SECRET_KEY'] = f.read() except KeyError: # if key missing in environ try dev settings print('running in dev environment...') dev_file_loc = os.getenv('DJANGO_KEY') with open(dev_file_loc, 'r') as f: os.environ['SECRET_KEY'] = f.read() return _application(environ, start_response) The function retrieves the key values just fine, but fails to set os.environ['SECRET_KEY']. The code in settings.py is SECRET_KEY = os.environ['SECRET_KEY']. The app fails to load unless I supply a dummy value for SECRET_KEY beforehand, but the … -
Django: reset passowrd in updateview
I am new to Django and try to change/reset the passowrd of an user. Is it possible to change/set the password of an user in updateview? Or ist there a function available to serialize an input and save to the password field of the user model? Thanks in advance Ben -
Django built-in LogoutView is always 'GET'
First stuck with "Method Not Allowed (GET): /logout/", found answer, changed template so method is 'POST'(tried 'post'), but now despite it I'm still getting "Method Not Allowed (GET): /logout/", since method is still 'GET'. Same happens when LogoutView.as_view() is empty. urls.py from django.contrib import admin from django.contrib.auth import views as auth_views from django.urls import path, include from users import views as user_views urlpatterns = [ path('admin/', admin.site.urls), path('register/', user_views.register, name='register'), path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'), path('', include('blog.urls')), ] full html file(/users/templates/users/logout.html) <form method="POST" > {% csrf_token %} <button type="submit">logout</button> </form> command prompt when I'm going to http://localhost:8000/logout/ Method Not Allowed (GET): /logout/ Method Not Allowed: /logout/ [04/Feb/2024 17:30:07] "GET /logout/ HTTP/1.1" 405 0 Method Not Allowed (GET): /logout/ Method Not Allowed: /logout/ [04/Feb/2024 17:30:08] "GET /logout/ HTTP/1.1" 405 0 Can I change method to 'POST' instead of 'GET' with built-in LogoutView? Tried to find answers for "Method Not Allowed (GET): /logout/", but all I got was to change form method to 'POST', but I'm still getting 'GET' method. -
badly formed hexadecimal UUID string
from django.db import models import uuid # Create your models here. class Project(models.Model): title = models.CharField(max_length=200) description = models.TextField(null=True, blank=True) demo_link = models.CharField(max_length=2000, null=True, blank=True) source_link = models.CharField(max_length=2000, null=True, blank=True) created = models.DateTimeField(auto_now_add=True) id = models.UUIDField(default=uuid.uuid4, unique=True, primary_key=True, editable=True) I have tried to change uuid and editable argument but it's not working at all. -
getting weird login page for django adming
I am getting this weird login page for Django admin after deploying on server. In my local project everything is looking fine. I checked already if there is any css failing but everything seems fine. if anyone have any idea about this please help me to get rid of it. -
Problems with user login in the system
i have created two custom forms based on UserCreationForm and AuthenticationForm. After registering a user, I want to log him in immediately, and I succeeded. But when I just want to log in, the error {'invalid_login': 'Please enter a correct %(username)s and password. Note that both fields may be case-sensitive.', 'inactive': 'This account is inactive.'} even if all the entered data is correct. models.py class User(AbstractUser): profile_image = models.ImageField(upload_to='accounts/images', default='default/user.jpg', blank=True, null=True) address = models.CharField(max_length=130, null=True, blank=True) date_of_birth = models.DateField(null=True, blank=True) def __str__(self) -> str: return f"{self.username}, {self.email}" forms.py class LoginForm(AuthenticationForm): class Meta: model = User fields = ['username', 'password'] labels = { 'username': "Username", 'password': 'Password' } views.py class LoginView(View): def get(self, request): form = LoginForm() return render(request, 'accounts/login.html', {'form': form}) def post(self, request): form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') user = authenticate(username=username, password=password) if user is not None: login(request, user) print(f"User {username} login successfully.") return redirect('blog:index') print(f"Form errors: {form.error_messages}") return render(request, 'accounts/login.html', {'form': form}) template login.html {% extends 'base.html' %} {% block title %} Login user {% endblock %} {% block content %} <div> <form action="" method="post"> {% csrf_token %} {{ form }} <br> <button type="submit">Log in</button> </form> </div> {% endblock %} -
How do I fix my link in modal class on Bootstrap 5?
I have a template to show posts and each post has post.id. Also there is a button to open modal and "yes" button must delete post with post.id that I clicked. But when I do this it deleting the first post on current page instead of the right one I clicked before. ... <div class="col-md-9"> {% for post in page %} <div class="card-body"> <p class="card-text p-2"> <a class="link text-dark" href="/profile/{{post.author.username}}/"><strong class="d-block text-dark">@{{profile_user.username}}</strong> </a> {{post.text}} {% load thumbnail %} {% thumbnail post.image "960x339" crop="center" upscale=True as im %} <img class="card-img" src="{{ im.url }}"> {% endthumbnail %} </p> <div class="d-flex justify-content-between align-items-center"> <div class="btn-group"> <a class="btn btn-sm text-muted" href="/profile/{{profile_user.username}}/{{post.id}}/" role="button"> ... </a> {% if user.username == profile_user.username %} <a class="btn btn-sm text-muted" href="/profile/{{profile_user.username}}/{{post.id}}/edit" role="button">...</a> <!-- Button trigger modal --> <button type="button" class="btn btn-sm text-muted" data-bs-toggle="modal" data-bs-target="#exampleModal"> ... </button> <!-- Modal --> <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h1 class="modal-title fs-5" id="exampleModalLabel">Delete post?</h1> <button type="button" class="btn btn-sm text-muted" data-bs-dismiss="modal" aria-label="Close">...</button> </div> <div class="modal-footer"> <button type="button" class="btn btn secondary" data-bs-dismiss="modal">NO</button> <a role="button" class="btn btn-primary" href="/profile/{{profile_user.username}}/{{post.id}}/delete">YES</a> <!-- TODO Fix id problem--> </div> </div> </div> </div> {% endif %} </div> <small class="text-muted">{{post.pub_date}}</small> </div> </div> {% endfor %} ... I … -
No handlers could be found for logger "cuckoo"
Error I am running the Cocosandbox project. But I get this error when running Coco command Oops! Cuckoo failed in an unhandled exception! Sometimes bugs are already fixed in the development release, it is therefore recommended to retry with the latest development release available https://github.com/cuckoosandbox/cuckoo If the error persists please open a new issue at https://github.com/cuckoosandbox/cuckoo/issues === Exception details === Cuckoo version: 2.0.7 OS version: posix OS release: Ubuntu 22.04 jammy Python version: 2.7.18 Python implementation: CPython Machine arch: x86_64 Modules: alembic:1.0.10 androguard:3.0.1 argparse:1.2.1 attrs:21.4.0 beautifulsoup4:4.5.3 capstone:3.0.5rc2 cffi:1.15.1 chardet:2.3.0 click:6.6 colorama:0.3.7 configparser:4.0.2 contextlib2:0.6.0.post1 cryptography:3.3.2 cuckoo:2.0.7 django-extensions:1.6.7 django:1.8.4 dpkt:1.8.7 ecdsa:0.18.0 egghatch:0.2.3 elasticsearch:5.3.0 enum34:1.1.10 flask-sqlalchemy:2.4.0 flask:0.12.2 functools32:3.2.3.post2 future:0.18.3 gevent:1.2.2 greenlet:2.0.2 httpreplay:0.2.6 idna:2.10 importlib-metadata:2.1.3 ipaddress:1.0.23 itsdangerous:1.1.0 jinja2:2.9.6 jsbeautifier:1.6.2 jsonschema:3.2.0 mako:1.1.6 markupsafe:1.1.1 olefile:0.43 oletools:0.51 pathlib2:2.3.7.post1 peepdf:0.4.2 pefile2:1.2.11 pillow:3.2.0 pip:20.3.4 pycparser:2.21 pycrypto:2.6.1 pyelftools:0.24 pyguacamole:0.6 pymisp:2.4.106 pymongo:3.0.3 pyopenssl:21.0.0 pyrsistent:0.16.1 python-dateutil:2.4.2 python-editor:1.0.4 python-magic:0.4.12 python:2.7.18 pythonaes:1.0 requests:2.13.0 roach:0.1.2 scandir:1.10.0 scapy:2.3.2 setuptools:44.1.1 sflock:0.3.10 six:1.16.0 sqlalchemy:1.3.3 tlslite-ng:0.6.0 typing:3.10.0.0 unicorn:1.0.1 urllib3:1.26.18 wakeonlan:0.2.2 werkzeug:1.0.1 wheel:0.37.1 wsgiref:0.1.2 yara-python:3.6.3 zipp:1.2.0 No handlers could be found for logger "cuckoo" -
Django TypeError: fromisoformat: argument must be str
enter image description here class UserConfirmation(BaseModel): TYPE_CHOICES = ( (VIA_PHONE, VIA_PHONE), (VIA_EMAIL, VIA_EMAIL) ) code = models.CharField(max_length=4) verify_type = models.CharField(max_length=31, choices=TYPE_CHOICES) user = models.ForeignKey('users.User', models.CASCADE, related_name='verify_codes', db_constraint=False) expiration_time = models.TimeField(null=True) is_confirmed = models.BooleanField(default=False) def __str__(self): return str(self.user.__str__()) def save(self, *args, **kwargs): if not self.pk: if self.verify_type == VIA_EMAIL: self.expiration_tme = datetime.now() + timedelta(minutes=EMAIL_EXPIRE) else: self.expiration_tme = datetime.now() + timedelta(minutes=PHONE_EXPIRE) super(UserConfirmation, self).save(*args, **kwargs) -
Django single login page for both rest_framework and admin console
I am making a Django application which uses rest_frameworks (under urlpattern '/api') and the admin console (for user and group management, under urlpattern '/admin'). Currently they both have their own login page. I want both of them to use the same login page (a single login URL), and if the user successfully logs in, then if it is a superuser redirect to the admin console, and if not a superuser then redirect to '/foo'. I know you can insert a url pattern above the admin.site.urls to override its login (and logout) url patterns, but I want the login page to be '/login' not '/admin/login'. -
TemplateDoesNotExist at /home/ internal server error Django
my html file isn't displaying. folder path: D:\New folder\core\core\home View.py file in home app D:\New folder\core\core\home urls.py file in home app D:\New folder\core\core urls.py file in core project D:\New folder\core\core Settings.py file in core project index.html file in template which is in template file Tried every step help me solving this