Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
What is `message.reply_channel` in Django Channels?
What is message.reply_channel in Django Channels? def connect(self, message, **kwargs): """ Perform things on connection start """ self.message.reply_channel.send({"accept": True}) pass -
Toggle function not working the div element doesn't appear
I am doing a project on django and I am working on a template and I want the div element to toggle between hiding and showing but it isn't working. I took the function from a working template but for some reason it doesn't work in django project. I just can't figure a solution for the problem. Here is the template: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>Admin Home Page</title> {% load staticfiles %} <!-- Bootstrap core CSS --> <link href="{% static 'Boards/Homepage/vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link href='https://fonts.googleapis.com/css?family=Sofia' rel='stylesheet'> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!-- Custom styles for this template --> <link href="{% static 'Boards/Homepage/css/modern-business.css' %}" rel="stylesheet"> <style> #ManageUsers{ display :none; } </style> <script type="text/javascript"> function ToggleHide(id) { var divelement = document.getElementById(id); if(divelement.style.display === 'none') divelement.style.display = 'block'; else divelement.style.display = 'none'; } </script> </head> <body> <!-- Navigation --> <nav class="navbar fixed-top navbar-expand-lg fixed-top" style="background-color: #0b0849;"> <div class="container"> <a class="navbar-brand" href="#" style="margin-left: -120px; font-family: 'Sofia';font-size: 22px;" ><i class="fa fa-flash" style="font-size:24px"></i> Drello Admin</a> <div class="search-container"> <form action="/action_page.php"> <input type="text" placeholder="Search.." name="search"> <button type="submit"><i class="fa fa-search"></i></button> </form> </div> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> … -
Remove successText in django-inplaceedit app
Is there a way to remove the success text which is showing after the inline edit is done. Also, I want to save my inline changes by pressing Enter. Is there any easy way to make this? -
Deploying PostgreSQL database with Kubernetes
I am confused when it comes to deploying PostgreSQL database of my Django application with Kubernetes. Here is how I have constructed my deployment-definition.yml file: apiVersion: apps/v1beta1 kind: Deployment metadata: name: postgres spec: replicas: 1 selector: matchLabels: app: postgres-container template: metadata: labels: app: postgres-container tier: backend spec: containers: - name: postgres-container image: postgres:9.6.6 env: - name: POSTGRES_USER valueFrom: secretKeyRef: name: postgres-credentials key: user - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: postgres-credentials key: password - name: POSTGRES_DB value: agent_technologies_db ports: - containerPort: 5432 volumeMounts: - name: postgres-volume-mount mountPath: /var/lib/postgresql/data volumes: - name: postgres-volume-mount persistentVolumeClaim: claimName: postgres-pvc - name: postgres-credentials secret: secretName: postgres-credentials What I dont understand is this. If I specify (like i did) an existing image of PostgreSQL inside spec of Kubernetes Deployment object, how do I actually run my application? What do I need to specify as HOST inside my settings.py file? Here is what my settings.py file looks like for now: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'agent_technologies_db', 'USER': 'stefan_radonjic', 'PASSWORD': 'cepajecar995', 'HOST': 'localhost', 'PORT': '', } } It is constructed this way because I am still designing the application and I do not wanna deploy it to Kubernetes cluster just yet. But when I do, what … -
Deploying Django Channels: how to keep Daphne running after exiting shell on web server
As practice, I'm trying to deploy Andrew Godwin's multichat example with Django Channels 2.1.1 on DigitalOcean Ubuntu 16.04.4. However, I don't know how to exit the Ubuntu server without Channels' Daphne server stopping. Right now, almost my entire familiarity with deployment comes from this tutorial, and that's how I've deployed the site. But according to Channels' documentation, I have to run one of these three in production to start Daphne: daphne myproject.asgi:application daphne -p 8001 myproject.asgi:application daphne -b 0.0.0.0 -p 8001 myproject.asgi:application So, in addition to following the DigitalOcean tutorial, I ran these also. The third one worked for me and the site ran well. However, if I exit shell on DigitalOcean, Daphne stops too. The tutorial has gunicorn access a sock file (--bind unix:/home/sammy/myproject/myproject.sock), and in my research so far I've seen on a few sites published before 2018 that somehow somewhere a daphne.sock file is generated. So, I guess Channels deploys similarly? But I haven't seen any details about how this is done. How do I deploy the multichat example so I can exit the Ubuntu web server without Daphne stopping? -
Django REST Framework ManyToMany Error
When I add a serializer for the ManyToMany Field, it displays the results on the REST API but when I post data then the serializer gives is_valid() as false. When I mention them as JSONFields, then the serializer is_valid() is True and the data gets saved, but upon viewing the api on localhost it gives the following error - 'Object of type 'ManyRelatedManager' is not JSON serializable' class B(models.model): name = models.CharField() class A(models.model): b = models.ManyToManyField(B) class BSerializer(serializer.modelSerializer): class Meta: model=B fields = '__all__' class ASerializer(serializer.ModelSerializer): b = BSerializer(many=true) def save(self): b_data = self.validated_data.pop('b') a = A.objects.create(**validated_data) b_instance = B.objects.get(name=b_data['name']) a.add(b_instance) This gives perfect results on the REST Framework UI when hit with http://localhost:8000/a/REST but when I hit the POST request on postman with the data {'b':[{'name':'foo'}]} the serializer fails to is_valid() function. But when I change the code to this: class ASerializer(serializer.ModelSerializer): b = serializer.JSONField() def save(self): b_data = self.validated_data.pop('b') a = A.objects.create(**validated_data) b_instance = B.objects.get(name=b_data['name']) a.add(b_instance) The postman hit saves the data for A and then adds the b instance to it. It is seen when I see the data in python shell. But upon viewing it on the REST Framework UI, it gives the follwoing error: … -
Django template URL that sends varible throws error [duplicate]
This question already has an answer here: No reverse Match error: cannot find the slug or the primary key I'm passing in 1 answer I want to pass two variables via my URL. But it is showing error and I can not find any clue. URL in template: <td><a href="{% url 'viewDetailOfsupplyrequest' request.user.id i.id_supplier %}">View Details</a></td> URL in urls.py : url(r'^viewDetailOfsupplyrequest/<employeeID>/<supplierID>/',employee.views.viewDetailOfsupplyrequest,name="viewDetailOfsupplyrequest"), And it shows this error : Reverse for 'viewDetailOfsupplyrequest' with arguments '(3, '2')' not found. 1 pattern(s) tried: ['viewDetailOfsupplyrequest/<employeeID>/<supplierID>/'] -
'ProgrammingError at' When trying to edit my register data from my MSSQL
My Admin Interface Error I got when clicking the Change Button Under SWCTOLLROADS at the row of Employee tbls This is my Connection I Successfully run this command "python manage.py inspectdb Users > models.py" and do some configuration until my django run successfully. When I try to view the data of my tables is come to an error "ProgrammingError at /admin/SWCTollRoads/employeetbl/ ('42S02', "[42S02] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name 'Employee_Tbl'. (208) (SQLExecDirectW)")" Thanks for the Help. -
Django using a string to filter a model to avoid repetition
I'm trying to repeat myself as little as possible in my code buy have run into a problem. My code looks like this from .models import source def myfunction(): if category1 == True: types=5 b=[None]*types for i in range(0, types): b[i]=source.objects.all().filter(rowdata1='identifier', state=i) elif category2 == True: types=3 b=[None]*types for i in range(0, types): b[i]=source.objects.all().filter(rowdata2='identifier', state=i) . . . return result However I would like to do something like this instead: def myfunction(): if category1 == True: types=5 param='rowdata1' elif category2 == True: types=3 param='rowdata2' b=[None]*types for i in range(0, types): b[i]=source.objects.all().filter(param='identifier', state=i) . . . return result Is there a way to use a string or other structure to use as a filter value to access a model in Django? When i try my example 2 i get a Field error, the first one works. -
ModuleNotFoundError: No module named 'backend' in django-admin
When i start a new project using django-admin startproject anil i get this error: Traceback (most recent call last): File "c:\users\gsrnation\appdata\local\programs\python\python36-32\Lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\gsrnation\appdata\local\programs\python\python36-32\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\gsrnation\Desktop\sp\venv\Scripts\django-admin.exe\__main__.py", line 9, in <module> File "c:\users\gsrnation\desktop\sp\venv\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line utility.execute() File "c:\users\gsrnation\desktop\sp\venv\lib\site-packages\django\core\management\__init__.py", line 317, in execute settings.INSTALLED_APPS File "c:\users\gsrnation\desktop\sp\venv\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__ self._setup(name) File "c:\users\gsrnation\desktop\sp\venv\lib\site-packages\django\conf\__init__.py", line 43, in _setup self._wrapped = Settings(settings_module) File "c:\users\gsrnation\desktop\sp\venv\lib\site-packages\django\conf\__init__.py", line 106, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "c:\users\gsrnation\desktop\sp\venv\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'backend' I have even made a virtualenv but still same error is comming. My django version is Django==2.0.5 and python version is python 3.6.5. I tried running my previous … -
How to make it harder to reverse engineer PyInstaller EXE
i made a Django web app that i'm submitting to my university for a project, i do not want them to use it without my permission, so i created a demo account in the database, and i compressed the app using PyInstaller. now, i want to make it harder to access the code, if the users try to decompress the app. Is there a way to make the app self delete or self sabotage if the user tries to get the pyc's from the exe for example ? Or, a way to encrypt the data before compressing ? or really any other way to not let my uni use my software or at least to make them suffer in order to do so ? Thank You! -
Explain return super().get(request, *args, **kwargs)
Hi I want to understand this line of code: return super().get(request, *args, **kwargs) This line is part of a method in class based view in views.py file , for example class HomePage(TemplateView): template_name = "index.html" def get(self, request, *args, **kwargs): if request.user.is_authenticated: return HttpResponseRedirect(reverse("test")) return super().get(request, *args, **kwargs) If anyone can explain: 1- why I have these parameters: (self, request, *args, **kwargs) in get function? 2- when this method : def get(self, request, *args, **kwargs): will be triggered or called? 3- explain the last line in the get method: ( return super().get(request, *args, **kwargs) step by step. I will be grateful in details because I am still learning.. Thanks a lot -
Returning a html page from a AWS Python lambda function
I currently have a Python lambda function that is returning a JSON object. However rather then getting a white screen with JSON data I was wondering if there is a way to return a html webpage that returns instead of JSON? Currently the return data looks like return { 'statusCode': 200, 'headers': {}, 'body': json.dumps({ 'HOW-TO: ': prompt, 'instanceId': instanceId, 'PUBLIC_IP_ADDRESS': publicIp, 'instanceRegion':Instance_region }) But was curious if there is a way to return an HTML page instead? -
Use 2 views in the same template django
I have 2 views (post and new_payement) and i want to use the form from new_payment inside the post template I tried pointing both the views to the same template but i get an error 'function object is not iterable' I want to get the post.slug variable to use it inside the form but whatever i try doesn't work How can i acheive that models.py class Post(models.Model): title = models.CharField(max_length=255) slug = models.SlugField(max_length=255, unique=True) created = models.DateTimeField(auto_now_add=True) content = models.TextField(default="---") current_price = models.IntegerField(default=0) reduction = models.IntegerField(default=0) original_price = models.IntegerField(default=0) Status = models.CharField(max_length=5, default="✓") img = models.CharField(max_length=255) sold = models.IntegerField(default=0) endday = models.CharField(max_length=30, default="apr 27, 2018 16:09:00") class Meta: ordering = ['-created'] def __unicode__(self): return u'%s'% self.title def get_absolute_url(self): return reverse('Products.views.post', args=[self.slug]) def __str__(self): return self.title class Payment(models.Model): Author = models.CharField(max_length=255) Product = models.CharField(max_length=255) Price = models.IntegerField(default=0) Payment_ID = models.BigIntegerField(default=0) Status = models.CharField(max_length=5, default="X") Review_result = models.CharField(max_length=255, default="Not yet reviewed") created = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['-created'] def __unicode__(self): return u'%s'% self.Status def __str__(self): return self.Status views.py def post(request, slug): return render(request, 'post.html', {'post': get_object_or_404(Post, slug=slug)}) def new_payment(request): template ='payment.html' if request.method == 'POST': form = PayForm(request.POST) if form.is_valid(): form.save() return redirect('index') else: print('form invalid') else: form = PayForm({'Author':request.user.username}) context … -
Overriding Django auto_now in datefiled
Is there a way to pass a date to datafield that overrides auto_now? I want to only use auto_now if a date is not passed. -
No reverse Match error: cannot find the slug or the primary key I'm passing in
I am trying to add links to the change_friend url and view, but I am getting a reverse match because Im apparently not passing in the right arguments. here is friends.urls.py: from . import views from django.conf.urls import url app_name = 'friends' urlpatterns = [ # we have 1 url for both adding and losing a friend url('connect/<slug:operation>/<int:pk>/', views.change_friends, name='change_friends'), # url(r'^connect/(?P<operation>.+)/(?P<pk>\d+)/$', views.change_friends, name='change_friends') ] here is the friends.views.py: from django.shortcuts import render, redirect from friends.models import Friend from django.contrib.auth.models import User def change_friends(request, operation, pk): friend = User.objects.get(pk=pk) if operation == 'add': Friend.make_friend(request.user, friend) elif operation == 'lose': Friend.lose_friend(request.user, friend) return redirect('groups:index') here is the template i'm calling it in (profile.html): {% if user in friends %} <a href="{% url 'friends:change_friends' 'remove' user_profile.id %}"><button type="button" name="btn btn-warning">UnFriend</button></a> {% else %} <a href="{% url 'friends:change_friends' 'add' user_profile.id %}"><button type="button" name="btn btn-success">Befriend</button></a> {% endif %} to me, it looks like i'm passing in the right arguments. this is the error im getting: NoReverseMatch at /accounts/profile/4 Reverse for 'change_friends' with arguments '('remove', 4)' not found. 1 pattern(s) tried: ['friends\\/connect/<slug:operation>/<int:pk>/'] any help would be really appreciated -
Django zappa 403 forbiden error and net:: Err_Aborted
I am trying to deploy vuejs/frontend & django(python)/backend webapp with AWS Lambda using zappa. I have all of my static files in an S3 bucket. Whenever I try to view it in the browser, the page is completely blank, & I am getting these errors in the console. GET https://example.s3.amazonaws.com/static/webpack_bundles/static/js/app.3122315aa5664adf.js 403 (Forbidden) GET https://example.s3.amazonaws.com/static/webpack_bundles/static/css/app.b161c29d6c5fa852dc6887b62955427e6.css net::ERR_ABORTED GET https://7exa5465ef451.execute-api.us-east-1.amazonaws.com/favicon.ico 403 () -
Django passwordless UserModel
I'm trying to make custom UserModel that doesn't need password field for authentication and Login. actually, something like passwordless authentication with a phone number and verify with custom tokens that send from the server. every custom way for extending django user model that include password field required. I tried to make custom user model from AbstractBaseUser with something like this from django.db import models from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) class UserManager(BaseUserManager): def create_user(self, username, password): if not username: raise ValueError(' user must have an username') user = self.create_user(username, password=password) user.set_unusable_password() user.save(using=self._db) def create_staffuser(self, username, password): if not username: raise ValueError(' user must have an username') user = self.create_user(username, email, phonenumber, password=password) user.staff = True user.save(using=self._db) def create_superuser(self, username, email, phonenumber, password): if not username: raise ValueError(' user must have an username') user = self.create_user(username, password=password) user.staff = True user.admin = True user.save(using=self._db) return user class User(AbstractBaseUser): username = models.CharField(max_length=50, unique=True, verbose_name='user name') first_name = models.CharField(max_length=50, unique=True, verbose_name='first name') last_name = models.CharField(max_length=50, unique=True, verbose_name='last name') email = models.EmailField(verbose_name='email address', max_length=255, unique=True) phonenumber = models.IntegerField(max_length=13, verbose_name='phonenumber') password = models.CharField(max_length=255, blank=True) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) objects = UserManager() USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['email', 'phonenumber'] def … -
Have data in ajax, but when it's called I got undefined
Have some data in the dict: data = {"signup":1, "trash":'trash'} But when i call it by console.log(data.signup) it prints undefined. Img with console logs of data and dicts objects. Img with prints in console. Ajax function: $(document).ready(function(){ var form = $('#signin_form'); form.on('submit', function(e){ e.preventDefault(); var url = form.attr("action"); var username = $('#username').val(); var password = $('#password').val(); var csrf_token = $('#signin_form [name="csrfmiddlewaretoken"]').val(); console.log(username); console.log(password); $.ajax({ type: "POST", url: url, data: { 'username': username, 'password': password, 'csrfmiddlewaretoken': csrf_token, }, dataType: "text", cache: false, success: function(data){ console.log(data); console.log(data.signupstatus); console.log(data.trash); if(data.signup){ console.log('lol') } } }) }) }) And view on Django that gets data by the request, checking user login and password in the DB(authenticating user) and giving some keys with values back to ajax: def sigin(request): return_dict = dict() if request.method == "POST": username = request.POST["username"] password = request.POST["password"] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return_dict["signupstatus"] = 1 return_dict["trash"] = 'trash' else: return_dict["signupstatus"] = 0 return JsonResponse(return_dict) So back to the ajax func. I can see what keys are in the data by using console.log(data) but when i'm trying to see the value of the key by using console.log(data.signupstatus) i'm getting unidentified. -
Django: Trouble passing variables to the Form for saving to the database
hope you can help resolve this issue. I have a Django app with Artist, Venue and Event modals, and I need to be able to add an 'alert' to either one of these. I have created one Alert Modal that looks like this; class AMQAlert(models.Model): venue = models.ForeignKey("Venue", on_delete=models.CASCADE, null=True, blank=True) artist = models.ForeignKey("Artist", on_delete=models.CASCADE, null=True, blank=True) event = models.ForeignKey("Event", on_delete=models.CASCADE, null=True, blank=True) author = models.ForeignKey(User, on_delete=models.CASCADE, default=1) created_at = models.DateTimeField(default=timezone.now) text = models.CharField(max_length=300, blank=True) link = models.URLField(max_length=200, blank=True) As some of these fields are automatically filled (author & 'created_at') I have created a form in my forms.py file like this; class AMQAlertForm(forms.ModelForm): class Meta: model = AMQAlert fields = [ "text", "link" ] I also have a template for this form, that includes a 'cancel' button; <form class="form-horizontal" method="POST" action="">{% csrf_token %} {% for field in form %} <div class="form-group"> <span style="padding: 0px 0px 0px 0px;" class="text-danger small">{{ field.errors }}</span> <label class="controll-label col-sm-2">{{ field.label_tag }}</label> <div class="col-sm-10">{{ field }}</div> </div> {% endfor %} <button type="submit" name="submit" class="btn btn-success">Submit</button>&nbsp;&nbsp; <button type="submit" name="cancel" value="Cancel" formnovalidate class="btn btn-info">Cancel</button> </form> In my views.py I have a CreateView like this accounting for the 'cancel' or 'submit' POSTs; def ArtistCreateAMQ(request, artist_id): artist = get_object_or_404(Artist, pk=artist_id) … -
Cannot create a polymorphic project instance in Django Rest framework JSON API example project
I am trying to understand how polymorphic resources work in django-rest-framework-json-api and I get the following error both on my own project and the example project provided by django-rest-framework-json-api. My models are created using django-polymorphic. The example project I am trying to run is https://github.com/django-json-api/django-rest-framework-json-api/tree/master/example. Endpoint : localhost:8000/projects { "errors": [ { "detail": "Incorrect relation type. Expected on of [artProject, researchProject], received None.", "source": { "pointer": "/data" }, "status": "409" } ] } Project page's form used to create a new instance doesn't have any field that I can specify the type of the Project. It only shows the topic field. So I am also wondering how I can create an Art project for instance. In the documentation it says the type is determined by the resource_name in Meta data of either view, serializer or model. But type is none in the returned json data. It is because serializer.instance = None which is used to determine the type when force_type_resolution is set to True. It is set to True to force polymorphic serializers to resolve the type based on instance. So I can't seem to fix this issue, maybe I am missing some configuration or there really is a bug … -
Output of different querisets in the Django Rest framework
Perhaps a little incorrectly formulated the question. In general, I do not understand how to transfer various collections of objects using DRF. I need to list all the places, the list of the most popular and the list is the editor's choice. I'm trying to understand by analogy with django views. def places_list(request): places = Places.objects.all() editor_places = Places.objects.filter(editor_choice = True ) popular_places = Places.objects.filter(most_popular = True ) return render (request, "places/places_list.html", {"places": places, "editor_places": editor_places, "popular_places": popular_places, }) And then in the template I display 3 tables with the parameters I need. MAke API serializer.py class PlaeceSerializer(ModelSerializer): url = HyperlinkedIdentityField( view_name='places_api:detail', lookup_field='pk' ) class Meta: model = Places fields = ( 'url', 'id', 'main_photo', 'name', ) views.py class PlacesListAPIView(ListAPIView): queryset = Places.objects.all() serializer_class = PlaeceSerializer So I have a json collection that contains all the objects. How to make a sample correctly? In views.py or can it be like working on the front with the data? Share your experience, please. -
how do i get the username variable from a user to use it in models.py django
I want to get the username variable of the logged in user to use it as the default value of create a Post form in html i can access that by doing {{ user.username}}but when i do that as a default value in my models.py i get the default value as {{ user.username}} just as a text not a variable and when i remove the two curly braces it saids that user is not defined models.py class Payment(models.Model): Author = models.CharField(max_length=255) Product = models.CharField(max_length=255) Payment_ID = models.BigIntegerField(default=0) Status = models.CharField(max_length=5, default="X") Review_result = models.CharField(max_length=255, default="Not yet reviewed") created = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['-created'] def __unicode__(self): return u'%s'% self.Status def __str__(self): return self.Status and for the login i use the default form of django -
How to install Oracle Client library on cPanel
I create Python App throw cPanel and setting database to connect with Oracle DB on AWS. This app run on localhost perfectly. But on host, it missing Oracle Client library with error: Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help -
I want to send mail through form data. I want the receiver to be fixed and sender only changes.How can I achieve this?
This is the models.py . The email field is the sender with the password and receiver is email1. class ContactModel(models.Model): fullname = models.CharField(max_length=20,null=True,blank=True) email=models.EmailField(null=True,blank=True) password = forms.CharField(widget=forms.PasswordInput) email1=models.EmailField(null=True,blank=True) subject=models.CharField(max_length=30,null=True,blank=True) message=models.TextField(max_length=200) color = models.CharField(max_length=6, choices=COLOR_CHOICES, default='green') This is my views.py file. def contact_page(request): if request.method=='POST': form = ContactForm(request.POST) if form.is_valid(): fullname =form.cleaned_data.get("fullname") email =form.cleaned_data.get(settings.EMAIL_HOST_USER) password=form.cleaned_data.get(settings.EMAIL_HOST_PASSWORD) subject =form.cleaned_data.get("subject") model_instance = form.save(commit=False) fullname = request.POST.get('fullname', '') email1 = request.POST.get('email1', '') message = request.POST.get('message', '') color = request.POST.get('color', '') # Email the profile with the # contact information template = get_template('contact_template.txt') context = { 'fullname': fullname, 'email': email, 'message': message, 'color':color, 'email1': email1, } message = template.render(context) email = EmailMessage("Test Mail",message,settings.EMAIL_HOST_USER,[email1], headers = {'Reply-To': email1 } ) email.send() model_instance.save() return render(request,'form/success.html') else: form = ContactForm() return render(request, "contact_page.html", {'form': form}) Please help me only one receiver and sender changes. I will be thankful for your help. Trying to retrieve the form data through mail sending this to mail.