Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Ajax Call to Return Quantity
Currently using the django-carton app, I have a django view that returns JSON data that I use in an ajax call. Broadly speaking, I have got it working but struggling to work out how I can pass my item quantity (using ajax). Within the template I can call my item quantities using: {% for item in cart.items %} {{ item.quantity }} The ajax call connects to the view to return the Json data: def cart_detail_api_view(request): # cart_obj, new_obj = Cart.objects.new_or_get(request) cart = Cart(request.session) products = [{"name": x.name, "price": x.price} for x in cart.products] cart_data = {"products": products, "total": cart.total} return JsonResponse(cart_data) This is my Jquery/Ajax call: $(document).ready(function() { var productForm = $(".form-product-ajax") // #form-product-ajax productForm.submit(function(event) { event.preventDefault(); // console.log("Form is not sending") var thisForm = $(this) //var actionEndpoint = thisForm.attr("action"); var actionEndpoint = thisForm.attr("data-endpoint"); var httpMethod = thisForm.attr("method"); var formData = thisForm.serialize(); $.ajax({ url: actionEndpoint, method: httpMethod, data: formData, success: function(data) { var submitSpan = thisForm.find(".submit-span") if (data.added) { submitSpan.html("In cart <button type='submit' class='btn btn-link'>Remove?</button>")} var currentPath = window.location.href if (currentPath.indexOf("") != -1) { refreshCart() } }, error: function(errorData) { console.log("error") console.log(errorData) } }) }) function refreshCart() { console.log("in current cart") var cartTable = $(".cart-table") var cartBody = cartTable.find(".cart-body") // … -
Twitter API and Python 3: Authorization error in apparently perfectly authorized request
Following this doc, I finally got the steps 1 and 2 working by copypasting this answer. Why my original solution didn't work is still beyond me, but whatever I was doing wrong there seems to carry on in this third step, since I get an HTTP Error 401: Authorization Required. The Oauth header I produce is the following: Oauth oauth_consumer_key="omitted", oauth_nonce="ozlmgbmrxftmmfaxnngbpsulickqwrkn", oauth_signature="3ZxJu%252Bv%2FjxyPmghiI85xnuPv3YQ%253D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1518820400", oauth_token="omitted", oauth_version="1.0" which seems to be exactly the way the doc I linked in the beginning wants it. So maybe my signature is wrong? I can't really figure it out since I do it in a pretty standard way. This is my code for the callback url up until the request to oauth/access_token: def logged(request): print('Processing request from redirected user...') token = request.GET.get('oauth_token', '') user = twitterer.objects.get(oauth_token=token) #my model for the user that's signing in with twitter verifier = user.oauth_verifier = request.GET.get('oauth_verifier', '') url = 'https://api.twitter.com/oauth/access_token' dir_path = path.dirname(path.realpath(__file__)) with open(path.join(dir_path, 'credentials.txt'), 'r') as TweetCred: creds = TweetCred.read().split(linesep) oauth_consumer_key = creds[0].split()[1] consumer_secret = creds[2].split()[1] oauth_nonce = '' for i in range(32): oauth_nonce += chr(random.randint(97, 122)) oauth_timestamp = str(int(time.time())) parameter_string = parameter_string = 'oauth_consumer_key=' + oauth_consumer_key + '&oauth_nonce=' + oauth_nonce + '&oauth_signature_method=HMAC-SHA1&oauth_timestamp=' + oauth_timestamp + '&oauth_token=' + … -
Link to a different view's template from one template Django
enter image description here I have a template that displays a detail of a dorm with a list of "room_numbers". The problem: I am trying to make "room_numbers" as a link to each specific dorm room details page (see screenshot above). A dorm room details page has the following format: rooms/<int:pk> as specified in my urls.py I have scoured through the web and can't find where I need to start. Django and Python newbie here so please bear with me. URLs.py > urlpatterns = [ path('', views.index, name='index'), path('list/', views.DormsListView.as_view(), name='dorms'), path('list/<int:pk>', views.DormsDetailView.as_view(), name='dorm-detail'), path('rooms/', views.DormsRoomView.as_view(), name='rooms'), path('rooms/<int:pk>', views.DormsRoomsDetailView.as_view(), name='rooms-detail'), ] Views.py (DormsDetailView) > class DormsDetailView(LoginRequiredMixin, generic.DetailView): model = Dorm def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['room_numbers'] = ", ".join(self.object.dormroom_set.values_list('room_number', flat=True)) return context Views.py (DormRoomsDetailView) > class DormsRoomsDetailView(LoginRequiredMixin, generic.DetailView): model = DormRoom Dorm_Detail.html > <div>Rooms: {{ room_numbers }}</div> -
Django: TemplateSyntaxError, Invalid filter
I'm trying to access a value from a dictionary using a variable, all in an HTML file that follows Django's Templating language. Django's templating language doesn't let you access a dictionary using a variable as a key, so I decided to use Django filters to do it. However, I am getting a "Invalid filter" error and I can't figure out why. My html file <table class="table"> <tbody> <tr> <th scope="row">Username</th> <th scope="row">Full Name</th> <th scope="row">Points</th> {% for subject in subjects %} <th scope="row">{{ subject }}</th> {% endfor %} </tr> {% for user in users %} <tr> <td> <a href="{% url 'profile' username=user.username %}">{{ user.username }}</a> </td> <td>{{ user.first_name }} {{ user.last_name }}</td> <td>{{ user.profile.points.total }}</td> {% for subject in subjects %} <td>{{ user.profile.points|keyvalue:subject }}</td> {% endfor %} </tr> {% endfor %} </tbody> My filter.py from django import template register = template.Library() @register.filter def keyvalue(dict, key): return dict[key] My error message TemplateSyntaxError at /leaderboard/ Invalid filter: 'keyvalue' Thank you for any help :D -
sudo: unknown user: root via PythonAnywhere
I'm using PythonAnywhere with Postgresql, and have run into several problems. When I try to do anything, such as python manage.py makemigrations, I get the following error : sudo: unknown user: root sudo: unable to initialize policy plugin Also, I tried to use postgres -V, but I get command not found, and yet I can't use sudo to install it. Finally, I'm also not sure what my UNIX password is, but all my permissions are denied to me. Strangely, I've noticed the creation of a dead.letter file, which contains: giles-liveconsole1 : Feb 17 09:25:05 : DMells123 : user NOT in sudoers ; TTY=unknown ; PWD=/home/DMells123/nomadpad/blog ; USER=DMells123 ; COMMAND=/bin/bash giles-liveconsole2 : Feb 17 11:43:08 : DMells123 : user NOT in sudoers ; TTY=unknown ; PWD=/etc ; USER=#0 ; COMMAND=/usr/bin/vi /etc/passwd giles-liveconsole2 : Feb 17 11:45:51 : DMells123 : user NOT in sudoers ; TTY=unknown ; PWD=/etc ; USER=#0 ; COMMAND=/usr/bin/vi /etc/passwd -
Contact_form not found when adding contact form in Django
I get a message contact form not found when trying to add a contact form in Django. I follwed this guide. https://atsoftware.de/2015/02/django-contact-form-full-tutorial-custom-example-in-django-1-7/ This should have worked. contact/contact_form.html Request Method: GET Request URL: http://127.0.0.1:8000/contact/ Django Version: 2.0 Exception Type: TemplateDoesNotExist Exception Value: contact/contact_form.html Exception Location: /home/karl/django/venv/lib/python3.5/site-packages /django/template/loader.py in get_template, line 19 Python Executable: /home/karl/django/venv/bin/python Python Version: 3.5.2 Python Path: ['/home/karl/django/myproject', '/home/karl/django/venv/lib/python35.zip', '/home/karl/django/venv/lib/python3.5', '/home/karl/django/venv/lib/python3.5/plat-x86_64-linux-gnu', '/home/karl/django/venv/lib/python3.5/lib-dynload', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/home/karl/django/venv/lib/python3.5/site-packages'] Settings.py INSTALLED_APPS = [ 'personal', 'blog', 'writing', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'contact', 'contact_form', I set up the email address. root urls. urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'contact', include('contact.urls')), url(r'^', include('personal.urls')), url(r'^blog/', include('blog.urls')), url(r'^writing/', include('writing.urls')), url(r'^contact/', include('contact.urls')), ] contact urls.py from django.conf.urls import url, include from django.contrib import admin from . import views urlpatterns = [ url(r'^$', views.index), ] contact views.py from django.shortcuts import render def index(request): return render(request, 'contact/contact_form.html') Please help. -
Pass API Keys to GET Request in Python
We are trying to GET data from multiple endpoints in Django using the below format. How do we pass variables through to the endpoint? (settings.EXAMPLE_API_KEY) is a single API key. We have a multitude of API keys stored securely. orders_endpoint = 'https://{api_key}:{password}@{shop}.example.com/admin/orders/count.json' orders_url = orders_endpoint.format(api_key=settings.EXAMPLE_API_KEY, password=settings.EXAMPLE_PASSWORD, shop=settings.EXAMPLE_SHOP) orders_response = requests.get(orders_url) orders_json = orders_response.json() orders = mark_safe(json.dumps(orders_json)) -
Display List of objects from another Model Django
I am new to stackoverflow and I don't know how to properly paste Django code. Please bear with me. Anyway, here's my problem: "I want to display DormRoom.room_number in a template as a list (sample: Rooms: 401, 402, 403, 404, etc)." enter image description here Models.py > class Dorm(models.Model): dorm_name = models.CharField(max_length=50, help_text="Enter dorm name") dorm_description = models.TextField(max_length=1000, help_text="Enter dorm description") dorm_primary_picture = models.ImageField(help_text="Enter dorm primary pic") dorm_room_count = models.IntegerField(help_text="Enter no. of rooms") dorm_address = models.CharField(max_length=100,help_text="Enter dorm address") dorm_caretaker = models.CharField(max_length=50,help_text="Enter caretaker name") dorm_contact_no = models.CharField(max_length=50,help_text="Enter dorm contact number") dorm_contact_email = models.EmailField(max_length=254,help_text="Enter dorm email") dorm_date_added = models.DateTimeField(help_text="Enter Date Dorm was created") dorm_availability = models.CharField(max_length=50, help_text="Is dorm available") dorm_date_updated = models.DateTimeField(help_text="Enter Date Dorm information was updated") dorm_house_rules = models.TextField(max_length=1000, help_text="Enter dorm house rules") class Meta: ordering = ["-dorm_name"] def get_absolute_url(self): return reverse('dorm-detail',args=[str(self.id)]) def __str__(self): return self.dorm_name class DormRoom(models.Model): room_number = models.CharField(max_length=20, help_text="Enter room number") room_maxusers = models.IntegerField(help_text="Enter maximum # of room users") room_dorm = models.ForeignKey(Dorm, on_delete=models.CASCADE) room_count = models.IntegerField(help_text="Enter # of rooms in this Dorm room") def get_absolute_url(self): return reverse('rooms-detail', args=[str(self.id)]) def __str__(self): return self.room_number class Meta: ordering = ('room_number',) URLs.py > from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), path('list/', views.DormsListView.as_view(), name='dorms'), path('list/<int:pk>', views.DormsDetailView.as_view(), … -
Group by and count values
Im new to Django. I have different classes (Stock, Portfolio, Trades) What Im trying to achieve is a summery of all trades per stock. So Basicly this is how my rows are now I want to combine or group by stock_id and do a sum of open_price and quantity. I tried with Trade.objects.filter(portfolio=1).values('stock__name').aggregate(stock_total=Count('stock',distinct=True)) But that doesnt work. How do I need to write the query to get that result? -
Load the csv data using html view into django database
I am trying to load a simple csv file into django model named as class Team class Team(models.Model): Team = models.CharField(max_length=255,primary_key=True) Description = models.CharField(max_length=255) def __str__(self): return self.Team I have create a simple html page to load the file into the following location MEDIA_ROOT=os.path.join(BASE_DIR,"media") I am able to load my file into that location but I need some help with passing on the data to the actual database and load the values into the table "Team". Any suggestiond on this? -
Django: Use inline with One to One field
I have 3 models User,Student and Teacher. class User(..): username=.. firstname=.. more_fields.. class Student(..): user = models.OneToOneField(User, ..) a = .. more_fields.... class Teacher(..): user = models.OneToOneField(User, ..) b = .. more_fields..... At admin side I want Student and Teacher models to be displayed such that I can fill fields of User table when I add new Student/Teacher i.e Add Student form should have User model Stacked below it. I am getting errors while using inlines that User model does not have foreign key to Student model -
Django Carton App - Getting Ajax Working
I am using the Django Carton shopping cart add on and have got it working. I am now trying to add to cart via an ajax call and struggling to get the code working. I get an error which says "TypeError at /api/cart/↵Object of type 'property' is not JSON serializable" (on the Chrome Console). Views.py class ProductListView(ListView): (redacted for clarity) def add(request): cart = Cart(request.session) product = Product.objects.get(id=request.POST.get('id')) cart.add(product, price=product.price) added = True if request.is_ajax(): print("Ajax request") json_data = { "added": added, } return JsonResponse(json_data) return redirect('list') def remove(request): cart = Cart(request.session) product = Product.objects.get(id=request.GET.POST('id')) cart.remove_single(product) return redirect('list') def show(request): return render(request, 'carts/carts.html') def cart_detail_api_view(request): # cart_obj, new_obj = Cart.objects.new_or_get(request) cart = Cart(request.session) products = [{"name": x.name, "price": x.price} for x in cart.products.all()] cart_data = {"products": products, "total": Cart.total} return JsonResponse(cart_data) HTML Template: {% for product in cat_appetizers %} <form method="POST" class='form-product-ajax' action='{% url "shopping-cart-add" %}' data-endpoint='{% url "shopping-cart-add" %}'> {% csrf_token %} {{ product.name }} <input type="hidden" name='id' value='{{ product.id }}'> <br/> <span class='submit-span'> <button>Add to Basket</button> </span> </form> <br/> {% endfor %} {% load carton_tags %} {% get_cart as cart %} <div> <h4>This is your shopping cart</h4> <table class="cart-table"> <tbody class="cart-body"> <tr>These are the items in your basket … -
Django makemigrations error?
I'm new started to Django.where is my fault? -
Download static file displayed in the list Django
I am trying to make static files download-able from the template of my Django app. def list(request): folder = '/home/galander/Desktop/Projekty/django-pdf-generator/django-pdf/generator/static/pdfs' file_list = os.listdir(folder) return render_to_response('list.html', {'file_list': file_list}) def download_file(request): pdf_folder = '/home/galander/Desktop/Projekty/django-pdf-generator/django-pdf/generator/static/pdfs' response = HttpResponse(pdf_folder, content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="nowy.pdf"' return response list.html {% for file in file_list %} <a href="/home/galander/Desktop/Projekty/django-pdf-generator/django-pdf/generator/static/pdfs/{{ file }}">{{ file }}</a> {% endfor %} My current output is rather obvious at the moment - Django is looking for matching url pattern and it fails. My filename="nowy.odf" in download_file(request): is hard-coded atm just for testing purposes. 2 Solutions I am thinking of: 1) Create appropriate regex for url pattern in url.py to satisfy redirection to my download_file view which i fail to accomplish 2) I should change the display method for my static/pdf folder somehow All tips appreciated ! -
Django template - get object's choice field text
This is my model: class Person(models.Model): ... DOP = 1 PPP = 2 contract_choices = ( (DOP, 'always'), (PPP, 'sometimes'), ) contract = models.CharField(max_length=3, choices = contract_choices) ... I need contract field value in my template: {% for person in persons %} {{ person.get_contract_display }} {% endfor %} gives me '1' (or '2') instead of 'always' (or 'sometimes'). How can i get that string text instead of integer value? -
Pip/Django only works through CMD when there's no file path
Pip usually works fine when installing modules but when I shift-right-click on a folder and open cmd with that file path, Pip and Django are not recognised as internal or external command, operable program or batch file. -
Django - Want to search each words in a sentece using filter
I want to search each word in a sentence and put that is result['post'] dictionary but this code only search last query queries = querystring.split() for query in queries: results['posts'] = Post.objects.filter(text__icontains=query) i tried appending,extending and a lot of things but it didn't work. -
django-why bootstrap already loaded but gave no effect on the page?
hi guys im new to django, now im facing problem that the already loaded bootstrap template gave no effect on the page. i have read several post of this problem in this site, but none of it work. i use python 3.6.4 and django 2.0. here is my settings.py: STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"), ] installed apps: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rango' ] my index.html: <!DOCTYPE html> {% load staticfiles %} <html> <head> <title>Rango</title> <!-- CSS --> <link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.css" %}" /> the command prompt said: [17/Feb/2018 20:06:14] "GET /static/css/bootstrap.css HTTP/1.1" 200 178152 when i call an image from same static folder, it can show the picture <img src="{% static "images/alif.jpg" %}" width="500px" height="800px" alt="foto alif"> my debug set True and i use virtual environment i also check on chrome developer tools>network>css. it said the css run my folder structure: tango | static | css | bootstrap.css can anyone help me to solve this? -
No module named django_select2
I'm trying to run an example from the django-SHOP framework. Following their tutorial on running the example, I get the following error: Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute django.setup() File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/apps/config.py", line 94, in create module = import_module(entry) File "/home/agozie/anaconda3/envs/env1/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: No module named django_select2 I've installed django_select2 but it still throws the error. Any ideas? -
Django2 How can i make some conditions in my Class based View
please i have an issue , i want to check the difference between two dates from my form, then allows to create the object using my class based_View if the date is bigger than an other attribute, if not render it to an other page without inserting nothing in the database.here is my # view class AddVacation(LoginRequiredMixin, CreateView): form_class = VacationCreateForm template_name = 'vavcation.html' login_url = 'login' def form_valid(self, form): instance = form.save(commit=False) instance.employee = self.request.user return super(AddVacation, self).form_valid(form) # form: class VacationCreateForm(forms.ModelForm): class Meta: model = VacationModel fields = [ 'type', 'startDate', 'enddate', ] -
Django - ImportError : no module named django.core.wsgi
I am trying to deploy my Django application with Apache and mod_wsgi. I installed and configured them according to following references:- https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/modwsgi/ My django project tree - /home/zahlen mysite ├── db.sqlite3 ├── log │ ├── access.log │ └── error.log ├── manage.py ├── mysite │ ├── __init__.py │ ├── settings.py │ ├── static │ ├── templates │ ├── urls.py │ ├── views.py │ ├── wsgi.py ├── places │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── migrations │ ├── models.py │ ├── static │ ├── templates │ ├── tests.py │ ├── urls.py │ ├── views.py └── static django is present in /home/zahlen/.local/lib/site-packages //apache2/apache2.conf .... .... LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so WSGIPythonPath /home/zahlen/mysite:/home/zahlen/.local/lib/site-packages <Directory /home/zahlen/mysite/mysite> <Files wsgi.py> Require all granted </Files> </Directory> //apache2/sites-available/000-default.conf VirtualHost Configuration <VirtualHost *:80> ServerName www.mysite.com ServerAlias mysite.com ServerAdmin webmaster@mysite.com DocumentRoot /home/zahlen/mysite Alias /static /home/zahlen/mysite/mysite <Directory /home/zahlen/mysite/static> Require all granted </Directory> ErrorLog /home/zahlen/mysite/log/error.log CustomLog /home/zahlen/mysite/log/access.log combined <Directory /home/zahlen/mysite/mysite/> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess mysite.com python-path=/home/zahlen/mysite WSGIProcessGroup mysite.com WSGIScriptAlias / /home/zahlen/mysite/mysite/wsgi.py </VirtualHost> Django and mod_wsgi are configured to use python2.7 . Vitualenv is not used and Apache uses the Event MPM All of this is on a Ubuntu Server Virtual Machine. //log/apache2/error.log gives the following line … -
DJango display images in the grid
I want to have the this image display effect: LINK and I don't know how to do this. I'm using DJango to display images. -
Django: records that have most matching words should come up higher in the result set
This is my first app/site. I am trying to implement a search option. I have these to implement the search view: def normalize_query(query_string, findterms=re.compile(r'"([^"]+)"|(\S+)').findall, normspace=re.compile(r'\s{2,}').sub): return [normspace('',(t[0] or t[1]).strip()) for t in findterms(query_string)] def get_query(query_string, search_fields): ''' Returns a query, that is a combination of Q objects. That combination aims to search keywords within a model by testing the given search fields. ''' query = None # Query to search for every search term terms = normalize_query(query_string) for term in terms: or_query = None # Query to search for a given term in each field for field_name in search_fields: q = Q(**{"%s__icontains" % field_name: term}) if or_query is None: or_query = q else: or_query = or_query | q if query is None: query = or_query else: query = query | or_query return query def search_doctor(request): query_string = '' found_entries = None query_string = request.POST.get('doctor', None).strip() if query_string: entry_query = get_query(query_string, ['full_name']) found_entries = User.objects.filter(entry_query, groups__name='Doctor') #.order_by('first_name') context = { 'query_string': entry_query, 'doctors': found_entries } #return redirect('health:doctors' ) return render(request,'doctors_search_list.html', context ) It does search records but I am looking for a way to show records that have most matching search terms in them come up higher in the order. Can … -
Receive and process JSON using fetch API in Javascript in combination with Django
In my Project when conditions are insufficient my Django app send JSON response with message. I use for this JsonResponse() directive, Code: data = { 'is_taken_email': email } messages.error(request, 'Email is already used!') return JsonResponse(data) Now I want using Javascript fetch API receive this JSON response and for example show alert. I don't know how to use fetch API to do this. I want to write a listener who will be waiting for my JSON response from Django App. I try: function reqListener() { var stack = JSON.parse(data); console.log(stack); } var oReq = new XMLHttpRequest(); Thanks in advance! -
Collectstatic - permission denied, pythonanywhere bash terminal
I'm trying to use the collectstatic command in pythonanywhere's bash terminal, python manage.py collectstatic, but I get : PermissionError: [Errno 13] Permission denied: '/static' Please can anyone help? I've been trying to fix this for two days now! Here's the full error : nomadpad-virtualenv) 11:51 ~/nomadpad (master)$ python manage.py collectstatic Copying '/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/djang o/contrib/admin/static/admin/img/inline-delete.svg' Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/init.py", line 364, in execute_from_command_line utility.execute() File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/init.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/base.py", line 283, in run_from_argv self.execute(*args, cmd_options) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/base.py", line 330, in execute output = self.handle(*args, options) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /contrib/staticfiles/management/commands/collectstatic.py", line 199, in handle collected = self.collect() File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /contrib/staticfiles/management/commands/collectstatic.py", line 124, in collect handler(path, prefixed_path, storage) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /contrib/staticfiles/management/commands/collectstatic.py", line 364, in copy_file self.storage.save(prefixed_path, source_file) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/files/storage.py", line 54, in save return self._save(name, content) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/files/storage.py", line 321, in _save os.makedirs(directory) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/static'