Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Custom Permission for Authorization
I am working on a Django Project, where one model (lets say Document) has the following field: #In models.py class Document (models.Model): choice=(('Yes','Yes'), ('No','No)) authorized = models.CharField (max_length=3, choices=choice, default='No') Now, as a normal user creates a Document object, the authorized field is no. However, the superior needs to authorize the same before it is actually approved. Now, is there a permission system in django where one user can create an object but not authorize, whereas some other user - who has the permission - can authorize? If not, is the only way to do it is to create a custom field in user model and check it every time? -
NoReverseMatch Django with negative content_type_id
I know for some this question may seem similar to other NoReverseMatch Errors, but it isn't I am using Djangae Framework over Django, to support Google Appengine. I have made a Custom GaeDatastoreUser, extending GaeAbstractBaseUser, and registered the model with admin.site.register(). models.py class ChatUser(GaeAbstractBaseUser, PermissionsMixin): # ID Constants class Meta: app_label = "chat_auth" swappable = 'AUTH_USER_MODEL' verbose_name = _('chat user') verbose_name_plural = _('chat users') app_id = models.CharField(_('app_id'), max_length=64, blank=True, null=True) gcm_key = models.CharField(_('key'), max_length=128, blank=True, null=True, unique=True) mobile = models.CharField(_('mobile'), max_length=10, default="", null=True) Viewing the list of all custom users at /admin/chat_auth/chatuser/ on Django's Admin Site is working, but whenever I select a particular user to modify/delete it, I get a NoReverseMatch at /admin/chat_auth/chatuser/5818821692620800/change/ Reverse for 'view_on_site' with arguments '()' and keyword arguments '{'object_id': 5818821692620800L, 'content_type_id': -4929820764642951528L}' not found. 1 pattern(s) tried: [u'admin/r/(?P<content_type_id>\\d+)/(?P<object_id>.+)/$'] As you can see I am getting a negative ContentType ID for any custom admin user (I don't know why). I have changed AUTH_USER_MODEL, and done everything djangae's documentation said. If I try to use djangae's default GaeDatastoreUser, these links work fine, only when I make a custom user, these links don't work. Do I need to change something in urls.py, but I don't think so, else β¦ -
Trying to view User Profile in Django, but Page Not Found when searching URLs
I am trying to view a user profile for my website with the Detail CBV. Below is the code for views.py, urls.py, models.py and profile.html. A user exists with the username "brian_weber", but for some reason when I navigate to this link: http://0.0.0.0:8000/accounts/profile/brian_weber the page is not found. My app is called "accounts". If someone could point me in the right direction to get the view to show up with the url, that would be greatly appreciated! I have searched around Stack Overflow, but nothing has worked that I tried. Thanks in advance, Brian views.py from django.shortcuts import render from django.shortcuts import get_object_or_404 from django.contrib.auth import login, logout, authenticate from django.http import HttpResponseRedirect from django.contrib.auth.forms import AuthenticationForm from django.core.urlresolvers import reverse, reverse_lazy from django.views import generic from braces.views import LoginRequiredMixin from django.contrib.messages.views import SuccessMessageMixin from . import forms from . import models class LoginView(generic.FormView): form_class = AuthenticationForm success_url = reverse_lazy('home') template_name = "accounts/login.html" def get_form(self, form_class=None): if form_class is None: form_class = self.get_form_class() return form_class(self.request, **self.get_form_kwargs()) def form_valid(self, form): login(self.request, form.get_user()) return super().form_valid(form) def logout_view(request): logout(request) return HttpResponseRedirect(reverse('home')) class SignUp(SuccessMessageMixin, generic.CreateView): form_class = forms.UserCreateForm success_url = reverse_lazy("login") template_name = "accounts/signup.html" success_message = "Your profile has been successfully created. Please log β¦ -
Dynamic choice option for individual fields in MultiValueField in Django
Here I have MultiValueField with three ModelChoiceField. The field choices are depend upon the previous filed . For Example second field (ClassSectionField) choices depend upon first field (AcademicFiled) value . class AcademicStudentField(forms.MultiValueField): def __init__(self,*args, **kwargs): error_messages = { 'incomplete': 'select Academic year , grade section and student', } AcademicFiled = forms.ModelChoiceField(queryset=AcademicYear.objects.all(), error_messages={'incomplete': 'Select Academic Year.'},required=True,widget= widgets.Select(),empty_label='Academic Year') ClassSectionField =ChainedModelChoiceField(model=UnitGradeSection,parent_field='%(name)s_0',ajax_url=reverse_lazy('configuration:ajax_ugs'),error_messages={'incomplete': 'Select Class Section .'},empty_label='Class Section',required=True) StudentFiled = ChainedModelChoiceField(model=StudentSection,parent_field='%(name)s_1',ajax_url=reverse_lazy('student:ajax_student_section'),error_messages={'incomplete': 'Select Student.'},empty_label='Students',required=True ) fields = (AcademicFiled,ClassSectionField,StudentFiled ) widget = AcademicStudentWidget(widgets=[fields[0].widget, fields[1].widget, fields[2].widget]) super(AcademicStudentField, self).__init__( error_messages=error_messages, fields=fields,widget=widget, require_all_fields=True, *args, **kwargs ) def compress(self, data_list): if data_list: return {'academic':data_list[0],'ugs':data_list[1],'stu_sec':data_list[2]} class AcademicStudentWidget(widgets.MultiWidget): def __init__(self, widgets,attrs=None): super(AcademicStudentWidget, self).__init__(widgets, attrs) def decompress(self, value): if value: return [value['academic'], value['ugs'], value['stu_sec']] return [None, None, None] In form init function , I can set choices for normal ModelChoiceField as self.fields['field_name'].choices =[my choices] and its working fine. But when I set choices for ModelChoiceField which is inside MultiValueField as self.fields['field_name'].fields[0].choices =[my choices] is not working. I want to set choices of filed in MultiValueField in form init. Please some one help me to fix this problem.... -
Store set of dates in Django and then query for specific?
Is it possible to create a model to store a set of chosen DateTime objects and query for all instances that contain a specific DateTime? e.g. class TimeOff(models.Model): employee = models.CharField(...) time_off = models.DateSetField(...) # who has monday off? free_employees = TimeOff.objects.filter(...) -
file not getting downloaded in django
Im trying to write a CSV file and download it in my browser. I was able to create a CSV file using unicodecsv(used it insted of csv to avoid unicode errors ),but im not able to download it. Following is my view.I am new to django.So please help me. import unicodecsv from django.views.generic import View class ExportToCsvView(View): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super(ExportToCsvView, self).dispatch(request, *args, **kwargs) def post(self, request, *args, **kwargs): places_list=[] pk_list=[] if request.POST.get('area_choice')!= "all": for area in Area.objects.filter(pk__in=self.request.POST.getlist('area_choice')): places_list.append(FizPlace.objects.filter(coordinates__intersects=area.polygon)) for place in places_list: for p in place: pk_list.append(p.pk) self.places=FizPlace.objects.filter(pk__in=pk_list) else: self.places=FizPlace.objects.all() if request.POST.get('provider_choice')!="all": self.places=self.places.filter(provider=self.request.POST.get('provider_choice')) if request.POST.get('category_choice')!="all": total_types=[] for master in MasterType.objects.filter(pk=self.request.POST.get('category_choice')): total_types= master.types.all() self.places=self.places.filter(types__in =total_types) if request.POST.get('type_choice')!="all": types=Type.objects.filter(pk=self.request.POST.get('type_choice')) self.places=self.places.filter(types__in =types) if request.POST.get('score_choice')!="all": self.places=self.places.filter(score=self.request.POST.get('score_choice')) if request.POST.get('fiz_approved_choice')=="on": self.places=self.places.filter(fiz_approved=True) else: self.places=self.places.filter(fiz_approved=False) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="places.csv"' writer = unicodecsv.writer(response, encoding='utf-8') for place in self.places: writer.writerow([place.name]) #print response return response -
Django Mezzanine custom template not showing
From Mezzanine docs: The view function mezzanine.pages.views.page() handles returning a Page instance to a template. By default the template pages/page.html is used, but if a custom template exists it will be used instead. The check for a custom template will first check for a template with the same name as the Page instanceβs slug, and if not then a template with a name derived from the subclass modelβs name is checked for. The question is does it mean for custom Pages there is no need to create a urls.py to display the custom templates? I created a custom template named after the Page instance slug inside my apps templates directory and it's not showing. -
Django: Popup message not showing using Bootbox
I am trying to display a Bootbox, which uses bootstrap modals, and make it display with some defined messages that already shows up with the regular messages whenever some bootstrap buttons are clicked but no success so far. This is the code I have implemented in my base.html file to show the messages without the popup: {% if messages %} {% for message in messages %} <div class="alert alert-{{ message.tags }}">{{ message }}</div> {% endfor %} {% endif %} Now, I dont want to use that anymore and want to use the Bootbox library. This is how I have it implemented in my javascript.html file: {% load staticfiles %} <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="{% static 'js/jquery.formset.js' %}"></script> <script src="{% static 'js/moment.js' %}"></script> <script src="{% static 'js/transition.js' %}"></script> <script src="{% static 'js/collapse.js' %}"></script> <script src="{% static 'js/bootstrap.js' %}"></script> <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> <script src="{% static 'js/bootstrap-filestyle.min.js' %}"></script> <script src="{% static 'js/bootbox.min.js' %}"></script> <script src="{% static 'js/jquery-3.0.0.js' %}"></script> <script> $(document).ready(function(){ $('.btn').on('click', function(){ bootbox.alert(message); }); }); </script> This is the code in views.py where the message is extracted: class EpisodeActionView(ProductionRequiredMixin, RedirectView): pattern_name = 'podfunnel:dashboard' def β¦ -
django cms placeholder not in structure view
My co programmer developed a django plugin for use in a django project and on his setup, the plugin works. he can write a placeholder in the django template being used and load that with the custom plugin via the django-cms structure view. I tried doing the same thing but i noticed that the placeholder i put in the html in the same place he put it in isn't appearing in the structure view. the only placeholders appearing in the structure view and can be edited are static placeholders. placeholders entered like the ones in the django tutorial http://docs.django-cms.org/en/release-3.3.x/introduction/templates_placeholders.html and are placed with this code {% placeholder "custom_name" %} aren't appearing in the structure view. i couldn't find a similar scenario here in stackoverflow. I have a fairly similar setup to my co programmer too. i copied the same repo he's working on and i even used a dump from his postgres database in case there's something wrong with my own setup but still no luck. there are no DEBUG errors appearing in the console or the webpage so I am out of ideas. Has anyone encountered a similar situation? The django-cms we are using is version 3.1.0. Thanks -
Displaying Many to Many relationship in model admin change
So right now I have a Many to Many relationship set up like this: class Page(models.Model): owner = models.ManyToManyField(User) For the most part this works fine, when I go to the Page admin change list for an individual object, I can see the list of Users that is the Page's owner. However, when I go to the Users admin change form for an individual user, I don't see the list of Pages there. Is there a way to display this? -
Django choicefield choices not displaying
Im using a choicefield and setting 2 values - 'students', 'teachers', but for some reason when the form displays it only shows 'teachers' and not 'students'. class SignUpShortForm(SignUpForm): role = forms.ChoiceField( choices=[], widget=forms.Select(attrs={'class':'form-control'}), label='I am a...', ) self.fields['role'].choices = [('Teacher', 'Teacher2')] -
Reading user selection from Django 1.5 template without using Models
Im using Python27 with Django 1.5. i have been scowering the internet for hours without success. Is there a way to capture what the user has selected from a dropdown listbox in a template without using Models? Im looking for a direct way to read some sort of var into code in views.py. example.html <select name="num_select"> <option value="0">-----</option> <option value="10">1 - 10</option> <option value="20">10 - 20</option> <option value="30">20 - 30</option> <option value="40">30 - 40</option> <option value="all">all</option> </select> which every option i select I want to pass the value to a var in my views.py views.py def my_view(request): ... num_select = forms.????.get['num_select'] ... return blah blah.... I hope i have provided enough details for you to assist me. Not sure what else i can add. I have been going through pages of docs without success. I know how to get vars from views.py to html templates, but not vise-versa. Help is greatly appreciated. -
Django I want to create new user with default password in a form.
My process is like this. 1. type username, email from a form 2. (POST) validation 3. create new user with cleaned data and default password(which I determine) views.py if form.is_valid(): username = form.cleaned_data['username'] email = form.cleaned_data['email'] user = user.objects.create_user \ (username=username,email=email,password='default_password') user.save() It creates new user with username and email. but password is ''(Null). I checked from SQL view. but If I use Shell, it create new user with password which I set. >>>from django.contrib.auth.models import User >>>user = User.objects.create_user('username','email','default_password') well, I tried to figure out this myself. I tried making a user with username, email first then setting password with user.set_password method. I tested ideas I came up with. But I don't know why it doesnt work in a form. it didn't work with not only create_user(password attribute) but also user.groups.set(group) in a form. Thanks in advance! -
'Secret Key' Not Found In Gunicorn When Starting Gunicorn Server (On Ubuntu 16.04)
rather new to deploying django-based projects so apologies for terminologies incorrectly explained or referenced. I'm trying to deploy my django-based application onto digital ocean utilizing nginx for the proxy server. When I configure the nginx file on the /etc/nginx/nginx.conf path and the gunicorn specific server's conf file on path /etc/nginx/sites-enabled/myapplication, everything is OK with a green status on the nginx status. However, when I run a sudo systemctl status gunicorn on the CL, the server begins to boot and exits with this failed message: gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2016-10-06 19:25:19 PDT; 9s ago Process: 6265 ExecStart=/home/genericuser/Documents/myapp/src/venv/bin/gunicorn -- bind unix:/home/genericuser/Documents/myapp/src/genericuser.sock myapp.wsgi:application (code=exited) Main PID: 6265 (code=exited, status=3) Oct 06 19:25:19 ubuntu gunicorn[6265]: self._wrapped = Settings(settings_module) Oct 06 19:25:19 ubuntu gunicorn[6265]: File "/home/genericuser/Documents/myapp/src/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 116, in __init__ Oct 06 19:25:19 ubuntu gunicorn[6265]: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.") Oct 06 19:25:19 ubuntu gunicorn[6265]: ImproperlyConfigured: The SECRET_KEY setting must not be empty. Oct 06 19:25:19 ubuntu gunicorn[6265]: [2016-10-06 19:25:19 +0000] [6271] [INFO] Worker exiting (pid: 6271) Oct 06 19:25:19 ubuntu gunicorn[6265]: [2016-10-06 19:25:19 +0000] [6265] [INFO] Shutting down: Master Oct 06 19:25:19 ubuntu gunicorn[6265]: [2016-10-06 19:25:19 +0000] [6265] β¦ -
Django attachment and custom data in response
Could someone please let me know if I can add custom message in HTTP response along with a attachment in Django Here is my django response with file attachment. data = key[0] response = HttpResponse(data, content_type='text/plain') response['Content-Disposition'] = 'filename=license.txt' I also want to send additional data with response (not part of attachment) like employee id '2343'. Can it be done? Is it a good idea to add data to header ? thanks in advance! -
Pythonanywhere - ImportError: No module named 'myapp.settings'
Using Python 3.5 and Django 1.9, I was trying to deploy my app to pythonanywhere, but I keep getting this error 2016-10-07 01:44:28,879 :Error running WSGI application Traceback (most recent call last): File "/bin/user_wsgi_wrapper.py", line 154, in __call__ app_iterator = self.app(environ, start_response) File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application raise e File "/bin/user_wsgi_wrapper.py", line 154, in __call__ app_iterator = self.app(environ, start_response) File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application raise e File "/bin/user_wsgi_wrapper.py", line 179, in <module> application = load_wsgi_application() File "/bin/user_wsgi_wrapper.py", line 175, in load_wsgi_application return __import__(os.environ['WSGI_MODULE'], globals(), locals(), ['application']).application File "/var/www/nidalmer_pythonanywhere_com_wsgi.py", line 21, in <module> application = StaticFilesHandler(get_wsgi_application()) File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application django.setup() File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/__init__.py", line 17, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 55, in __getattr__ self._setup(name) File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup self._wrapped = Settings(settings_module) File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 99, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named 'trailersapp.settings' Here is my wsgi.py file import os import sys path = '/home/nidalmer/trailersapp/trailers/settings.py' if path not in sys.path: sys.path.append(path) from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trailers.settings") application = get_wsgi_application() and my tree: trailersapp βββ db.sqlite3 βββ manage.py βββ movies β βββ __init__.py β βββ __pycache__ β βββ admin.py β βββ β¦ -
If Today is next Month
Condition: if today is next month. What is the best approach for creating this condition in Django/Python? What have I tried? timezone.now() + timezone.timedelta(days=1) I can get tomorrow's date and I can compare today's date with tomorrow's date to see if tomorrow is next month. This means, if tomorrow is next month, then I have to store that fact in a field. Is there a way in Django to check if today is the next month without creating an extra field? The purpose: User can input an amount that will be stored in the Transaction Model, if multiple transactions are made within a month, monthly_net_balance is increased by the amount. My Transaction model: class Transaction (models.Model): transaction_id = models.AutoField(primary_key=True) net_monthly_transaction = models.DecimalField(max_digits = 10, decimal_places = 2, default=0) amount = models.DecimalField(max_digits = 10, decimal_places = 2) time_stamp = models.DateTimeField(default=datetime.now, blank=True) loans = models.ForeignKey('Loan', related_name='transactions') -
Django migration duplicated index error on Postgres database
I'm getting the following error when I'm try to migrate an app on Postgres database. What's the best way to resolve this? django.db.utils.IntegrityError: could not create unique index "my_table_id_b6bbb9d727c50cb_uniq" DETAIL: Key (my_col1, my_col2)=(111, xxx) is duplicated. -
How to modify deprecated imports for a reusable app?
My project depends on an OSS reusable app, and that app includes a Django import which is deprecated in Django 1.10: from django.db.models.sql.aggregates import Aggregate is changing to: from django.db.models.aggregates import Aggregate We get a warning on Django 1.9, which will become an error on Django 1.10. This is blocking our upgrade, and I want to contribute a fix to the app so we can upgrade. One option would be to modify the requirements in setup.py so that Django 1.10 is required. But I'm sure my contribution would be rejected since it would break for everyone else. To maintain backwards compatibility, I can do the import as a try/except but that feels hacky. It seems like I need to do some Django version checking in the imports. Should I do a Django version check, which returns a string, convert that to a float, and do an if version > x? That feels hacky too. What's the best practice on this? Examples? -
How to sort after dehytrate creates all data in Tastypie
I want to BookResource to perform join (book table with author table) with dedydrate(...) function. Final result should be sorted by table Author. dehydrate(...) is called for each item in Book table. class Author(Model) author_name = models.CharField(max_length=64) class Book(Model) author = models.ForeignKey('Author') book_name = models.CharField(max_length=64) class BookResource(ModelResource): class Meta(object): # The point here is Book table can be sorted. But, final result # should be sorted by author_name queryset = Book.objects.all().order_by('book_name') resource_name = 'api_test' serializer = Serializer(formats=['xml', 'json']) allowed_methods = ('get') always_return_data = True def dehydrate(self, bundle): author_id = bundle.obj.author.id # author is foreign key of book author_obj = Author.objects.get(id=bundle.obj.author.id) # Construct queryset with author_name. Same as join 2 tables. # But, I want to sort by author. bundle.data['author_name'] = author_obj.author_name return bundle # This is called before dehydrate(...) is called. Not sure how to use it. def apply_sorting(self, obj_list, options=None): return obj_list Questions: 1) How to sort result by author if using above code? 2) Could not figure out how to do join. Can you provide alternative? Thank you. -
Can't get select box to display previous value, in ModelChoiceField
I have two views, one for creation and one for modifying an entry that has been created. I'm trying to populate the value from an instance that has been created in the model choice field, I've tried a couple different methods to use the value from the database to display in the template when trying to modify but it won't work. All my other fields, are populated already but the select box for model choice field won't display anything. All i need is for the last selected value to show up in the select box. my model # Injury Parameters -> SOI Level 2 class SourceOfInjuryLevel2(models.Model): creator = models.ForeignKey('auth.User') id = models.AutoField(primary_key=True) soi_l1 = models.CharField(max_length=80) soi_l2 = models.CharField(max_length=80) status = models.CharField(max_length=8) created_date = models.DateTimeField(default=timezone.now) modified_date = models.DateTimeField(blank=True, null=True) modified_by = models.CharField(max_length=60, blank=True, null=True) def create(self): self.save() def __str__(self): return '{}'.format(self.soi_l1) My form # Soure of Injury Level 2 class SourceOfInjuryLevel2Form(forms.ModelForm): options = (('Enabled', 'Enabled',), ('Disabled', 'Disabled')) soi_l1 = forms.ModelChoiceField( queryset=SourceOfInjuryLevel1.objects.filter(status='Enabled'), widget=forms.Select(attrs={'class': 'form-control'}), empty_label='' ) soi_l2 = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}) ) status = forms.CharField( widget=forms.Select( attrs={'class': 'form-control'}, choices=options ) ) class Meta: model = SourceOfInjuryLevel2 fields = ('soi_l1', 'soi_l2', 'status') my view # Modify Source of Injury Level 2 # ################################### β¦ -
Aggregate totals of a ViewSet results in Django Rest Framework
I have a ViewSet which outputs a set of results: { "count": 19355, "next": null, "previous": null, "results": [ { "duration": 5, ... }, { "duration": 5, ... }, ... ] } I would like to aggregate the totals of the duration of the results, right in that handy little top area next to "count". I know how to do this in a queryset, using annotate and sum, but I don't see a way to get it into the ViewSet output. Desired output for this data set would be: { "count": 19355, "total_duration": 10, "next": null, "previous": null, "results": [ { "duration": 5, ... }, { "duration": 5, ... }, ... ] } I appreciate the help! -
How to declare empty models in Django?
How do you declare empty models in Django? The following produce an error, class MyModel(ParentModel): -
Django python trying to use forms with token does not work for me
I'm learning django, in this moment I'm trying to implement web forms, actually some of them works fine with the data base model but I'm trying to make a new one without use the models. The problem is that django show me the token and not the value typed in the form. I hope you can help me, to understand more about it. URLS: url(r'^test', views.test), VIEWS: def test(request): if request.method == "POST": return HttpResponse(request.POST) return render(request, 'datos.html') DATOS HTML: <form action="/sumar-argumentos" method="post"> {% csrf_token %} <input type="text"> <input type="submit"> </form> When I run this django show me: csrfmiddlewaretoken Can any one help me please? -
Django, uwsgi static files not being served even after collectstatic
I'm having trouble with the deployment of a Django application on a Debian 8 VPS. Python version 2.7, Django 1.10.2. My problem is that it will not serve static files in production mode (DEBUG = False) even after having run 'collectstatic' and assigning a STATIC_ROOT directory. I've followed every instruction regarding this deployment (nginx, uwsgi, python) but still get 404's for all my static files. When collectstatic is run, it does put all the files into a /static/ directory at the top of the application. When I run uwsgi or the development server, the HTML and python functions fine, but all my static CSS,JS,IMG are not accessible. When I switch back to DEBUG=True and run the dev server, my static files are present again. Can someone have a look and see what I could be doing wrong? If you need any more context of files please let me know. My settings.py reads as follows: """ Django settings for mysite project. Generated by 'django-admin startproject' using Django 1.10.2. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR β¦