Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
What does this error means "Exception Value: `update()` must be implemented." in django restframework
I am trying to make a web service of choice field using Django rest framework. My data base connectivity is working but when I post my web service it gives me the error:- : update() must be implemented." I am attaching my code below My dashboard/models.py: from django.db import models from django.contrib import admin from django import forms class Campus(models.Model): campus_choices = (('Campus_1','Campus_1'),('Campus_2','Campus_2'),('Campus_3','Campus_3')) select_campus = models.CharField(max_length = 100,choices = campus_choices) class Building(models.Model): building_choices = (('Building_1','Building_1'),('Building_2','Building_2'),('Building_3','Building_3')) select_building = models.CharField(max_length = 100, choices = building_choices) class Floor(models.Model): floor_choices = (('Floor_1','Floor_1'),('Floor_2','Floor_2'),('Floor_3','Floor_3')) select_floor = models.CharField(max_length = 100,choices = floor_choices) class Rooms(models.Model): room_choices = (('Room_1','Room_1'),('Room_2','Room_2'),('Room_3','Room_3')) select_rooms = models.CharField(max_length = 100, choices = room_choices) serializers.py from rest_framework import serializers from .models import * from dashboard.models import Campus class CampusSerializers(serializers.Serializer): class Meta: campus_choices = [('Campus_1','Campus_1'),('Campus_2','Campus_2'),('Campus_3','Campus_3')] model = Campus select_campus = serializers.ChoiceField(choices = campus_choices) def create(self, validated_data): campus_obj = Campus(**validated_data) campus_obj.save() return campus_obj def update(self, instance, validated_data): instance.select_campus = validated_data["select_campus"] instance.save() return instance class BuildingSerializers(models.Model): select_building = serializers.CharField(max_length = 100) def create(self, validated_data): building_obj = Building(**validated_data) building_obj.save() return building_obj def update(self, instance, validated_data): instance.select_building = validated_data["select_building"] instance.save() return instance class FloorSerializers(models.Model): select_floor = serializers.CharField(max_length = 100) def create(self, validated_data): floor_obj = Floor(**validated_data) floor_obj.save() return floor_obj def update(self, instance, … -
User has no profile.RelatedObjectDoesNotExist
I am trying to create a user based app. A profile image is assosciated with every user.But whenever I am trying to login it is showing the above mentioned error and highlighting the instance.profile.save() in signals.py. I am new to django kindly help me with this. Thanks in Advance. error: Request Method: POST Request URL: http://127.0.0.1:8000/login/ Django Version: 2.2.5 Exception Type: RelatedObjectDoesNotExist Exception Value: User has no profile. users/Signals.py: from django.db.models.signals import post_save from django.contrib.auth.models import User from django.dispatch import receiver from .models import profile @receiver(post_save,sender=User) def create_profile(sender,instance,created,**kwargs): if created: profile.objects.create(user=instance) @receiver(post_save,sender=User) def save_profile(sender,instance,**kwargs): instance.profile.save() users/Models.py: from django.db import models from django.contrib.auth.models import User from PIL import Image # Create your models here. class profile(models.Model): user=models.OneToOneField(User,on_delete=models.CASCADE) image=models.ImageField(default='default.png',upload_to='profile_pics') def __str__(self): return f'{self.user.username} profile' def save(self,*args,**kwargs): super( profile, self ).save(*args,**kwargs) img=Image.open(self.image.path) if img.height>300 or img.width>300: output_size=(300,300) img.thumbnail(output_size) img.save(self.image.path) users/views.py: from django.shortcuts import render,redirect from django.contrib import messages from .forms import UserRegisterForm,UserUpdateForm,ProfileUpdateForm from django.contrib.auth.decorators import login_required from .models import profile # Create your views here. def register(request): if request.method=="POST": form=UserRegisterForm(request.POST) if form.is_valid(): form.save() username=form.cleaned_data.get('username') messages.success(request,f'Account created for {username}!') return redirect('login') else: form=UserRegisterForm() return render(request,'users/register.html',{'form':form}) @login_required def profile(request): if request.method=='POST': u_form = UserUpdateForm( request.POST,instance=request.user ) profile = profile.objects.get( user=request.user ) Profile_form = ProfileForm( request.POST, … -
Django send email from a form, with the filler's email as FROM
I'm moving my portfolio from PHP to Python (django), and I have a contact form in it, when it was in PHP, it didn't need any credentials, and when it sent the email,I receive an email FROM: user@mail.com normally, now when I tried to convert it to Django, using send_mail, when an email is sent I receive an Email FROM: myemail@gmai.com (me). i want to know how I could fix this, receive the email with the sender email as From, otherwise i wouldn't be able to reply to them. My question is not a duplicate, as i have seen the other questions and their anwers and it didn't help. Here is the PHP: <?php // Replace this with your own email address $siteOwnersEmail = 'wassim.chaguetmi@gmail.com'; if ($_POST) { $name = trim(stripslashes($_POST['contactName'])); $email = trim(stripslashes($_POST['contactEmail'])); $subject = trim(stripslashes($_POST['contactSubject'])); $contact_message = trim(stripslashes($_POST['contactMessage'])); // Check Name if (strlen($name) < 2) { $error['name'] = "Please enter your name."; } // Check Email if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) { $error['email'] = "Please enter a valid email address."; } // Check Message if (strlen($contact_message) < 15) { $error['message'] = "Please enter your message. It should have at least 15 characters."; } // Subject if ($subject == '') { … -
Django: AttributeError: 'str' object has no attribute 'objects'
i am getting error while i extracting the value in my AUTH_USER_MODEL table. any help, would be appreciated. views.py AUTH_USER_MODEL = settings.AUTH_USER_MODEL class AllUser(ListAPIView): model = AUTH_USER_MODEL serializer_class = UserSerializer queryset = AUTH_USER_MODEL.objects.all() serializers.py AUTH_USER_MODEL = settings.AUTH_USER_MODEL class UserSerializer(serializers.ModelSerializer): class Meta: model = AUTH_USER_MODEL fields = [ "username", "email", ] -
Deploying tf.keras model using Django Rest Framework, class-based views
I have a trained tf.keras model (for this example, let's say it is trained on the Iris Dataset). I want to deploy this model using Django Framework, more specifically, the Django REST Framework to create an API. I want my final product to be a website, where users can input the features (in this case, the Petal width, sepal width, and so on...) via a form, and the server should take in those features, do the necessary processing, and show the prediction to the user (maybe just below the form). The way I implemented it does not work, the server throws an error. models.py (I did run makemigrations and migrate commands) from django.db import models class IrisData(models.Model): name = models.CharField(max_length=50) petal_width = models.FloatField() petal_length = models.FloatField() sepal_width = models.FloatField() sepal_length = models.FloatField() def __str__(self): return self.name serializers.py from rest_framework import ModelSerializer from .models import IrisData class IrisSerializer(ModelSerializer): class Meta: model = IrisData fields = '__all__' It is very likely that the views.py file is not properly configured for my requirements. views.py from .serializers import import IrisSerializer from .models import IrisData # I want to use only class-based views # I prefer to use generic CreateView instead of creating a form … -
Could not parse the remainder: '('static', filename='main.png')' from 'url_for('static', filename='main.png')'
I am a django beginner and I am trying to render a html page. I already have a test html page and URL to test this out. Upon hitting the URL, following error is encountered: Could not parse the remainder: '('static', filename='main.png')' from 'url_for('static', filename='main.png')' Complete Trace: Request Method: GET Request URL: http://127.0.0.1:8000/xxxxx Django Version: 3.0.2 Exception Type: TemplateSyntaxError Exception Value: Could not parse the remainder: '('static', filename='main.png')' from 'url_for('static', filename='main.png')' Exception Location: F:\Anaconda\lib\site-packages\django\template\base.py in __init__, line 662 Python Executable: F:\Anaconda\python.exe Python Version: 3.7.0 I have tried using single & double quotes but it still doesn't work. kind of stuck at this point. Any comments/suggestions/hints/links-to-guides are appreciated. -
Access tuple values in django templates without loop
My dictionary returns a qureyset. E.g. context = { 'details': appl.values_list('device_detail_title','icon'), } Returns: <QuerySet [('Recent Info', 'amr.jpg')]> I want to access the second index of the tuple in the template without need to loop. How is this possible? Like: {{ details[1] }} -
Could not parse the remainder: '[i]['fld_id']' from 'data[i]['fld_id']'
I am trying to access data from a list of dictionary to my HTML template and the following error occured while trying to access the data from the dictionary. This same error even occured initially when I tried to loop using range(len(data)) but then I created another list that stores the range. But I can't do that for a LOD. Could not parse the remainder: '[i]['fld_id']' from 'data[i]['fld_id']' viwes.py data_to_print=[ { 'fld_name':i, 'name':randomString(10), 'age':randomString(2), 'gender':randomString(5) }for i in files_in_user_folder ] for q in range(len(data_to_print)): numbers.append(q) return render(request, 'loginpage/datapage.html',{'data':data_to_print},{'rng':numbers}) template.html </tr> {% for i in rng %} <tr> <td> {{data[i]['fld_id']}} </td> <td> {{data[i]['name']}} </td> <td> {{data[i]['age']}} </td> <td> {{data[i]['gender']}} </td> <td> <a href="http://127.0.0.1:8000/media/{{data[i]['fld_id']}}.zip" download>Download</a></td> </tr> {% endfor %} How can I resolve this? -
How set date filter with start and end date django rest framwork
I have view.py class eventList(ListAPIView): queryset = Event.objects.all().filter(is_active=1, is_approved=1) serializer_class = eventSerializer filter_backends = [DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter] search_fields = ['event_name', 'event_address', 'start_date', 'start_time', 'end_time', 'age_max', 'age_min', 'event_organizer__name', 'event_type__name', 'event_city__name', 'event_tag__name'] filterset_fields = ['id', 'event_name', 'start_date', 'start_time', 'end_date', 'end_time', 'age_max', 'age_min', 'event_organizer', 'event_type', 'event_city', 'event_tag'] ordering_fields = '__all__' ordering = ['-start_date'] how I get events on the basis start_date date range like http://192.168.0.115:8000/api/allEvents/?start_date__gte=2019-11-16&start_date__lt=2019-11-24 I want this on filterset_fields, How achieved this scenario -
Django MultipleObjectsReturned issue
I tried to make a signup system for my Django app. But when a user login or signup there is a error page coming up. I have 3 users and I think this is related to error. MultipleObjectsReturned at / get() returned more than one CustomUser -- it returned 3! Error image: error image views.py from django.urls import reverse_lazy from django.views.generic.edit import CreateView from .forms import CustomUserCreationForm class SignUpView(CreateView): form_class = CustomUserCreationForm success_url = reverse_lazy('login') template_name = 'registration/signup.html' forms.py from django import forms from django.contrib.auth.forms import UserCreationForm, UserChangeForm from .models import CustomUser class CustomUserCreationForm(UserCreationForm): class Meta: model = CustomUser fields = ('username', 'email', 'user_type' ) class CustomUserChangeForm(UserChangeForm): class Meta: model = CustomUser fields = ('username', 'email', 'user_type') models.py from django.contrib.auth.models import AbstractUser from django.db import models user_type = ( ('pharmacist', 'Pharmacist'), ('manager', 'Medical Repository Manager'), ) class CustomUser(AbstractUser): user_type = models.CharField(max_length=50, choices=user_type) def __str__(self): return self.username Here is a part of my code. If it is lack of some necessary parts, please tell me. Thank you. -
Getting not all arguments converted during string formatting
Hi I have a below code. def GetData(request): try: year='' month=[] results=[] conn = connections["connection1"] cursor = conn.cursor() year = request.GET.get('year') print(year) month = request.GET.getlist('month[]') for i in month: print("Months::"+i) class = request.GET.get('class') response_list = [] placeholder= '?' # For SQLite. See DBAPI paramstyle. placeholders= ', '.join(placeholder for unused in month) response_list = [] query = (" select Year,month,student_name,admission_date,class from admission_table\ where MONTH(admission_date) in (%s) AND YEAR(admission_date) in ('"+year+"') AND class in ('"+class+"')"% placeholders) cursor.execute(query,month) rows = cursor.fetchall() print(rows) if rows: for row in rows: response_list.append({'year':row[0],'month':row[1],'student_name':row[2],'admission_date':str(row[3]),'class':row[4]}) except Exception as e: print(str(e)) return HttpResponse(json.dumps(response_list)) Am getting while passing arguments for MONTH(admission_date) in (%s) in SQL query. How can overcome it . Please help.Thank you!! -
Transparent HTML Form background in Django
How to have a transparent form background instead of white color ? I am trying to have a transparent form for my search page. But when I use form tags in django, I get a white background. <form id="search" method="POST" action="" novalidate> {% csrf_token %} <div class=" form-control"> <b><th>Search</th><b> <div style="text-align: center"> {{form.name}}</div> </div> <br> <button type="submit" class="save btn btn-default">Search</button> </form> -
how to show details of a record with a foreign key relationship
i have these two models class Pv(models.Model): IA_System_Code = models.AutoField(primary_key = True) IA_code = models.CharField(max_length = 150) Date_recieved = models.DateField() Pv_reference = models.CharField(unique = True, max_length = 120) Payee = models.CharField(max_length=500) Description = models.CharField(max_length = 500) class Meta(): ordering = ["-IA_System_Code"] def __str__(self): return self.Description class staff(models.Model): staff_id = models.CharField(max_length = 150) name = models.CharField(max_length = 300) rank = models.CharField(max_length = 300) amount = models.DecimalField(max_digits=19, decimal_places=2) Pv_reference = models.ForeignKey('Pv',on_delete=models.CASCADE) def __str__(self): return self.name now the thing is i want to be able to click view button of the registed pv in a table it should open the detail page with the id passed at arg and related record in the staff should also appear on the same detail form in a table manner here is my registere pv table html registedpv.html <table id="example2" class="table table-hover"> <tr> <thead class="thead-light success"> <tr> <th scope="col">Pv Reference</th> <th scope="col">Description</th> <th scope="col">IA code</th> <th scope="col">Gross Amount(GH&#8373) </th> <th scope="col">Tax (GH&#8373) </th> <th scope="col">Net Amount (GH&#8373) </th> <th scope="col">Accountable impress</th> <th scope="col">Status</th> <th scope="col"></th> </tr> </thead> <tbody> {% for pv in pvs %} <tr> <td>{{pv.Pv_reference}}</td> <td>{{pv.Description}}</td> <td>{{pv.IA_code}}</td> <td> {{pv.Gross_amount}} </td> <td> {{pv.Withholding_tax}}</td> <td> {{pv.Net_amount}}</td> <td>{{pv.Acc_Impress}}</td> <td> {% if pv.Status == 'Completed' %} <span class="badge bg-success">{{pv.Status}}</span> {% … -
How to correctly unpack tuple and display it?
I have ['34242342', 'Ford focus 2015', 'Chevrolet Impala 1960', 'Ford focus 2012', 'Dodge charger 2010', 'Dodge', 'New fiat punto 2012'] created from: (('34242342',), ('Ford focus 2015',), ('Chevrolet Impala 1960',))(not full). And I want to display it on my template: {% for p in full %} <form action="{% url 'table' %}" method="GET"> <input style="background-color:#2F4050;color:#A7B1C2; margin-top:5px;border: none; border-color: rgba(0,0,0,0.9);" type="submit" value={{ p }} name="button"> </form> {% endfor %} But instead of displaying full elements it cuts it: 34242342 Ford Chevrolet Ford Dodge New It displays everything correctly if I call elements like: {% for p in full %} {{p}} {% endfor %} It cuts elements only in value option of input. -
How to use a context variable when passing to a template tag
I use the following template tag to allow custom variables to be set inside a template: class SetVarNode(template.Node): def __init__(self, new_val, var_name): self.new_val = new_val self.var_name = var_name def render(self, context): context[self.var_name] = self.new_val return '' @register.tag def setvar(parser, token): # This version uses a regular expression to parse tag contents. try: # Splitting by None == splitting by spaces. tag_name, arg = token.contents.split(None, 1) except ValueError: raise template.TemplateSyntaxError( "%r tag requires arguments" % token.contents.split()[0] ) m = re.search(r'(.*?) as (\w+)', arg) if not m: raise template.TemplateSyntaxError( "%r tag had invalid arguments" % tag_name ) new_val, var_name = m.groups() if not (new_val[0] == new_val[-1] and new_val[0] in ('"', "'")): raise template.TemplateSyntaxError( "%r tag's argument should be in quotes" % tag_name ) return SetVarNode(new_val[1:-1], var_name) This lets me set a variable once for use in the template: {% setvar "a string" as new_template_var %} How can I modify this to allow my variable to concatenate with an existing context variable? E.g. I want to pass context['var1'] to the setvar as {% setvar "a string {{ var1 }}" as new_template_var %} however the {{ var1 }} is included as a string and not the variable value itself. -
Authenticating user before profile is activated in django
I would like to create a signup process where a user completes the signup form, receives an emailing detailing the next step forward and remains as an inactive user until I manually login as an admin and activate the user's profile. This is what I have in my views.py (teachers.py): class TeacherSignUpView(CreateView): model = User form_class = TeacherSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'teacher' return super().get_context_data(**kwargs) def form_valid(self, form, request): user = form.save() # user.set_password(form.cl) login(self.request, user) username = form.cleaned_data.get('first_name') email = form.cleaned_data.get('email') htmly = get_template('classroom/teachers/email.html') d = {'username': username} subject, from_email, to = 'Welcome to GradientBoost', 'emmanuel@thegradientboost.com', email html_content = htmly.render(d) msg = EmailMultiAlternatives(subject, html_content, from_email, [to]) msg.attach_alternative(html_content, 'text/html') msg.send() if request.user.is_activated: return redirect('teachers:app-instructor-dashboard') else: return redirect('teachers:notyet') models.py class User(AbstractUser): is_student = models.BooleanField(default=False) is_teacher = models.BooleanField(default=False) is_activated = models.BooleanField(default=False) and classroom.py (views for the home page, about page etc): #redirects after signup def home(request): if request.user.is_authenticated and request.user.is_activated: if request.user.is_teacher: return redirect('teachers:app-instructor-dashboard') elif request.user.is_student: return redirect('students:app-student-dashboard') return render(request, 'classroom/home.html') #about us page def about(request): return render(request, 'classroom/about-us.html') #courses page def courses(request): return render(request, 'classroom/courses.html') #course details def course_details(request): return render(request, 'classroom/course-details.html') However, when I attempt to signup I get the error message: TypeError at /accounts/signup/teacher/ form_valid() … -
Python's datetime timezone aware is giving not unanimous results
Why do I get different resuluts for these operations? >> from datetime import datetime >> import pytz >> from django.utils import timezone >> b = pytz.timezone("Europe/Warsaw") >> datetime.combine(a.date(), a.time(), b) datetime.datetime(2020, 2, 4, 12, 16, 41, 554036, tzinfo=<DstTzInfo 'Europe/Warsaw' LMT+1:24:00 STD>) >> b.localize(a) datetime.datetime(2020, 2, 4, 12, 16, 41, 554036, tzinfo=<DstTzInfo 'Europe/Warsaw' CET+1:00:00 STD>) >> timezone.get_current_timezone() <DstTzInfo 'Europe/Warsaw' LMT+1:24:00 STD> >> timezone.make_aware(a) datetime.datetime(2020, 2, 4, 12, 16, 41, 554036, tzinfo=<DstTzInfo 'Europe/Warsaw' CET+1:00:00 STD>) -
Should I remove "_placeholder" tables during the upgrade of Django?
I have the following configuration in my active server, Python 2.7, Django 1.x, Django-cms 3.x and I'm doing the upgrade for all these three to, Python 3.7, Django 2.x, Django-cms 3.x But, issue is my current project have so much data as Both independent(Ex.account, user, payment_transaction) and dependent(cms, cms_plugin.etc) The issue is while checking the tables, I noticed some of the other tables (not created by django or other plugins) end with "_placeholder"(Ex. account_placeholder). Here I already have table called "account". But during migration, this "_placeholder" table is created automatically. What is the use of this table and can I remove it? If i remove, what is the consequence ? -
Professor Django how are user request objects attached to views?
When a Django application receives a http request form a browser, what function is responsible for calling a view? Does that function first manipulate the Http request information before calling the view function? Does the function also perform automatic user retrieval like in: The user object is available on the request object from django.conf import settings from django.shortcuts import redirect def my_view(request): if not request.user.is_authenticated: return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path)) # ... -
Extended user model to include is _activated getting no such column error
I would like users in my django app to signup, receive an email with further details regarding the signup process and for the profile to remain inactive and for the user not to be redirected to the login page until I manually activate it in admin. I started getting the error no such column: classroom_user.is_activated after extending the user model to include is_activated class User(AbstractUser): is_student = models.BooleanField(default=False) is_teacher = models.BooleanField(default=False) is_activated = models.BooleanField(default=False) Since there are 2 types of users I created 3 views, one for the home page and the 2 for each type of user. Here is the one for the home page(classrooms.py): class SignUpView(TemplateView): template_name = 'registration/signup.html' #redirects after signup def home(request): if request.user.is_authenticated and request.user.is_activated: if request.user.is_teacher: return redirect('teachers:app-instructor-dashboard') elif request.user.is_student: return redirect('students:app-student-dashboard') return render(request, 'classroom/home.html') #about us page ... The one for the teachers profile: class TeacherSignUpView(CreateView): model = User form_class = TeacherSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'teacher' return super().get_context_data(**kwargs) def form_valid(self, form): user = form.save() # user.set_password(form.cl) login(self.request, user) username = form.cleaned_data.get('first_name') email = form.cleaned_data.get('email') htmly = get_template('classroom/teachers/email.html') d = {'username': username} subject, from_email, to = 'Welcome to GradientBoost', 'emmanuel@thegradientboost.com', email html_content = htmly.render(d) msg = EmailMultiAlternatives(subject, html_content, from_email, … -
How to call javascript function only if the django form is valid
I have a django form I need to call javascript function only if the form is valid.Is there a way that i can achieve this. -
AWS Elastic bean stalk environment got stuck while creating
Whenever I try to create an application, it gets created but when I try to create environment it got stuck on multiple places. I have attached the error log file below. I have also tried multiple solutions. Like I have erased all the command from requirement.txt. I have also created a new application and new environment all over again but its still stuck at the same places. My requirement.txt looks like this: Django==2.1.5 django-filter==2.0.0 djangorestframework==3.9.0 Markdown==3.0.1 pytz==2018.7 django-timezone-field==3.0 django-rest-auth==0.9.3 django-allauth==0.39.1 django-cors-headers==2.4.0 psycopg2-binary==2.7.7 psycopg2==2.7.7 django-bootstrap4==0.0.8 django-fontawesome-5==1.0.16 Pillow==6.0.0 boto3==1.10.28 django-storages==1.7.1 django-smtp-ssl django-ses stripe==2.36.2 django-background-tasks==1.2.0 zappa==0.48.2 django-s3-storage==0.12.5 celery==4.4.0 pycurl==7.43.0.4 And my django.config file is this: option_settings: aws:elasticbeanstalk:container:python: WSGIPath: SB_Main/wsgi.py NumProcesses: 3 NumThreads: 30 "aws:elasticbeanstalk:container:python:staticfiles": /static/: "static/" container_commands: 01_makeMigrations: command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations SB_Auth" leader_only: true 02_makeMigrations: command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations SB_API" leader_only: true 03_migrate: command: "source /opt/python/run/venv/bin/activate && python manage.py migrate" leader_only: true 04_collectstatic: command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput" 05_makeMigrations: command: "source /opt/python/run/venv/bin/activate && python manage.py loaddata dummyData.json" leader_only: true 06_wsgipass: command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf' It also gets stuck here and give this error: -
Sending a request from django to itself
I have a Django project that contains a second, third-party Django app. In one of my views, I need to query a view from the other app (within the same Django project). Currently, it works something like this: import requests def my_view(request): data = requests.get('http://localhost/foo/bar').json() # mangle data return some_response Is there a clean way to send the request without going all the way through DNS and the webserver and just go directly to the other app's view (ideally going through the middleware as well of course) -
Why user www-data of apache2 can't import module django
I am using virtual Machine Ubuntu16.04 and I want to use LAMP(python),but when I test as user "web" (a user that I created), there is no error. But if I test as apache2's default user "www-data", there is a error as follow: ImportError: No module named 'django' My django's location is /home/web/.local/lib/python3.5/site-packages, and I also use: cd /home/web/.local/lib/python3.5 sudo chmod -R 777 site-packages/ but it not worked. Please help me, I just don't know why "www-data" not work but "usr" can work I also try www-data user unable to import installed python modules, but it still don't work -
pip3 is installing django globally not inside my environment
I used virtualenvwrapper to create a new env but when i tried to install pip3 to install newer versions of django it was install globally although my environment was activated , which leads to global installation of django .. how can I use it only inside my virtual env