Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Task celery succeeded in 0.09006300568580627s: None
I have a project where I use Django with celery and I noticed when a task has errors I always have that message : Task celery succeeded in 0.09006300568580627s: None So I understand the task is finished but sometimes there are errors and I have succeeded which is for me not true. Besides, I have None and no informations. Do you know if it is possible to get more informations instead of None ? Thank you very much ! -
DJ_REST_AUTH Error : NameError: name 'dj_rest_auth' is not defined
I have installed dj-rest-authfor Token Authentication. My urls.py: from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('customer/', include('customer.urls')), #new path('api-auth/', include('rest_framework.urls')), # new path('customer/dj-rest-auth/', include(dj_rest_auth.urls)), ] Settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'customer', 'rest_framework.authtoken', # new 'dj_rest_auth', ] My Requirements.txt: asgiref==3.4.1 dj-rest-auth==2.1.11 Django==3.2.7 django-rest-auth==0.9.5 djangorestframework==3.12.4 psycopg2-binary==2.9.1 pytz==2021.1 six==1.16.0 sqlparse==0.4.2 But when I am trying to runserver It's giving me NameError: name 'dj_rest_auth' is not defined What am I doing wrong? -
How to retry a task if it's the last retry in celery?
I'm writing a send_mail task, which, if another instance of it is running, has to retry after 2 seconds. The number of retries is limited by 300. If there is a running instance and the last retry is currently running - the function has to send the mail, regardless of the other instance is running. If it fails - asynchronous recording to the log. How to implement the following with Celery? -
Nginx fastcgi_cache_path file naming / design / best practice
I'm trying to configure Nginx as a reverse proxy "properly". So many documentation, so many website advising bad practices... well I've come up with this: the folder conf.d was created by Nginx to include once all files in it. That's where I've made global_custom.conf In conf.d/global_custom.conf I define all the "cache" type that might be used like this: fastcgi_cache_path /var/run/nginx-cache-wordpress levels=1:2 keys_zone=WORDPRESS:50m max_size=10g inactive=60m use_temp_path=off; fastcgi_cache_path /var/run/nginx-cache-django levels=1:2 keys_zone=DJANGO:50m max_size=10g inactive=60m use_temp_path=off; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; I did nginx-cache with multiple aliases and multiple files like I do /var/run/nginx-cache-wordpress, /var/run/nginx-cache-django and then use them like this: server { server_name django.myserver.com fastcgi_cache DJANGO; # blabla } server { server_name wordpress.myserver.com fastcgi_cache WORDPRESS; # blabla } Is it a good practice, if not, how should I do? I can't find any valuable information for a good sample for a good nginx reverse proxy configuration. -
remove {} from OrderedDict
I have an OrderedDict given as result in my function in below: [ { "name": "tetst", "date": [ { "dates": "20/09/2021 15:14:00", "id": 146 }, { "dates": "20/09/2021 15:14:00", "id": 145 } ] }, {} ] I want remove {} objects from Dict and ı want to get dict like: [ { "name": "tetst", "date": [ { "dates": "20/09/2021 15:14:00", "id": 146 }, { "dates": "20/09/2021 15:14:00", "id": 145 } ] } ] -
Sentry delete issues (logs)
I'm running Self-Hosted Sentry 21.6.1 on-premise with docker-compose up -d and Django database is getting full very fast because of large number of collected issues. 3,218,732 Total Errors in 8 days. Filesystem Size Used Avail Use% Mounted on /dev/sda1 504G 130G 349G 28% / How can I delete old issues (let's say older than 30 days) from the database or set new issues to overwrite the old ones once the disk is full? Or is there a better solution for this problem? -
Data is not fetching from database in python django
I have saved some lists in the database and i am fetching posts to show in list.html. But data is not Showing. main Urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('blog/', include('blog.urls',namespace='blog')), ] app url.py from django.urls import path from . import views app_name = 'blog' urlpatterns = [ path('',views.post_list,name='post_list'), path('<int:year>/<int:month>/<int:day>/<slug:post>/',views.post_detail,name='post_detail'), ] Views.py from django.core import paginator from .models import Post from django.shortcuts import render, get_list_or_404 def post_list(req): posts = Post.published.all() return render(req,'blog/post/list.html',{'posts':posts}) def post_detail(req, year,month,day,post): post = get_list_or_404(Post,slug=post,status='published',publish__year=year,publish__month=month,publish__day=day) return render(req,'blog/post/detail.html', {'post':post}) -
save formset data to which data is passed from a form
I can't save multiple objects in the db, I created the formset but at the time of saving it only saves me the first compiled object if request.method == "POST": schede_form = SchedeForm(request.POST, prefix='schede') gruppi_formset = gruppiFormSet(request.POST, prefix='gruppi') if schede_form.is_valid(): schedaName = schede_form.cleaned_data['nome_scheda'] scheda = schede_form.save(commit = False) scheda.utente = request.user scheda.save() if gruppi_formset.is_valid(): for gruppo in gruppi_formset: gruppi_instance = gruppo.save(commit = False) gruppi_instance.gruppi_scheda = Schede.objects.get(nome_scheda=schedaName) gruppi_instance.save() -
django allauth and api call to eveonline
I have successfully added django-allauth to my bare application. What I want to do now is call API, but I do not know how. I use eve online provider. It returns a auth code to be used to exchange it for bearer token, just as many other applications. How do I get a bearer token from django-allauth tables or utilities to make a call? What I understand, I need to log in first and than make a call to api to get bearer token. The EVE Online website after login redirects to {SERVER}/callback?code={CODE_FROM_LOGIN} curl -XPOST -H "Content-Type:application/json" -H "Authorization:Basic {CODE_FROM_LOGIN}" -d '{"grant_type":"authorization_code", "code":"{APPLICATION_CALL"}' https://login.eveonline.com/oauth/token -
LDAP Connection at nginx.conf
I declareted LDAP settings in settings.py (i have an django app). This is how ut works now: AUTH_LDAP_SERVER_URI = 'ldap://my_url' AUTH_LDAP_BIND_DN = f'uid{LDAP_BIND_USER}, cn=bind_user,ou=service accounts,dc=something,dc=something_else' AUTH_LDAP_BIND_PASSWORD = LDAP_BIND_PASSWORD AUTH_LDAP_USER_SEARCH = LDAPSearch( 'cn=users,dc=something,dc=something_else,dc=ac,dc=uk', ldap.SCOPE_SUBTREE, '(uid=%(user)s)') AUTH_LDAP_GROUP_SEARCH = LDAPSearch( 'OU=Groups,dc=something,dc=something_else,dc=ac,dc=uk', ldap.SCOPE_SUBTREE, '(objectClass=groupOfNames)') AUTH_LDAP_GROUP_TYPE = GroupOfNamesType() i need to transfer this piece of code to nginx.conf. I know about nginx_ldap_auth, but I can't undestand how to use AUTH_LDAP_GROUP_SEARCH and SCOPE_SUBTREE there. Now i have something like that: proxy_set_header X-Ldap-URL "ldap://my_url"; proxy_set_header X-Ldap-BindDN "uid=LDAP_BIND_USER, cn=bind_user,ou=service accounts,dc=something,dc=something_else"; proxy_set_header X-Ldap-BindPass LDAP_BIND_PASSWORD; -
Django Radio Buttons in Columns
I have a radio button with n choices, the choices themselves being picked up from a Database. Forms.py class FilterForm(forms.Form): DressTable = mydb['DressInfo'] ColorTable =mydb['ColorInfo'] dress = forms.ChoiceField(widget=forms.RadioSelect,choices=[(obj['subcatvalue'], obj['subcategory']) for obj in DressTable.find({})]) color = forms.ChoiceField(widget=forms.RadioSelect,choices=[(obj['subcatvalue'], obj['subcategory']) for obj in ColorTable.find({})]) This is my views.py def dayview(request): form = FilterDaywiseNew() return render(request, 'searchpage.html',{'form': form}) This is my template file searchpage.html <form method="post" action="SearchDisplay" id="searchFilter"> <div id="checkbox"> <ul> {{ form.dress }} </ul> </div> <div id="checkbox"> <ul> {{ form.color}} </ul> </div> </form> I want the choices to be displayed as radio buttons in two columns per row, equally spaced. I have tried crispy options, but that is for the entire form I guess. How do I get the desired result like shown : -
Django migrations doens't recognize change in IntegerChoices
I have the following model: class Job(models.Model): class Status(models.IntegerChoices): OPEN = 1 DECLINED = 2 ACCEPTED = 3 and for consistency, I'd like the change the capitalization to title cases: class Job(models.Model): class Status(models.IntegerChoices): Open = 1 Declined = 2 Accepted = 3 Django does error when I change this, but doesn't recognize the changes when I run python manage.py makemigrations. I've had troubles with this before, as these changes can go unnoticed when other changes have been applied, crashing the app in the future. I've tried to find an answer in the docs & stack, but with no luck. What can I do to properly propagate these changes? -
Making an Order button on Details page work-Django
i am developing my ecommerce platform using django. I have implemented the order functionalities. When the user click s on teh add to cart, it works okay. But when he cicks on the product, to get more details, when he wants to click now the add to cart button, it doesnt respond. I have given it the same functionality like other button before coming to details page of single product. The problems seemed to be teh place where it doesnt find teh correct path. How can i implement that one button. Here is my views.py def processOrder(request): transaction_id = datetime.datetime.now().timestamp() data = json.loads(request.body) print(data) if request.user.is_authenticated: customer = request.user order, created = Order.objects.get_or_create( customer=customer, complete=False) total = order.get_cart_totals order.transaction_id = transaction_id if total == order.get_cart_totals: order.complete = True order.save() if order.shipping == True: print("Wrong") ship = ShippingAddress( customer=customer, order=order, firstname=data['shipping']['firstname'], lastname=data['shipping']['lastname'], address=data['shipping']['address'], city=data['shipping']['city'], zipcode=data['shipping']['zipcode'] ) ship.save(force_insert=True) else: print("User doesn't exist") print('Data:', request.body) return JsonResponse('Payment Submitted', safe=False) Here is my model.py class Order(models.Model): customer = models.ForeignKey( User, on_delete=models.SET_NULL, null=True, blank=True) date_ordered = models.DateTimeField(auto_now_add=True) complete = models.BooleanField(default=False) transaction_id = models.CharField(max_length=100, null=True) def __str__(self): return str(self.id) @property def shipping(self): shipping = False orderItems = self.orderitem_set.all() for i in orderItems: if i.product.digital == False: … -
ERREUR: la relation « map_place » n'existe pas [closed]
Bonjour, je suis en train d'essayer d'adapter cet exemple pour réaliser une application géographique Django : https://github.com/simon-the-shark/django-mapbox-location-field#admin-interface-usage Cependant, lorsque je clique sur le bouton pour ajouter un nouveau lieu j'obtiens cette erreur mais je ne comprends pas à quoi elle est due (sûrement postgreSQL mais je ne vois pas comment faire) : Voici mes éléments : map\models.py from django.db import models from mapbox_location_field.models import LocationField, AddressAutoHiddenField class Place(models.Model): location = LocationField( map_attrs={"style": "mapbox://styles/mightysharky/cjwgnjzr004bu1dnpw8kzxa72", "center": (3.15, 46.883331), "zoom": 3}) created_at = models.DateTimeField(auto_now_add=True) address = AddressAutoHiddenField() map\urls.py from django.urls import re_path from .views import AddPlaceView, ChangePlaceView, PlacesView urlpatterns = [ re_path("^$", AddPlaceView.as_view(), name="add"), re_path("^places/(?P<pk>[0-9]+)/$", ChangePlaceView.as_view(), name="change"), re_path("^index/$", PlacesView.as_view(), name="index"), ] map\views.py from django.views.generic import CreateView, UpdateView, ListView from .models import Place class AddPlaceView(CreateView): model = Place template_name = "map/place_form.html" success_url = "/index/" fields = ("location", "address") class ChangePlaceView(UpdateView): model = Place template_name = "map/place_form.html" success_url = "/index/" fields = ("location", "address") class PlacesView(ListView): model = Place template_name = "map/index.html" ordering = ["-created_at", ] templates\map\index.html {% block content %} <a class="btn btn-success text-ligt btn-lg btn-block" href="{% url 'add' %}">ADD NEW PLACE</a> <h2 class="display-5">Places:</h2> {% for place in object_list %} <div class="row" style="margin:5px;"> <div class="col"> {{ place.location}}</div> <div class="col"> {{ place.address}}</div> <div class="col"><a href="{% … -
How to filter a model when using forms in DJango
Here i need to display type_of_entry based on the client but i am getting type_of_entry of all the clients views.py def item_view(request): client = request.user.client log_form = ItemsLogForm() Here is my forms forms.py class ItemsLogForm(forms.ModelForm): class Meta: model = JobItemsLogs fields = ('type_of_entry', 'log' ) here is my models.py class ServiceType(models.Model): name = models.CharField(max_length=100,default='Project',null=True, blank=True) client = models.ForeignKey(Client) class JobItemsLogs(models.Model): client = models.ForeignKey(Client) type_of_entry = models.ForeignKey("core.ServiceType", blank=True, null=True) log = models.TextField(blank=True) template.html <form class="form-horizontal" action=" "> {% csrf_token %} <div class="control-group"> <div class="controls"> {{log_form.as_p}} </div> </div> </form> Lets us consider my database table for ServiceType id name client_id 1 Electrical 1 2 Plumbing 3 3 Construction 3 database table for JobItemsLogs id type_of_entry_id log 1 2 something Now here i need to display type_of_entry (i.e servicetypes) of client_id = 3 (Plumbing, Construction) for particular log nut instead its displaying type_of_entry of client_id = 1 also (means its showing Electrical, Plumbing, Construction) Please help me to code so that i show type_of_entry of client =3 only -
Problem integrating React with errors in fetching data from backend
This is my first attempt to do full stack web development using Django as back end and react js as frontend I am following a tutorial but have got stuck at a final stage the codes are as under if some one can help me out the error list is as under it is failing to update will apreciate Unhandled Rejection (TypeError): Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. From web page inspect 18 | 19 | class APIServiece { 20 | static UpdateArticle(article_id, body) { 21 | return fetch(' http://127.0.0.1:8000/api/articles/${article_id}/', { | ^ 22 | Method: 'PUT', 23 | headers: { 24 | 'Content-Type': 'application/json', App.js file enter code here import './App.css' import { useState, useEffect } from 'react' import ArticleList from './Components/ArticleList' import Form from './Components/Form' function App() { const [articles, setArticles] = useState([]) const [editArticle, setEditArticle] = useState(null) useEffect(() => { fetch(' http://127.0.0.1:8000/api/articles/', { Method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: 'Token 7654d578b64711481eea3345caf0b90646b8881f', }, }) .then((resp) => resp.json()) .then((resp) => setArticles(resp)) .catch((error) => console.log(error)) }, []) const editBtn = (article) => { setEditArticle(article) } return ( <div className='App'> <h1>React Js</h1> <ArticleList articles={articles} editBtn={editBtn} /> {editArticle ? <Form article={editArticle} /> : null} … -
File descriptor doesn't contain backend url django
I'm trying to access a file from React but the django FileDescriptor doesn't contain backend URL. Instead of 127.0.0.1:8000/quizResults/rezultate/Ene_Mihai_CYMED/index.png-2021-09-20-102619 i'm getting only /quizResults/rezultate/Ene_Mihai_CYMED/index.png-2021-09-20-102619 and, when i'm trying to access the files from react using a map, it doesn't work because <a href='/quizResults/rezultate/Ene_Mihai_CYMED/index.png-2021-09-20-102619'/> will open the page 127.0.0.1:3000/quizResults/rezultate/Ene_Mihai_CYMED/index.png-2021-09-20-102619 which is the frontend url and it doesn't exists. urls.py: urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) settings.py MEDIA_ROOT = os.path.join(BASE_DIR,'quizResults') MEDIA_URL = '/quizResults/' I don't know if it matters, but that's in Models.py def upload_to(instance,filename): return 'rezultate/{firstname}_{lastname}_{organizatie}/{filename}-{date}'.format(firstname=instance.user.nume,organizatie=instance.user.organizatie,lastname=instance.user.prenume,filename=filename, date=instance.date.strftime("%Y-%m-%d-%H:%M:%S")) class quizPDF(models.Model): user = models.ForeignKey(User, related_name='UserPDF', on_delete=models.CASCADE) date = models.DateTimeField(auto_now_add=True) pdf = models.FileField(_("PDF"),upload_to=upload_to) -
Module 'socket' has no attribute 'AF_UNIX'
I'm trying to run an OLD (2018) Django project on localhost. However, when I use: python manage.py runserver 192.168.23.12:8000 I get: line 600, in connect sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) AttributeError: module 'socket' has no attribute 'AF_UNIX' I'm using a Window machine and I tried also to change AF_UNIX to AF_INET getting: AF_INET address must be tuple, not str -
Django Form with validation state for unique
I try to add a validation state like "this already exist." (like registration form, see picture) just under my form input. But when I submit my form i'v this error 'UNIQUE constraint failed' this is my code model class Company(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) siret = models.CharField(max_length=50, unique=True) forms class CheckoutForm(forms.Form): siret = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder': 'Ton SIRET'})) class Meta: model = Company fields = ('siret') def clean(self): siret = cleaned_data.get('siret') if siret: raise forms.ValidationError("This siret exist.") else: return siret view def post(self, request, *args, **kwargs): form = CheckoutForm(self.request.POST) if form.is_valid(): siret = form.cleaned_data.get('siret') company = Company( user = self.request.user, siret = siret, ) company.save() context = { 'company': company, } return redirect("core:payment") else: messages.info(self.request, "Please fill in the shipping form properly") return redirect("core:checkout") template {% load crispy_forms_tags %} <main> <div class="container wow fadeIn"> <h2 class="my-5 h2 text-left">Checkout form</h2> <div class="row"> <div class="col-md-8 mb-4"> <div class="card"> <form method="post" class="card-body"> {% csrf_token %} {{ form|crispy }} <button class="btn btn-primary" id="checkout-button" data-secret="{{ session_id }}"> Checkout </button> </form> </div> </div> Thanks a lot -
from Google import Create_Service ModuleNotFoundError: No module named 'Google'
I'm trying to use Gmail api in python to send email but I cant get past importing the Google module despite using "pip install --upgrade google-api-python-client" or "pip install google". However pip freeze shows: asgiref==3.3.4 beautifulsoup4==4.10.0 cachetools==4.2.2 certifi==2021.5.30 cffi==1.14.6 charset-normalizer==2.0.6 dj-database-url==0.5.0 Django==3.2.3 django-ckeditor==6.1.0 django-ckeditor-5==0.0.14 django-heroku==0.3.1 django-js-asset==1.2.2 django-phone-field==1.8.1 django-tawkto==0.3 **google==3.0.0** google-api-core==2.0.1 google-api-python-client==2.21.0 google-auth==2.1.0 google-auth-httplib2==0.1.0 google-auth-oauthlib==0.4.6 google-cloud==0.34.0 google-cloud-bigquery==2.26.0 google-cloud-core==2.0.0 google-cloud-storage==1.42.2 google-cloud-vision==2.4.2 google-crc32c==1.1.2 google-resumable-media==2.0.2 googleapis-common-protos==1.53.0 grpcio==1.40.0 gunicorn==20.1.0 httplib2==0.19.1 idna==3.2 oauthlib==3.1.1 packaging==21.0 Pillow==8.2.0 proto-plus==1.19.0 protobuf==3.18.0 psycopg2==2.8.6 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycparser==2.20 pyparsing==2.4.7 python-decouple==3.4 pytz==2021.1 requests==2.26.0 requests-oauthlib==1.3.0 rsa==4.7.2 six==1.16.0 soupsieve==2.2.1 sqlparse==0.4.1 uritemplate==3.0.1 urllib3==1.26.6 whitenoise==5.2.0 my code: from Google import Create_Service import base64 from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText CLIENT_SECRET_FILE = 'client_secret.json' API_NAME = 'gmail' API_VERSION = 'v1' SCOPES = ['https://mail.google.com/'] service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES) Any help would be greatly appreciated -
How to use UUIDField for SQLite?
How can I generate a UUIDField that works for SQLite? I want to use SQLite instead of Postgres for my tests so they run faster. # settings.py DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", # ... } } # Tests use sqlite instead of postgres import sys if ( "test" in sys.argv or "test_coverage" in sys.argv ): # Covers regular testing and django-coverage DATABASES["default"]["ENGINE"] = "django.db.backends.sqlite3" However, I don't seem to be able to create a UUID that fits Django's UUIDField for SQLite: A field for storing universally unique identifiers. Uses Python’s UUID class. When used on PostgreSQL, this stores in a uuid datatype, otherwise in a char(32). The following doesn't work even though the uuid value is 32 chars: # models.py class Item(models.Model): uuid = models.UUIDField() # tests.py uuid = str(uuid.uuid4()).replace("-", "") Item.objects.create(uuid=uuid) I get this error: django.db.utils.InterfaceError: Error binding parameter 4 - probably unsupported type. -
Google Analytics Measurement Protocol can not track cart addition and product view
I have implemented measurement protocol in my project. I can successfully track purhcases, checkouts, pageviews and refunds. For example sending this data with some additions from function outside I can track purchase event. data = { 't': 'pageview', 'ti': '123123', 'tr': 1510, 'ts': 10, 'cu': 'GEL', 'pa': 'purchase', 'cid': request.COOKIES.get('client_id'), 'pr1id': '123123', 'pr1nm': 'iPhoneXR', 'pr1ca': 'Smartphones', 'pr1pr': 500, 'pr1br': 'Apple', 'pr1va': 'RED 128 GB', 'pr1qt': 2 } now I am struggling to track product views and cart additions and I have gone through whole measurement protocol parameters and common hits that was shown in documentation but could not find solution. Any ideas how can I track cart additions and product views? -
how to list sub fields of model fields in Django ListView?
Under my model work_allocation I have a field called activity_name. Fort all activity_name there are sub fields associated as shown In the views.py I have written a simple class based view to list the activity_task(get_task_list), which is working fine. But I am not able to see the associated sub fields. Not sure what modification am I supposed to make for this to happen. Below are my project details: models.py from django.db import models class Status_Code(models.Model): Types = models.CharField(max_length=50, blank=True) def __str__(self): return self.Types class Assignee_Name(models.Model): emp_name = models.CharField(max_length=50, blank=True) def __str__(self): return self.emp_name class Priority(models.Model): priority = models.CharField(max_length=50, blank=True) def __str__(self): return self.priority class work_allocation(models.Model): activity_name = models.CharField(max_length=100) JIRA_tkt = models.CharField(max_length=100) Assignee_name = models.ForeignKey(Assignee_Name, on_delete=models.CASCADE) Status_code = models.ForeignKey(Status_Code, on_delete=models.CASCADE) Description = models.TextField() Planned_start_date = models.DateField(auto_now_add=True) Planned_end_date = models.DateField(auto_now_add=True) actual_start_date = models.DateField(auto_now_add=True) actual_end_date = models.DateField(auto_now_add=True) priority = models.ForeignKey(Priority,on_delete=models.CASCADE) def __str__(self): return self.activity_name views.py def createTask(request): if request.method == 'POST': form = Work_alloc_Form(request.POST) if form.is_valid(): data_to_db = work_allocation() data_to_db.activity_name = form.cleaned_data['activity_name'] data_to_db.JIRA_tkt = form.cleaned_data['JIRA_tkt'] data_to_db.Assignee_name = form.cleaned_data['Assignee_name'] data_to_db.Status_code = form.cleaned_data['Status_code'] data_to_db.Planned_start_date = form.cleaned_data['Planned_start_date'] data_to_db.Planned_end_date = form.cleaned_data['Planned_end_date'] data_to_db.actual_start_date = form.cleaned_data['actual_start_date'] data_to_db.actual_end_date = form.cleaned_data['actual_end_date'] data_to_db.Description = form.cleaned_data['Description'] data_to_db.priority = form.cleaned_data['priority'] data_to_db.save() messages.success(request, f'Profile has been updated successfully') return redirect('/home') else: messages.error(request, AttributeError) else: form … -
Django certbot installation
I am facing a problem when i try to install certbot in my Django project. I follow the instructions from the documentation https://certbot-django.readthedocs.io/en/latest/ and it occurs an error cannot import create_auth_header. Could anyone help? -
rewrite AND/OR query in django
I am having difficulty to rewrite AND/OR query in django. Parantheses is banned in django template.I tried using custom tags for this but it doesn't work as expected.Does anyone know how to rewrite a query like this for django templates and for custom tag both .So, I will know where i want wrong. for i in k: if (i.first == a and i.second == b) or (i.first == b and i.second == a): {some code}