Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can I send javascript arrays values into django database
I'm working on a app were the user add activities and time and it will display it on a chart. But when I save an activity, it only save the last input. I want the user to save all the input as an array. I not sure how to proceed from there. I was thinking using a XMLhttpRequest but I'm getting a an error saying "rest_framework.exceptions.ParseError: JSON parse error - Expecting value: line 1 column 1 (char 0)" View.py import json from django.shortcuts import render from django.core import serializers from django.http import HttpResponse, JsonResponse from django.views.decorators.csrf import csrf_protect from page.templates.forms import ActivitiesForm from page.models import Activities from .serializers import ActivitiesSerializer from rest_framework.parsers import JSONParser from rest_framework.decorators import api_view from rest_framework.decorators import parser_classes @parser_classes([JSONParser]) @csrf_protect def page_list(request): if request.method == 'GET': activities = Activities.objects.all() serializer = ActivitiesSerializer(activities, many=True) return JsonResponse(serializer.data, safe=False) elif request.method == 'POST': data = JSONParser().parse(request) serializer = ActivitiesSerializer(data=data) if serializer.is_valid(): serializer.save() return JsonResponse(serializer.data, status=201) return JsonResponse(serializer.errors, status=400) @csrf_protect def page_detail(request, pk): try: activities = Activities.objects.get(pk=pk) except Activities.DoesNotExist: return HttpResponse(status=404) if request.method == 'GET': serializer = ActivitiesSerializer(activities) return JsonResponse(serializer.data) elif request.method == 'PUT': data = JSONParser().parse(request) serializer = ActivitesSerializer(activities, data=data) if serializer.is_valid(): serializer.save() return JsonResponse(serializer.data) return JsonResponse(serializer.errors, status=400) elif … -
Working with csv data for web development
I am trying to build a webpage which will display some data from a csv file. Preferably, I want to be able to load the csv data, and then able to select from the data and plot it. I am new to web-development, and have set-up a simple site using django. However, I cannot see the easiest way to access the data from the csv files in the html/js files. Are there any existing frameworks by which this can be done- dash seems like a potential candidate but I am unsure. Alternatively, it seems that I may be able to load csv files via the static files directory in django, but this also seems like a lot of hassle. Many thanks in advance. -
How to get JSON API response for call made from twilio?
I am unable to fetch the JSON response as shown in the tutorial. I have implemented a Programmable Voice program. I want to show the user the details of the call and if I get the JSON response I would be able to get all of them (cost, duration, status, etc). # views.py def start_campaign(request, campaign_id): try: campaign = Campaign.objects.get(pk=campaign_id) account_sid = 'XXX' auth_token = 'XXX' client = Client(account_sid, auth_token) phone_numbers = Contact.objects.filter(phone_book=campaign.phone_book) custom_url = 'http://XXX.ngrok.io/assets/' + str(campaign_id) for phone_number in phone_numbers: call = client.calls.create( method='GET', status_callback='http://XXX.ngrok.io/events', status_callback_event='completed', status_callback_method='GET', url=str(custom_url), to=str(phone_number), from_='+1XXX' ) detail = client.calls(str(call.sid)).fetch() print(detail.price) except Campaign.DoesNotExist: raise Http404("Campaign Does Not Exist") context = { 'all_campaigns': campaign } return render(request, "CallCenter/start_campaign.html", context) def events(request): status = request.GET.getlist('CallStatus', default=None) duration = request.GET.getlist('CallDuration', default=None) print("Duration:{}\nStatus:{}".format(duration, status)) return render(request, "CallCenter/events.html") In the terminal, I get a output which prints out the status and duration of the call from "GET /events?Called=%2BXX&ToState=&CallerCountry=US&Direction=outbound-api&Timestamp=Sat,+12+Oct+2019+19:11:50+%2B0000&CallbackSource=call-progress-events&SipResponseCode=200&Ca llerState=AL&ToZip=&SequenceNumber=0&CallSid=XXX&To=%2BXXX&CallerZip=35766&ToCountry=IN&CalledZip=&ApiVersion=2010-04-01&CalledCity=&CallStatus=completed&Duration=1&From= %2BXXX&CallDuration=5&AccountSid=XXX&CalledCountry=IN&CallerCity=ESTILLFORK&ToCity=&FromCountry=US&Caller=%2B12563804721&FromCity=ESTILLFORK&CalledState=&FromZip=35766&Fro mState=AL HTTP/1.1" 200 123 printing out Duration:['5', '5'] Status:['completed', 'completed'] Unfortunately, I don't know how to ask for the JSON response from Twilio. -
Efficiently synchronizing Django with localStorage (push notifications for a lot of JSON data)
I have an app that is heavily based on reading data from a database. The backend is written in Django and I am currently using django-rest-framework for the API through which I get my data. The frontend is written in React (without Redux at the moment). Since I need most of this data to be always up-to-date, whenever I load it, I store it in localStorage, and then take from there. This means that on page load, I load whatever is in localStorage, and, if necessary (a predefined timeout), I make a request to the server for fresh data. The issue with this is that since I am doing this for roughly 10 API endpoints right now, every 5 minutes, the number of requests to the server grows rapidly even when the data doesn't change. On top of that, I also check for notifications every 40 seconds, so 99% of my access log is just "GET /api/notifications/ HTTP/1.1" 200 2. The question: how do I make this more efficient for the server? I still want to have near-instant access to data when I load the page (so keep localStorage and just update it on demand) but I don't want to … -
Implement database transaction management in Django while using classes
In Django, I want to implement db transaction management that spans multiple methods in a class. I want to implement to types of transactions: status updates and inserts of data from a file. Transaction management should only involve the inserts from data that is read from a file. Status updates should always be written to a database, because these log whether the import was successful or has failed. Below is an example of my intended implementation. I cannot find a way to implement this transaction management. Does anyone have a suggestion? class ImportFile: def __init__(self, f): this.f = f # file path self.start_activity() self.read_file() self.end_activity() def start_activity(self): WRITE TO DATABASE THAT FILE f IS BEING IMPORTED def read_file(self): with open(this.f, 'r') as fi: for line in fi.readlines(): self.save_line_to_db(line) def save_line_to_db(self, line): STORE line IN DB def end_activity(self): 1. PERFORM SOME CHECK TO TEST INTEGRITY OF IMPORTED FILE. IF CORRECTLY IMPORTED: COMMIT, ELSE: ROLLBACK 2. WRITE TO DATABASE THAT IMPORT WAS SUCCESSFUL/FAILED -
How to retrieve data from Form to Views
i can't Retrieving data from my Form choices(nationality) to check the values. models.py NATIONALITY_CHOICES = (('1', 'خليجي'), ('2', 'ليس خليجي')) nationality = models.CharField(max_length=250, choices=NATIONALITY_CHOICES, null=True) when i check my fields in views it only redirect thank_you_not ! views.py def form_page(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): form.save() if form.fields['nationality'].choices == 1: return redirect('LandingPage:thank_you') else: return redirect('LandingPage:thank_you_not') else: form = UserForm() posts = Article.objects.filter(published_date__lte=timezone.now()).order_by('published_date') return render(request, 'LandingPage/form_page.html', {'form': form, 'posts': posts,}) how can i solve it ? -
Please help me implement Student , Faculty Registration and login for my project
I have created two models : Student having attributes onetoonefeild(User),roll number , studyYear , Department Faculty having attributes onetoonefeild(User),Branch And I dont understand how to handle their Registration form , login form , . -
graphene mutation returns 400 - won't pass id field properly
I have been using graphene in django with graphql and a React frontend. I can get a create mutation to work, but an edit one won't - even tho the query without $ variables works in graphiQL My gql const in React is: export const EDIT_PERSON = gql` mutation personEdit($id: id, $input: PersonInputType!) { personEdit(id: id, input: $input) { person { id } } } `; id is set from a handler and the submit function in the form looks like: <form autoComplete="off" onSubmit={e => { e.preventDefault(); editPerson({ variables: { id: id, input: { firstName: firstName, lastName: lastName, address: address } } }); }} > My PersonEdit mutation in django looks like: class PersonEdit(Mutation): class Arguments: id = ID(required=True) input = PersonEditInputType(required=True) person = Field(PersonType) @classmethod def mutate(cls, root, info, **data): serializer = PersonSerializer(data=data.get('input')) serializer.is_valid(raise_exception=True) person = Person.objects.get(id=data.get('id')) print("PERSON", serializer.data) person.first_name = serializer.data['first_name'] person.last_name = serializer.data['last_name'] person.address = serializer.data['address'] return PersonEdit(person=person.save()) Why will editing not work? -
What is inverse operation of Javascript's CryptoJS.enc.base64.stringify(data) in Python3/Dja?
I'm trying to encrypt in Javascript and decrypt the same data in Python/Django. Disclaimer: Not Production level code, but to learn concept I generate a key through Diffie Hellman (Ajax using jQuery), which I pass to the encrypt function below. Input is generally an ID and Password in JSON format. This is how the encryption takes place. {Found the code somewhere.} function toWordArray(str){ return CryptoJS.enc.Utf8.parse(str); } function toString(words){ return CryptoJS.enc.Utf8.stringify(words); } function toBase64String(words){ return CryptoJS.enc.Base64.stringify(words); } function encrypt(input, key){ console.log("Input: " + input); var PROTOCOL_AES256 = 2; var secret_key = CryptoJS.SHA256(key); var header = toWordArray("AMAZON" + String.fromCharCode(PROTOCOL_AES256)); var iv = CryptoJS.lib.WordArray.random(16); var body = CryptoJS.AES.encrypt(input, secret_key, {iv: iv}); // construct the packet // HEADER + IV + BODY header.concat(iv); header.concat(body.ciphertext); console.log("Bytes before Base64 encoding: " + header); //Line 1 // encode in base64 return toBase64String(header); } The output I get is as follows: final key: 47 signin:119:33 Input: {"name":"Buzz","password":"lightyear"} signin:55:25 Bytes before Base64 encoding: 414d415a4f4e02e8ec9b8a949eb754e305acfbe5207f1ebe75272c18146bca57ce399928c0ffd7e506d90e11b011da42b1bd8d2393ec59cc926cef33c2121da3f48dfd59925138 signin:67:25 Payload: QU1BWk9OAujsm4qUnrdU4wWs++Ugfx6+dScsGBRrylfOOZkowP/X5QbZDhGwEdpCsb2NI5PsWcySbO8zwhIdo/SN/VmSUTg= signin:137:37 XHRGEThttp://127.0.0.1:8000/Shenzen/actsignin/?encrypted_string=QU1BWk9OAujsm4qUnrdU4wWs%2B%2BUgfx6%2BdScsGBRrylfOOZkowP%2FX5QbZDhGwEdpCsb2NI5PsWcySbO8zwhIdo%2FSN%2FVmSUTg%3D [HTTP/1.1 500 Internal Server Error 24ms] AES failed. Now I decode it in python as follows: encrypted_string = request.GET['encrypted_string'] print("Encrypted string decoded: ",base64.b64decode(encrypted_string)) #Line 2 print("----") sha256_key = SHA256.new(data=bytes(key)) cipher = AES.new(sha256_key.digest(),AES.MODE_CBC) print(cipher.decrypt(base64.b64decode(encrypted_string))) [12/Oct/2019 18:39:41] "GET /Shenzen/dh/?step=calcval&level1=37 HTTP/1.1" 200 16 … -
can we convert models.Timefield to datetime in django
I have a models.timefield as breakfast_start_time = models.TimeField(default=time(7, 30)) I want to add one more field automatically by overriding save method whose name is breakfast_attendence_start_time and value 15 minutes less than the user input in breakfast_start_time. How can I achieve that. datetime.timedelta(minutes=15) is not working with models.Timefield and I dont want to use Datetimefield. please help me with this code. -
NoReverseMatch error when adding link to go back to category
I am making a forum site with Django and have set up categories, each with different topics that can be commented on. On the specific topic page, I am able to add {{ topic }} but when I try and add {{ category }} above that it does not show up. I am also trying to make the {{ category }} a link so they can go back to that category's main page. I have tried adding this in the topic.html but nothing shows up. <p> <a href="{% url 'speak_space:category' category.id %}">{{ category }}</a> </p> This is the error I receive when that code is included: NoReverseMatch at /topics/3/ Reverse for 'category' with arguments '('',)' not found. 1 pattern(s) tried: ['categories/(?P<category_id>[0-9]+)/$'] Here's my full topic.html page (I added a back button for a temporary fix): {% extends 'speak_space/base.html' %} {% block content %} <form> <input type="button" value="<< go back" onclick="history.back()"> </form> <p>Topic: {{ topic }}</p> <p> <a href="{% url 'speak_space:new_entry' topic.id %}">Join the convo!</a> </p> <p>Responses:</p> <ul> {% for entry in entries %} <li> <p>{{ entry.date_added|date:'M d, Y H:i' }}</p> <p>{{ entry.text|linebreaks }}</p> <p> <a href="{% url 'speak_space:edit_entry' entry.id %}">Edit</a> </p> </li> {% empty %} <li>Nobody has added to this … -
Is it a Good Practice to use Hybrid mysql and MongoDb in Django Application?
I am using Django rest framework as my backend, and using Django's default user model and my custom files model to store files uploaded by specific user. Now the process is to read the uploaded excel file and store the json formatted data back in the database for later use. So I am planning to use Mysql for user and files models and MongoDB to store all the meta data which will be in json format. Please guide if this a correct way to handle this or not. Also would like to know if there is any other best possible way for the same. Thanks !! -
how to properly redirect from one app to another app in django
i am a beginner to Django and i am unable to properly handle redirects from one app to another. I have 2 apps Accounts, Dashboard. Accounts Handles login and registration of AuthUser. Dashboard handles other functionality like Fileupload So far, I have successfully using reverse() method have redirected from /accounts/login to my upload page but it redirects from /accounts/login to /accounts/upload instead of /dashboard/upload . Project URLS urlpatterns = [ path('dashboard/', include('Dashboard.urls')), path('accounts/', include('Accounts.urls')), path('admin/', admin.site.urls), ] Account urls.py urlpatterns = [ url('upload',DashboardViews.upload, name='upload'), path('login', views.login, name='Login'), path('register', views.register, name='Register'), path('logout', views.logout, name='logout') ] Account views.py def login(request): if request.method == 'GET': return render(request, 'login.html') if request.method == 'POST': user_name = request.POST.get("username") password = request.POST.get("password") user = auth.authenticate(username=user_name,password=password) if user is not None: auth.login(request,user) return redirect(reverse('upload')) else: print('Failed') return render(request,'login') My intention is whenever user (login/register), web page should redirect from /account/login to /dashboard/upload. -
Unexpexted MultiValueDictKeyError in signup code
I am new to Django. I am creating a signup page. But I am having an unexpected MultiValueDictKeyError with Exception value fname. I am not able to get it. Kindly help me to solve it -
Seo Analysis Tool for Django
is there any SEO Analysis tool (like Yoast SEO plugin for Wordpress) for Django? -
Unable to create a superuser after deploying to heroku(KeyError: 'createsuperuser')
I was able to deploy to Heroku but I am unable to create superuser. Command I want to run: heroku run python manage.py createsuper Error I am getting: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 204, in fetch_command app_name = commands[subcommand] KeyError: 'createsuper' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 16, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 211, in fetch_command settings.INSTALLED_APPS File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/app/.heroku/python/lib/python3.6/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 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'mysite.settings' -
Django-Storages ('`data` must be bytes, received', <class 'str'>) when saving a model field
I read through the django-storages docs which suggest using the following to save files to cloud storage (GCS in my case): >>> obj2 = Resume() >>> obj2.pdf.save('django_test.txt', ContentFile('more content')) >>> obj2.pdf <FieldFile: tests/django_test_.txt> >>> obj2.pdf.size However, following the same logic, I'm struggling to save a Pandas DataFrame as a CSV using FileField object: My code: df = load_some_df() print(df.head()) # prints contents of df contents = ContentFile(df.to_csv(index=False, header=True)) output_file_name = 'df.csv' instance = MyModel() instance.output_file.save(output_file_name, contents) The above gives me the error: ('`data` must be bytes, received', <class 'str'>) -
Django - converting datetime.date tuples
I'm trying to get some dates from my model. In my queryset I get: datetime.date(2019, 10, 15), datetime.date(2019, 10, 18), datetime.date(2019, 10, 2), datetime.date(2019, 9, 18), datetime.date(2019, 10, 28), datetime.date(2019, 10, 29)] when querying the DB for my "reservation dates". I need them to convert to normal dates,and if possibile,format them like this: "19-10-2019" So, dd-mm-yy format. I created a monstrosity to do this for me, wich (kinda sometimes) works...I will show the monster just for lols. here you go : var unavailableDates = "{{ unavailable_dates }}" unavailableDates = unavailableDates.replace(/datetime.date/g, "").replace(/[{()}]/g, "").replace(/]/g, ' ').replace("[", ' ').split() var y = unavailableDates[0].match(/.{1,14}/g) var dates = [] y.forEach((date, i) => { var now = moment(date).format('D-MM-YYYY') dates.push(now) }) console.log(dates); function unavailable(date) { dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear(); if ($.inArray(dmy, dates) == -1) { return [true, ""]; } else { return [false, "", "Unavailable"]; } } $(function () { $("#datepicker").datepicker({ dateFormat: 'yy-mm-dd', beforeShowDay: unavailable }) }) What would be the correct way of achieving what I want to do here ? Thanks so much ! -
good practices in django authentication system
I have a question, when adding the authentication urls of the auth application (django.contrib.auth.urls). Where should I add the templates? (login.html, etc) I have seen that they add in the templates folder of the project: project > templates > registration > login.html ... I've also seen that they do it in an application called registration: |-- project |-- registration |-- templates | |-- registration | |-- login.html | .... | |-- __init__.py |-- admin.py ..... But that name doesn't convince me much, I've also seen that they do it in applications called users andaccounts In which app should I do it? (accounts, users, registration) which one is best practice? I also want to comment that I am creating a custom user model, and I think it should go in one of these apps right? It would be the most logical, according to the name of the app. -
Redirecting correctly HTTP to HTTPS using Django and Nginx
Hi here's my problem. I'm trying to redirect my website from HTTP to HTTPS and I've succeeded partially doing so. The thing is, when I type mywebsite.fr, I get the name of the service of the container that contains the website's code in my address bar (e.g. djangoapp/) with a DNS_PROBE_FINISHED_NXDOMAIN error. Now, I tried the same thing with another Chrome browser of a another computer and this time when I type www.mywebsite.fr I get the same result where as the non-www is correctly redirected to the secure address. Finally, I tried the exact same process using my smartphone (Brave) with the www and non-www, I get https://djangoapp with an error ERR_NAME_NOT_RESOLVED whereas when I explicitly type https:\\mywebsite, I get no issues. So here is the NGINX portion that redirects to the HTTPS server: server { ... location / { return 301 https://djangoapp$request_uri; } } This is the location in the HTTPS server that refers to the upstream: server { ... location / { ... proxy_pass http://djangoapp; } } And, this is the service that runs the code: djangoapp: build: . ports: - "8000:80" links: - db depends_on: - db I do not master yet all the intricacies of NGINX … -
Hi, I am looking to create a form that displays a drop down menu with items specific to that user
I am looking to create a form that displays a drop down menu with items specific to that user. Please note my original code has no errors, I have summarised this one for simplicity. So let's say I have a form like this: html doc: <form> <p>Select a car:</p> <p>{{ form.car_name }}</p> </form> My models look like this: models.py class LoggedInUser(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='logged_in_user', on_delete=models.CASCADE) session_key = models.CharField(max_length=32) class Car(models.Model): car_name = models.CharField(max-length=100) car_owner = models.ForeignKey(LoggedInUser, on-delete=models.CASCADE) class SavedCars(models.Model): car_name = models.ForeignKey(Car, on-delete=models.CASCADE) I then created the form class as such: form.py class CarSelect(forms.Modelform): class Meta: model = SavedCars fields = [ 'car_name', ] As you can see. This current form setup gives me options to select ALL cars in that table even ones that are not assigned to a user. Which means on the form, every user can select any car. Not the desired result. I understand that a user has to be assigned a set of cars to choose from, So I tried this: class LoggedInUser(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='logged_in_user', on_delete=models.CASCADE) session_key = models.CharField(max_length=32) car_select = models.ManyToManyField(Car) // which detects the user selecting the car but this isn't my form. :( And this is obviously not possible: … -
ChoiceField disappears after overriding init method of BaseForm class
My application from an uploaded CSV file, reads header values and passes these headers into another class which extends Form. The goal was to populate this passed headers list finally into ChoiceField. To get the arguments, I overrode __init__. Somehow on overriding the __init__, my choicefield disappears, without any exception appearing. The choiceField appears when I am directly using ChoiceFields and not overriding the __init__ method. I tried modifying and working on different ways of overriding to get the arguments but could not succeed as in every case the ChoiceField goes missing. I am using python version 3.7.1 and Django version 1.9.8. Any advice would be appreciated. 1.views.py: def simple_upload(request): if request.method == 'POST' and request.FILES['myfile']: myfile = request.FILES['myfile'] fs = FileSystemStorage() fs.save(myfile.name, myfile) for row in myfile: headerlist = row.decode('utf-8').split(",") break expense_form = ExpenseForm(headerlist) return visualize_view(request, expense_form) return render(request, 'core/simple_upload.html') def visualize_view(request, expense_form): return render(request,'core/visualize_view.html',{'expense_form':expense_form}) 2.forms.py : from django import forms class ExpenseForm(forms.Form): def __init__(self, headerlist, *args, **kwargs): super(ExpenseForm,self).__init__(*args, **kwargs) CHOICES = [] for i in range(len(headerlist)): c = (i, headerlist[i]) CHOICES.append(c) columns = forms.ChoiceField(choices=CHOICES) 3.visualize.py: {% extends 'base.html' %} {% block content %} {{ expense_form.as_p }} {% endblock %} -
Update last inserted record in Django
In Django, I want to retrieve the last inserted record from the database and update its values. I use this model: def User(models.Model): name = models.CharField(max_length=15) I run the following code to retrieve the last inserted record and update the name: User.objects.last().update(name=‘NEW NAME’) However, the error is that update is not a known method. Does .last() indeed return the entire record, or only the primary key? Thank you very much. -
TypeError: __init__() got an unexpected keyword argument 'choices'
TypeError: init() got an unexpected keyword argument 'choices' forms.py class StudentMarksheetform2(forms.Form): subject_code=( (1,'CS101') ,(2,'CS102') ,(3,'CS103') ,(4,'CS104') ,(5,'CS105') ,(6,'CS106') ) code_title=forms.IntegerField(choices=subject_code,default='1') class Meta(): model=StudentMarksheetdata2 fields=['code_title'] -
How can you specify where to create a virtual environment using pipenv?
I'm learning django and just installed pipenv via pip install pipenv and then pipenv shell and I notice that the virtual environment files are installed or created in some random default directory, I have two questions regarding this: 1) How can I customize that installation/creation directory for the virtual environment? Do I have to use a different command line from pipenv shell? 2) Can you have multiple folders with different virtual environments inside each folder/project?