Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django - get related objects of related objects
I have the following three models: class Region(models.Model): code = models.IntegerField() class ReportRequest(models.Model): # a report can include many regions regions = models.ManyToManyField(Region) class Office(models.Model): # an office belongs to one region region = models.ForeignKey(Region) basically, many reports can have many regions, and one region can have many offices. How can I get all offices related to my report's regions in one query? I can do this in two queries: region_pks = reportrequest.regions.values_list('id', flat=True) offices = Office.objects.filter(region_id__in=region_pks) but I feel there must be a way to do this in just one query. I know how to do this if this was a chain of objects connected by ForeignKeys, but ManyToManyField confuses me a bit. -
How to connect mongolab to django?
I am creating a app in django and I want to fetch data from mongolab. But,I don't know how to connect mongolab to django. I had connect mongodb to django but now I want to connect with mongolab. How to do this? I have used this in my setting.py file, INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'djangotoolbox', 'app' ) And in DATABASE:, DATABASES = { 'default': { 'ENGINE': 'django_mongodb_engine', 'NAME': '*****', 'USER': '*****', 'PASSWORD': '******', 'HOST': 'ds129469.mongolab.com', 'PORT': '26469' } } And after running command, python manage.py runserver I get following error, life@life-All-Series:~/mongo/env1/project7/project$ python manage.py runrver /home/life/.local/lib/python2.7/site-packages/djangotoolbox/db/utils.py:1: RemovedInDjango19Warning: The django.db.backends.util module has been renamed. Use django.db.backends.utils instead. from django.db.backends.util import format_number /home/life/.local/lib/python2.7/site-packages/djangotoolbox/db/utils.py:1: RemovedInDjango19Warning: The django.db.backends.util module has been renamed. Use django.db.backends.utils instead. from django.db.backends.util import format_number Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread started by <function wrapper at 0x7fbad4b24c08> Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper fn(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 116, in inner_run self.check_migrations() File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 168, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/usr/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 19, in __init__ self.loader = MigrationLoader(self.connection) File "/usr/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__ self.build_graph() File "/usr/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 191, … -
Django: creating new instance causes primary key constraint violation
I have two models: > class HealthCenterServiceContractRel(BaseModel, ): > contract = models.ForeignKey(HealthCenterContract, on_delete=models.CASCADE, verbose_name=_('Contract')) > service = models.ForeignKey(HealthCenterService, on_delete=models.CASCADE, verbose_name=_('Service Name')) > price = models.BigIntegerField(null=True,blank=True, verbose_name=_('Price')) > price_dolati = models.BigIntegerField(null=True,blank=True, verbose_name=_('Price dolati')) > > rial_per_price_unit = models.BigIntegerField(null=True,blank=True, verbose_name=_('rial per price unit herfei')) > rial_per_price_unit_fani = models.BigIntegerField(null=True,blank=True, verbose_name=_('rial per > price unit for fani')) > rial_per_price_unit_dolati = models.BigIntegerField(null=True,blank=True, verbose_name=_('rial per > price unit for dolati')) > > #rial_per_price_unit_anses = models.BigIntegerField(null=True,blank=True, verbose_name=_('rial per > price unit fot bihushi')) > percentage = models.FloatField(null=True,blank=True, verbose_name=_('percentage')) > > #grade = models.IntegerField() > extra_text=models.TextField(null=True,blank=True,verbose_name=_("extra > text")) > confirm_extra_text = models.BooleanField(default=False,blank=True,verbose_name=_("confirm > extra text")) > print_in_pdf = models.BooleanField(default=False,blank=True,null=False,verbose_name=_("print > in pdf")) > #enable_two_k=models.BooleanField(null=False,blank=True,default=False,verbose_name=_("enable > two k")); > extra_heyatelmi_k=models.IntegerField(null=False,blank=True,default=0,verbose_name=_("extra_heyatelmi_k")) and > class HealthCenterContract(BaseModel, ): > source_contract = models.ForeignKey("HealthCenterContract",null=True,blank=True) > master_contract = models.ForeignKey("HealthCenterContract",null=True,blank=True,related_name="endorses") > health_center = models.ForeignKey(HealthCenter, on_delete=models.CASCADE, verbose_name=_('Health Center')) > contract_type = models.ForeignKey('HealthCenterContractType', on_delete=models.CASCADE, verbose_name=_('Contract Type')) > content = models.TextField(blank=True, null=True, verbose_name=_('Content')) > contract_number = models.CharField(max_length=400, blank=True, verbose_name=_('Contract Number')) > contract_title = models.CharField(max_length=400, blank=True, verbose_name=_('Contract title')) > regulation_date = models.DateField(verbose_name=_('Regulation Date')) > issu_date = models.DateField(verbose_name=_('issu Date'),null=True,blank=True) > start_date = models.DateField(verbose_name=_('Start Date')) > end_date = models.DateField(verbose_name=_('End Date')) > is_active = models.BooleanField(default=True, verbose_name=_('Activation Status')) > extra_text = models.TextField(null=True, verbose_name=_('extra text')) > morefi_active=models.BooleanField(default=True,blank=False,null=False,verbose_name=_("ghabelyat > ersal morefi name")) > > heyat_vaziran = … -
How to create a model and form for it for receiving multiple files?
I suppose this question was already not once asked. But I really don't understand how to make it. -
Does Django ORM support ternary associations (relatioship between three models)?
Does Django support using associations in which participates three models ? eg : User Project Group a User is a participant of a project using a role (group). How to handle such associations using Django ORM since it's never mentioned on the official documentation ? -
How to solve Django 'setup.py' not found in Linux Mint 18.1?
I'm trying to install Django to Linux Mint 18.1 with terminal. I am getting the same problem. My python version is 3.5.2 When i try to command $ -H pip install -e django/ I get this Directory 'django/' is not installable. File 'setup.py' not found. -
Django Admin form save same model twice
Im trying to add a new Object to a m2m field, im using django admin and it will open a form to add the new object model. The problem is, this is just a form and the model is not created yet so its impossible to get fields of this model ( I want the primary key but it doesnt have because the object is not added to the database yet). What i want to accomplish is to save the model as soon as the form initiates and still work on the same object and when the user clicks SAVE button it will update the object saved and not create a new one. class PrecoPorEpocaForm(forms.ModelForm): class Meta: model = Preco_por_epoca fields = ('epoca',) def __init__(self, *args, **kwargs): super(PrecoPorEpocaForm, self).__init__(*args, **kwargs) self.isntance.save() print self.instance.pk Calling self.instance.save() will add the object to the data base when the form is initialized but when adding the form it will create a new object because im not working on that instance anymore. I've tried to override with the save(commit=False) but it doesnt solve the problem because it doesnt add the object to the database thus im not able to get the primary key of the … -
Best way to make local server app using python
I want simple and easy integration of python and vba. People, reading this may kill me if they meet me in person after reading this but I am using django development server for this purpose. Is there any simple and better way. Just for example: I want to export comma separated string as excel file using python moduel openpyxl. This is django app url.py from django.conf.urls import url from . import views urlpatterns = [ url(r'identifier(.*)$', views.demo, name='index') ] This is django app views.py from django.http import HttpResponse from openpyxl import Workbook def demo(request, data): (identifier, numbers, filepath) = data.split(';;;') wb = Workbook() ws_sent = wb.active for number in numbers.split(','): ws_sent.append((number.strip(),)) wb.save(filepath + identifier + '.xlsx') return HttpResponse(identifier + " : Completed") vba: Sub demohttp() Set httpobject = CreateObject("MSXML2.XMLHTTP") url = "http://localhost:8000/appname/identifier;;;123456789;;;C:/ActiveDocument.Path" httpobject.Open "GET", url, False httpobject.send msgbox httpobject.responseText End Sub This is blazing fast compared to: calling python from vba shell functions This is amazingly simple compared to: automating excel from word vba. Excel is just an example. I have so many python scripts I wanted to convert to django apps. Questions 1) is there any downfall? I have checked it for my maximum number count up to 1200 … -
Is it possible to use the Django Sites Framework with multiple Sites on the same instance?
I have defined multiple sites as the documentation of the Site Framework suggested. I understand that if I would run mulitple instances of my application with each of them having a different settings file (different SITE_ID), Django would always know which Site to use. What I was trying to do is to run a single instance, where multiple sites are available, and the right Site should be chosen depending on the current url of the site. The Sites documentation states: The SITE_ID setting specifies the database ID of the Site object associated with that particular settings file. If the setting is omitted, the get_current_site() function will try to get the current site by comparing the domain with the host name from the request.get_host() method. So I tried to remove the SITE_ID from my settings.py and was hoping that Django would check the domain to find the current Site as stated above, howewer this fails with the following exception: You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting or pass a request to Site.objects.get_current() to fix this error. So it seems like although the documentation suggests otherwise, … -
Django Check if date time field contains a number
Lets say i have a number "5", How can i check if a date time field value contains that number? "25/10/15" should be true, while "20/10/12" should be false. -
Django Admin: create a custom button that updates (saves) an Object and does some extra action after that
I am working with an app that uses Django Admin for dealing with objects. So far, objects can be created and updated by using the default 'Save' buttons. I need a new button for updating an object and executing an action or command after that. This button will only be available for a certain type of users (which I am already able to do so). My problem is that I do not know how to perform the saving from a different button than the 'Save buttons. Is this possible? What would be the approach? -
Django REST Framework and HTML pages
I'm working on a project that uses Django on the server side and I have a REST(ish) API going. One thing I'm wondering about. Is it considered ok practice to deliver Django HTML templates via the API endpoints? For example, by going to www.rooturl.com, an API endpoint is called and the HTML delivered. Then, when user clicks on, say FAQ, a GET request is made to www.rooturl.com/faq and an HTML template delivered again? Or should the FAQ items be delivered as JSON? Or maybe give both alternatives through content negotiation? At which point is all the HTML content usually delivered? I couldn't find a satisfying answer with my google-fu. -
Celery & Django - Periodic Tasks not running
I have inherited a project which has some celery periodic tasks that are no longer running as scheduled. Looking at the djcelery_periodictask table in last_run_at, I can see that all tasks stopped running on the same date a couple of months ago. The project is using celery 3.1.24 with Django version 1.10.2. Django was updated from 1.8, which I thought may have caused the issue, however apparently this upgrade was done after the periodic tasks stopped running. If I try running python manage.py celery beat or python manage.py celery worker I get the same traceback: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/rh/workspace/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/Users/rh/workspace/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/rh/workspace/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 208, in fetch_command klass = load_command_class(app_name, subcommand) File "/Users/rh/workspace/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 40, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/Users/rh/workspace/project/lib/python3.4/importlib/__init__.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked File "<frozen importlib._bootstrap>", line 1129, in _exec File "<frozen importlib._bootstrap>", line 1471, in exec_module File "<frozen importlib._bootstrap>", line 321, … -
uwsgi error bind(): Permission denied [core/socket.c line 769]
Setting up django to use uwsgi I can run it using the command uwsgi --ini kb_uwsgi.ini --http :8000 outside the virtualenv however trying to run the emperor command sudo uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data brings an error: ubuntu@ip-172-31-16-133:/etc/uwsgi/vassals$ ls kb_uwsgi.ini ubuntu@ip-172-31-16-133:/etc/uwsgi/vassals$ sudo uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data *** Starting uWSGI 2.0.14 (64bit) on [Mon Jan 30 10:28:11 2017] *** compiled with version: 5.4.0 20160609 on 06 January 2017 11:55:37 os: Linux-4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 nodename: ip-172-31-16-133 machine: x86_64 clock source: unix detected number of CPU cores: 4 current working directory: /etc/uwsgi/vassals detected binary path: /usr/local/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! setgid() to 33 setuid() to 33 *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 64137 your memory page size is 4096 bytes detected max file descriptor number: 1024 *** starting uWSGI Emperor *** *** has_emperor mode detected (fd: 6) *** [uWSGI] getting INI configuration from kb_uwsgi.ini *** Starting uWSGI 2.0.14 (64bit) on [Mon Jan 30 10:28:11 2017] *** compiled with version: 5.4.0 20160609 on 06 January 2017 11:55:37 os: Linux-4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC … -
django-Cannot assign "u'Joan Manel'": "despesa.nomTreballador" must be a "treballador" instance
I have been working on a project in which I have to point out the expenses that the workers of a company have. For this I have created two models, workers and expenses, in which expenses has a foreign key to workers, in the field: "nomTreballador". When I try to save it in the db I get the error: "Cannot assign "u'Joan Manel'": "despesa.nomTreballador" must be a "treballador" instance." My models.py: from __future__ import unicode_literals from django.db import models from django.core.validators import RegexValidator KILOMETRATGE = 'KM' DINAR = 'DIN' AUTOPISTA = 'AP' MANTENIMENTPC = 'PC' GASTOS = ( (KILOMETRATGE, 'Kilometres'), (DINAR, 'Dinar'), (AUTOPISTA, 'Autopista peatge'), (MANTENIMENTPC, 'Manteniment de pc') ) NIF = 'NIF' NIE = 'NIE' DNI = 'DNI' TIPUSDOC = ( (DNI, 'DNI'), (NIF, 'NIF'), (NIE, 'NIE') ) class treballador(models.Model): nom = models.CharField(max_length=150, null=False, unique=True) cognom = models.CharField(max_length=150, null=False) tipusDocID = models.CharField(max_length=3, choices=TIPUSDOC, null=False) docId = models.CharField(max_length=9, null=False) tlf_regex = RegexValidator(regex=r'^\d{9,9}$',message="Phone number must be entered in the format: '+999999999'. Up to 9 digits allowed.") tlf = models.CharField(validators=[tlf_regex], blank=True, max_length=9) # validators should be a list correu = models.EmailField(max_length=254) ciutat = models.CharField(max_length=150) dataDAlta = models.DateTimeField(auto_now_add=True) def __unicode__(self): return unicode(self.nom) or 'u' class despesa(models.Model): nomTreballador = models.ForeignKey(treballador, to_field='nom') tipusDeGast = models.CharField(max_length=3, … -
How to pass a class based task into CELERY_BEAT_SCHEDULE
As seen in the docs class based tasks are a fair way to express complex logic. However, the docs do not specify how to add your shiny newly created class based task into you CELERY_BEAT_SCEHDULE (using django) Thing I tried: celery.py app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, 'task_summary') @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): from payments.tasks.generic.payeer import PayeerPaymentChecker from payments.tasks.generic.ok_pay import OkPayPaymentChecker okpay_import = OkPayPaymentChecker() payeer_imprt = PayeerPaymentChecker() sender.add_periodic_task(60.0, okpay_import.s(), name='OkPay import', expires=30) sender.add_periodic_task(60.0, payeer_imprt.s(), name='Payeer import', expires=30) -- OR -- payments/task_summary.py from tasks.generic.import import OkPayPaymentChecker, PayeerPaymentChecker run_okpay = OkPayPaymentChecker() run_payeer = PayeerPaymentChecker() CELERY_BEAT_SCHEDULE = { # yes, i did try referring to the class here 'check_okpay_payments': { 'task': 'payments.tasks.task_summary.run_okpay', 'schedule': timedelta(seconds=60), }, 'check_payeer_payments': { 'task': 'payments.task_summary.run_payeer', 'schedule': timedelta(seconds=60), }, } Really don't know what to do, restoring to something like: payments/task_summary.py/ from payments.tasks.generic.ok_pay import OkPayPaymentChecker from payments.tasks.generic.payeer import PayeerPaymentChecker from celery import shared_task @shared_task def run_payer(): instance = PayeerPaymentChecker() return instance.run() @shared_task def run_okpay(): instance = OkPayPaymentChecker() return instance.run() Online Resources which I've checked and do not help me / solve the problem: https://denibertovic.com/posts/celery-best-practices/ https://blog.balthazar-rouberol.com/celery-best-practices http://shulhi.com/class-based-celery-task/ http://jsatt.com/blog/class-based-celery-tasks/ -
django-import-export: create a new object on importing
I'm using django-import-export in my admin panel. i have a unique field in model called code. so in Resource class i have set import_id_fields = ['code']. now when I try to upload a csv file which doesn't have code column(or empty column) then it supposed to create a new object and in my model i have override the save method which auto generate the unique code. I tried to do this by overriding init_instance(self, row) method but it doesn't save manytomany relations. also it creates two objects with same data (ofcourse code is different) below is the sample code. def init_instance(self, row): # extract fields # mm = MyModel(**fields_dict) # mm.save() # return mm -
Proper way to register apps in Django
I noticed different ways to register apps in django project. For example, if I have an app called Catalog, in settings.py I can use either just the name of the app 'catalog' or the longer name 'catalog.apps.CatalogConfig'. What is the difference and which one is more accurate way to register an app? -
extract thumbnail from video in django
I am trying to extract frame from an uploaded video and save it as an image file. While it works perfect with command line, it just does not work with django. I'm using ffvideo the code for command line is: from ffvideo import VideoStream import random import uuid video = VideoStream("abc.mp4") pil_image = VideoStream('abc.mp4').get_frame_at_sec(3).image() pil_image.save('image.jpg') my django model is: class Video(models.Model): title = models.CharField(max_length=100, null=False, blank=False) file = models.FileField(upload_to="videos/%Y/%m/%d", blank=False, null=False) uploader = models.ForeignKey(User, related_name="uploads") thumbnail = models.ImageField(upload_to='images/%Y/%m/%d') timestamps = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.title and my django view is: def upload_next(request): id = request.GET.get('id','') video = Video.objects.get(id=id) stream = VideoStream(os.path.join(BASE_DIR,"media")+str(video.file)) pil_image = stream.get_frame_at_sec(3).image() video.thumbnail = pil_image.save('image.jpg') video.save() return HttpResponseRedirect('/') Where am I going wrong? Any other solution will be appreciated. -
Run OPKG from OpenWRT in Django
I built C program in OpenWRT ( to OPKG). How i can run it from Django Web? I want only to run this program from Web button( without any other interact - input or output text). Program can turn on and turn off led from router. I am a beginner. Thank you very much. -
How do I can update a field with queryset in django?
I'm trying to update the field 'estado' through a queryset but The record is deleted automatically and I do not know correct it I only want to Update it. I hope you can help me Views.py #Views.py from django.contrib import messages from django.core.urlresolvers import reverse from django.shortcuts import render from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse_lazy from apps.almacen.articulo.models import Articulo from django.views.generic import ListView,DeleteView # Create your views here. class ArticuloList(ListView): queryset = Articulo.objects.all().order_by('idarticulo') template_name = "almacen/articulo/index.html" paginate_by = 5 success_url= reverse_lazy('almacen_art:articulo_listar') class ArticuloDelete(DeleteView): success_url = reverse_lazy('almacen_art:articulo_listar') def get_queryset(self): pk = self.kwargs['pk'] Articulo.objects.filter(idarticulo=pk).update(estado='0') return Articulo.objects.all() Urls.py from django.contrib import admin from django.conf.urls import url from apps.almacen.articulo.views import ArticuloList,ArticuloDelete urlpatterns = [ url(r'^/$',ArticuloList.as_view(),name='articulo_listar'), url(r'^/delete/(?P<pk>\d+)$',ArticuloDelete.as_view(),name='articulo_delete'), ] Models.py from django.db import models from apps.almacen.categoria.models import Categoria # Create your models here. class Articulo(models.Model): idarticulo = models.AutoField(primary_key=True) codigo= models.CharField(max_length=50) nombre= models.CharField(max_length=100) stock= models.IntegerField() descripcion=models.CharField(max_length=512) imagen=models.CharField(max_length=50) estado=models.CharField(max_length=20) idcategoria= models.ForeignKey(Categoria,db_column='idcategoria',null=True,blank=True,on_delete=models.CASCADE) -
Django- Suspicious File Operation when opening an uploaded PDF file
I have been working on adding the functionality to upload PDFs & other image files to a form on a Django webpage. I currently have two buttons on a form on the page- one is to allow users to upload a 'Budget' file, and the other to allow them to upload a 'Drawing' file. I am currently testing these buttons by trying to upload a single PDF file for each of the Budget & the Drawing. When I click either button, an 'Open File' Dialog is displayed, and I can select the file, click 'OK', and the uploaded file is then shown on the form in the location where the 'upload' file button previously was. Currently, if I click on the PDF file uploaded via the 'Upload Drawing' button, a new tab is opened in the browser, and a preview of the PDF is displayed there. However, if I click on the PDF file uploaded via the 'Upload Budget' button, the new tab that's opened in the browser displays a "Suspicious File Operation" message... The HTML that's displaying the 'Upload File' buttons is: <tr> {% if not forloop.last %} <td colspan="3" class="center"> {% if presentation_form.instance.pdf_package_dep %} <a class="button file-download pdf" … -
how can i get only username display in web if i am having two data columns username and email using django
def search(request): if 'q' in request.GET and request.GET['q']: q = request.GET['q'] try: username = Userdata.objects.filter(user__icontains=q) return render(request, 'userdata/search_results.html', {'query': q}) except: return HttpResponse('Please submit a search term.') -
Running django with uwsgi & nginx error: connect() to unix:/tmp/kb.sock failed
Setting up a django site, I can run it outside the virtualenv with uwsgi --ini kb_uwsgi.ini --http :8000 but when I try to set it up live with nginx brings an error in the logs: 2017/01/30 08:00:26 [crit] 24629#24629: *1 connect() to unix:/tmp/kb.sock failed (2: No such file or directory) while connecting to upstream, client: 197.232.12.165, server: kenyabuzz.nation.news, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/tmp/kb.sock:", host: "kenyabuzz.nation.news" Here's the nginx file # kb.conf # the upstream component nginx needs to connect to upstream django { server unix:/tmp/kb.sock; # for a file socket #server 0.0.0.0:8000; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 0.0.0.0:80; # the domain name it will serve for server_name kenyabuzz.nation.news; # substitute your machine's IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { alias /home/ubuntu/webapps/kenyabuzz/kb/media; # your Django project's media files - amend as required } location /static { alias /home/ubuntu/webapps/kenyabuzz/kb/static; # your Django project's static files - amend as required } location /favicon.ico { alias /home/ubuntu/webapps/kenyabuzz/kb/static/kb/favicon.ico; # favicon } # Finally, send all non-media … -
upgrading django did not upgrade admin files
I upgraded Django from v.1.8 to 1.10 but the djang.contrib.admin static files are not upgraded and the 127.0.0.1:8000/admin does not work properly now. (It still uses the UI from 1.8 version). note: I am using django on my Windows pc and not on server (static files are stored in sitepackages/django/contrib/admin/ directory). So I guess that the collectstatic is useless in this case! How can this problem be resolved? Thanks in advance