Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Migrations don't create new tables
I have models.py in a Django app that has a few models that I have the corresponding tables for in MySQL, and others that I do not. How do I get Django to create the tables for the models that don't have them? I tried makemigrations and migrate, but they were not delivered. But then again django.db.utils.ProgrammingError: (1146, "Table 'test_vcc.polls_choice' doesn't exist") What am I doing wrong? I am using Django 1.11.7, Python 3.6.3 on MySQL 5.7 -
Django message catalog app
I am looking for an app or a functionality in Django that has messages by number. Eg. Msg 10 - Wrong Password Msg 23 - Congratulations Usage on a view {'returnMsg': messageapp.getCatalog(10)} This kind of stuff... and also supporting translation so the message can have one text per language. I have looked all over Django website and on google, but found nothing like this. If that doesn't exists, than I will go ahead and create some app that does that, but I would rather use something that is there. -
Querying in solr using Django Haystack but not models
I am trying to create a search engine on a cloud machine. I have used solr to index. And I am using Django and haystack for front end and querying. I have done the following till now: 1. Collected data from internet in a Json file 2. Indexed that Json File on Solr-7.1.0 3. Installed Django and Haystack. Edited settings.py. Made connection to solr. The next step is to create a single webpage for searching. Following is what I got from the "Django by example" book for querying: def post_search(request): form = SearchForm() if 'query' in request.GET: form = SearchForm(request.GET) if form.is_valid(): cd = form.cleaned_data results = SearchQuerySet().models(Post).filter(content=cd['query']).load_all() # count total results total_results = results.count() return render(request,'blog/post/search.html',{'form': form,'cd': cd,'results': results,'total_results': total_results}) The problem is: I don't have any databases (and therefore no models) in my application. Indexing was done directly on solr by giving it a json file. But the following line of code requires a model for querying on the indexed code. SearchQuerySet().models(Post).filter(content=cd['query']).load_all() Is there a way to search the index in solr when there are no models? -
How to make every field able to process a request with several options in Django REST?
Suppose I own a store, and there is a database table with information about everything I sell; it basically records what I sold and to whom I sold it. I use Django REST to interface with said database, and I can access the table data via /rest/purchases. I would like to filter those purchases by client, but I'd also like to be able to pass in an array of clients' IDs and get all the purchases they made. Here's the catch: I'm well aware that this can be easily achieved, either by creating a custom filter class inside the viewset class for this specific endpoint or by overriding the get_queryset method. The thing is that I want this functionality to be available for ALL fields in ALL my viewsets, and if I create another project later, I'd also want this functionality in all its viewsets and fields. So, changing the get_queryset method or adding custom filter_classes is not a viable option, because it takes up too much time. Bottom line: is there a way to create this custom filter and inject it in all field of my project? Studying the DRF, I got to where the filters for each field … -
How to save data in a DB field that is not listed as part of a DJango CreateView
I have the following CreateView where I am trying to Mstrstorehead-contactemail with the email address of the person who has logged in. The problem is that contactemail is not listed as one of the fields to be displayed on the CreateView form (which is MstrstoreheadCreate) How can I get this field assigned? views.py class MstrstoreheadCreate(CreateView): model = Mstrstorehead fields = ['companyname', 'taxeinno', 'companyname', 'abanumber', 'businesstypeid', 'ourmission', 'contactsalutationid', 'contactfirstname', 'contactlastname', 'contactofficephoneno', 'contactcellphoneno' ] template_name_suffix = '_mstr_create_form' def form_valid(self, form): mhead = form.save(commit=False) mhead.contactemail = self.request.user.email << contactemail is part of the model but NOT part of the fields used in CreateView return super(MstrstoreheadCreate, self).form_valid(form) TIA -
CSS font only works in some Django templates extended from same base
I'm in the middle of creating a fairly complex site using Django, and I've noticed a weird problem. All of my templates extend the same base template (base.html). That base template looks (something) like this: {% load staticfiles %} <html> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="{% static 'css/fonts.css' %}"> <link rel="stylesheet" href="{% static 'css/webStyleSheet.css' %}"> {% block head %} {% endblock %} </head> <body> <div class="wrapper"> {% block header %} <div class="header"> <h1><a href="/">Title</a></h1> <ul class="nav-bar"> <!-- nav bar content here etc etc--> </div> {% endblock %} </div> </body> </html> <!-- js relevant to the nav bar etc etc --> {% block script %} {% endblock %} My fonts.css file declares my font-faces, for example: /* latin */ @font-face { font-family: 'Overpass Mono'; font-style: normal; font-weight: 400; src: local('Overpass Mono Regular'), local('OverpassMono-Regular'), url('../fonts/OverpassMono-Regular.woff') format('woff'), url('../fonts/OverpassMono-Regular.ttf') format('truetype'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; } And in my webStyleSheet.css I implement those fonts like so: :root { --font-secondary: 'Overpass Mono', monospace; } /*the class I use for the nav-bar elements*/ .menu-button { font-family: var(--font-secondary); } As I said, I extend this base in all of my templates. The problem arises in that on some of … -
Best tool for implementing soap web service via django
forgive me if this question is naive. i'm new on django and i want to serve a soap web service. what is the best way for that? every answer or link would be appreciated. -
Cannot render chartit-django chart example
Im trying to build a dashboard in django framework using chartit. But the documentation seems to be for advanced people. Im a beginner trying to learn, so sorry. Im having a problem that i can render the chart in my dashboard. What i really dont understand in the docu was this, <!-- code to include the highcharts and jQuery libraries goes here --> <!-- load_charts filter takes a comma-separated list of id's where --> <!-- the charts need to be rendered to --> {% load chartit %} {{ weatherchart|load_charts:"container" }} i really dont understand those comments. What to put. Where to put it. Im rendering the chart to an extended html so i really dont know where to put it. Sorry im just a beginner im still learning. This is my base html {% load staticfiles %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Dashboard - Dark Admin</title> <link rel="stylesheet" type="text/css" href="{% static 'bootstrap/css/bootstrap.min.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'font-awesome/css/font-awesome.min.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'css/local.css' %}" /> <script type="text/javascript" src="{% static 'js/jquery-1.10.2.min.js' %}"></script> {% load chartit %} <script type="text/javascript" src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script> <!-- you need to include the shieldui css … -
Django form ImageField
I'm trying to establish CreateView for the model which holds ImageField. I can successfully upload and display images from django admin page. But, when I upload images from my own form, django doesn't upload images to "upload_to" folder. I'm writing my codes below: models.py from django.db import models class Album(models.Model): title = models.CharField(max_length=127) artist = models.CharField(max_length=63) release_date = models.DateField() logo = models.ImageField(blank=True, upload_to='album_logos', default='album_logos/no-image.jpg') def __str__(self): return self.title forms.py from django import forms from .models import Album class AlbumCreateForm(forms.ModelForm): class Meta: model = Album fields = [ 'title', 'artist', 'release_date', 'logo' ] views.py class AlbumCreateView(CreateView): form_class = AlbumCreateForm template_name = 'music/album_create.html' success_url = '/albums/' album_create.html {% extends 'base.html' %} {% block content %} <form method="post">{% csrf_token %} {{ form.as_p }} <button type="submit">Create</button> </form> {% endblock %} When I try to create album using "album_create.html" and upload image with django's default form, logo image isn't uploaded to "album_logos" folder and takes default value. Where am I doing wrong? -
Django: deleting a one-to-one related field in post_delete causes recursion
I have a model, say Model1 that has a OneToOne related field Model2. There is a post_delete signal connected method of Model1 that calls instance.model2.delete(), and very infrequently, this causes a recursive call back to the Model1.post_delete(). I've followed the stack trace, here is the recursion on Django 1.8 (most recent last): File "myapp/models.py", line 645, in post_delete instance.model2.delete() File "django/db/models/base.py", line 896, in delete collector.delete() File "django/db/models/deletion.py", line 314, in delete sender=model, instance=obj, using=self.using File "django/dispatch/dispatcher.py", line 189, in send response = receiver(signal=self, sender=sender, **named) File "myapp/models.py", line 645, in post_delete instance.model2.delete() File "django/db/models/base.py", line 896, in delete collector.delete() File "django/db/models/deletion.py", line 314, in delete sender=model, instance=obj, using=self.using File "django/dispatch/dispatcher.py", line 189, in send response = receiver(signal=self, sender=sender, **named) After following it many times in debug, and testing extensively with automation, I have come to the conclusion that the problem is that File "django/dispatch/dispatcher.py", line 189, in send response = receiver(signal=self, sender=sender, **named) is erroneously being called from File "django/db/models/deletion.py", line 314, in delete sender=model, instance=obj, using=self.using somehow. What could possibly be going on? -
error in template rendering django and bootstrap
I am using a bootstrap index file in the header.html in a django project. Can anyone point out a fix or the easiest method to link the bootstrap file to the static folder. In what places does it need to be done, and how? Also, for use of bootstrap, could I just use the index file rather than header? I can see the error (below) but do not know the syntax to fix it. The route i've tried is using Jinja logic and it is on that line that the first error arises. (line 14) Current error: Error during template rendering In template C:\Users\User\Desktop\pythonsite\mysite\aboutme\templates\aboutme\header.html, error at line 14 Invalid block tag on line 14: 'static'. Did you forget to register or load this tag? 4 <head> 5 6 <meta charset="utf-8"> 7 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 8 <meta name="description" content=""> 9 <meta name="author" content=""> 10 11 <title>Freelancer - Start Bootstrap Theme</title> 12 13 <!-- Bootstrap core CSS --> 14 <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> 15 16 <!-- Custom fonts for this template --> 17 <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> 18 <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css"> 19 <link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css"> 20 21 <!-- Plugin CSS --> 22 <link href="{% static 'vendor/magnific-popup/magnific-popup.css' … -
Django Admin Site-Wide CSS and JS
I'm wondering if there is an efficient way to add custom css and js to Django Admin in order to include in all pages through whole admin site. For example adding some options to settings.py or some useful packages which compatible with Grappelli Admin. I'm using Django 1.11 with Grappelli Admin 2.10.1 Thanks for the help. -
fix invalid geometries in django (without database)
I have polygon that I'm getting from external source. The polygon is not valid. In [36]: p Out[36]: <Polygon object at 0x7fec6bea6ac0> In [37]: p.valid [12/Dec/2017 19:13:19] WARNING [django.contrib.gis:85] GEOS_NOTICE: Hole lies outside shell at or near point 260561.40600000042 776052 I know that I can fix the polygon in the DB using the MakeValid() django function. Is there a way to fix the polygon before it is inserted to the DB, just using geos API? Thanks. -
Django show unique together fields in one model in another model's template
A Django newbie here. I have searched but couldn't find an answer to my question (or I didn't know the right keywords to look up) I have a model with a unique together columns in addition to a PK- class RegEntry(models.Model): id = models.AutoField(primary_key=True) product = models.ForeignKey('data.Product', on_delete=models.PROTECT) account_id = models.CharField(max_length=64) nominee_name = models.CharField(max_length=128) nominee_id = models.CharField(max_length=128) nominee_account_id = models.CharField(max_length=64, null=True) address = models.CharField(max_length=255, null=True objects = RegisterQuerySet.as_manager() class Meta: unique_together = (('date', 'product', 'nominee_id'),) index_together = ( ('nominee_id', 'date'), ('product', 'date'), ) ordering = ['date', 'product', 'nominee_id'] I have another model that is based on the previous model and has it's own PK - class Attribute(models.Model): id = models.AutoField(primary_key=True) date = models.DateField(db_index=True) product = models.ForeignKey('data.Product', on_delete=models.PROTECT) nominee_id = models.CharField(max_length=255) beneficiary_name = models.CharField(max_length=128) class Meta: unique_together = (('date', 'product', 'nominee_id', 'beneficiary_name'),) index_together = ( ('date', 'product', 'nominee_id'), ('is_processed',) ) ordering = ['date', 'product', 'nominee_id', 'beneficiary_name'] I need to display the manualatrribution model using ModelForm and associated template, but also need to display the product name and nominee name. I got to the part where I could render Model Form but couldn't figure out the linking part. Will be very grateful for any advice from the experts here. -
django collectstatic with template processor
Is it possible to use templates for static files? I would like django could process the static files with template processor before copying them in the static folder when manage collectstatic is issued. Of course the context would not contain request information but it could be useful to use such information as: urls from url names to be used in javascript code settings to be used to customize css or static html pages What is the simpler way to accomplish this? -
PostgreSQL with Django: transaction is aborted error
I have PostgreSQL and Django 1.8. When I try to create an MyModel object via Django ORM, I get InternalError current transaction is aborted, commands ignored until end of transaction block. My code look like: MyModel.objects.get_or_create(client=client, defaults={ 'email': client.user.email, 'name': client.name, 'phone_number': '77644017513' }) But when I modify MyModel via psql (I tried to delete a record) everything is just fine. When I try to create object from another model (not MyModel) everything is fine too. What is wrong with MyModel? -
POST request not behaving as intended
I've been trying to get my button to send a POST request to the submitted URL, which does a write back to the database. The application looks like the POST request gets sent, but after hitting the button my URL never changes and the print at the submitted URL appears to be an empty set. This is my jquery/ajax call for the button: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <button class="btn btn-primary my_select" type="submit">Request Access</button> <script> $(document).ready(function () { $('form').on('submit', function (e) { e.preventDefault(); var phi = $('#phi').val(); var accesslevelid = $('#accesslevelid').val(); $.ajax({ url: "{% url 'submitted' %}", headers: { 'X-CSRFToken': '{{ csrf_token }}' }, data: { phi: phi, accesslevelid: accesslevelid, }, type: 'POST', success: function (result) { // do something with result }, }); }); }); </script> I'm expecting my POST of the Application List, PHI flag, and Access Level gets sent as a POST to my submitted URL. My view for submitted is the following: def submitted(request): owner = User.objects.get (formattedusername=request.user.formattedusername) checkedlist = request.POST.getlist('report_id') coid = User.objects.filter(coid = request.user.coid).filter(formattedusername=request.user.formattedusername) facilitycfo = QvDatareducecfo.objects.filter(dr_code__exact = coid, active = 1, cfo_type = 1).values_list('cfo_ntname', flat = True) divisioncfo = QvDatareducecfo.objects.filter(dr_code__exact = coid, active = 1, cfo_type = 2).values_list('cfo_ntname', flat = True) print (checkedlist) selectedaccesslevel = request.POST.get('accesslevelid') … -
Add object to to manytomany relationship
i'm trying to add ticker values to a currency object using a custom command, but i can't seem to be able to add the ticker to the CurrencyTickerSerializer? i get following error TypeError: 'QuerySet' object does not support item assignment. I run this command in a specific interval that is suppose to add the ticker into the specific currency, but i guess i need to add something in order to being able to add the ticker into TickerSerializer? Command class Command(BaseCommand): def handle(self, *args, **options): comparison='DKK' url = 'URL' page = requests.get(url) data = page.json() response_data = {} for ticker in data: currency = Currency.objects.filter(symbol=ticker['symbol'], is_active=True) if currency.exists(): currency['tickers'] = ticker serializer = CurrencyTickerSerializer(data=currency) if serializer.is_valid(): serializer.save() serializers class TickerSerializer(serializers.HyperlinkedModelSerializer): currency = serializers.PrimaryKeyRelatedField(many=False, queryset=Currency.objects.all()) class Meta: model = Ticker fields = ('currency', 'rank', 'price_dkk', 'market_cap_dkk', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d',) class CurrencyTickerSerializer(serializers.HyperlinkedModelSerializer): tickers = TickerSerializer(many=True) class Meta: model = Currency fields = ('id', 'name','symbol', 'tickers', ) Models class Ticker(models.Model): rank = models.IntegerField() price_dkk = models.DecimalField(max_digits=20, decimal_places=6) market_cap_dkk = models.BigIntegerField() percent_change_1h = models.DecimalField(max_digits=4, decimal_places=2) percent_change_24h = models.DecimalField(max_digits=4, decimal_places=2) percent_change_7d = models.DecimalField(max_digits=4, decimal_places=2) created_at = models.DateTimeField(auto_now_add=True) class Meta: verbose_name_plural = _('Ticker') def __str__(self): return self.id class Currency(models.Model): symbol = models.CharField(max_length=4, default='BTC', unique=True) name = … -
Can we serve angular 4 in django server?
I'm trying to integrate Django and Angular 4 in the same app . Like in angularjs we could include cdn and serve. How to do in angular v4? -
Django not finding custom user model in settings when migrating
I've created a custom User model in models.py: class User(AbstractUser): pass Then, I've set AUTH_USER_MODEL to that model, in settings.py: AUTH_USER_MODEL = 'workoutcal.User' workoutcal is included in INSTALLED_APPS: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'workoutcal', 'rest_framework', 'rest_framework_mongoengine', ] And I've included this in admin.py: admin.site.register(User, UserAdmin) Then, I've ran makemigrations and migrate, and on the latter, I get this long error traceback: (workout) sahands-mbp:workout sahandzarrinkoub$ python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, workoutcal Running migrations: Applying admin.0001_initial...Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle fake_initial=fake_initial, File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/db/migrations/migration.py", line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 97, in database_forwards schema_editor.create_model(model) File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 254, in create_model definition, extra_params = self.column_sql(model, field) File … -
adding multiple markers on GoogleMaps
I am trying to retrieve the lat long values from my db and visualise them on googlemap. I'm not sure how do I access those fields using for loop models.py import json from django.db import models from django.utils.translation import ugettext_lazy as _ class LocateGoose(models.Model): class Meta: app_label = 'My Goose' verbose_name = _('Where is the Goose?') external_id = models.IntegerField(unique=True) latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True) longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True) name = models.TextField(max_length=250, null=True, blank=True) address = models.TextField(max_length=25, null=True, blank=True) views.py from edrive.mygoose.models import LocateGoose from django.shortcuts import render def testgmap(request): data = LocateGoose.objects.all() template = 'hereismygoose.html' return render(request, template, {"data": data}) hereismygoose.html function initMap() { var myLatLng = {lat: 52.0116, lng: 4.3571}; var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, center: myLatLng }); var marker = new google.maps.Marker({ position: myLatLng, map: map, title: 'stringLocate me!' }); map.setOptions({ minZoom: 4, maxZoom: 10 }); } -
How to enable DRF throttling after too many 403 responses?
I have an API endpoint that has a permission class which may throw 403 in some cases. I wonder how to enable throttling after some number of 403 responses to this endpoint? Suppose a user made 10 unsuccessful requests and I want to rate limit the endpoint for him. I see that DRF comes with throttling module that enables to filter requests before making them, but I am not sure how to do what I am willing to do. -
Update already existing data in database
I am trying to use the "update ()" to update existing data in the data base of the "ModelC". Models: from django.db import models class ModelA(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) def __str__(self): return '%s' %(self.id) class ModelB(models.Model): observation = models.CharField(max_length=30) status = models.BooleanField() relation = OneToOneField(ModelA) def __str__(self): return '%s' %(self.relation) class ModelC(models.Model): relationA = models.ForeignKey('ModelA', null=True, blank=True) date_relationA = models.CharField(max_length=10, null=True, blank=True) user_relationA = models.CharField(max_length=15, null=True, blank=True) relationB = models.ForeignKey('ModelB', null=True, blank=True) date_relationB = models.CharField(max_length=10, null=True, blank=True) user_relationB = models.CharField(max_length=15, null=True, blank=True) def __str__(self): return str(self.id) Views of the ModelA: def RegModelA(request): form = "" user = None if request.method == "POST": form = ModelAForm(request.POST) if form.is_valid(): save = form.save() date = time.strftime("%d - %m - %Y") user = request.user.username create = ModelC.objects.create(relationA=save, date_relationA=date, user_relationA=user, relationB=None, date_relationB=None, user_relationB=None) return redirect('/') else: form = ModelAForm return render(request, "ModelA.html", {"form":form}) **Result when registering ModelA:** In ModelA: Image of the result In ModelC: Image of the result Views of the ModelB: def RegModelB(request): form = "" user = None if request.method == "POST": form = ModelBForm(request.POST) if form.is_valid(): save = form.save() date = time.strftime("%d - %m - %Y") user = request.user.username update = ModelC.objects.filter().update(relationB=save, date_relationB=date, user_relationB=user) return redirect('/') else: form … -
Django URLs file error
I have the following urls.py file in a Django project, and I am getting an error which I assume is relating to the latest syntax relating to urls and paths. The code I have in the urls file which is url.py in the mysite (outermost directory) is: from django.urls import path from django.conf.urls import url, include urlpatterns = [ path(r'^$', include('aboutme.urls')), ] The error message is: Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^$ The empty path didn't match any of these. In the actual app (website folder) which is called 'aboutme', the urls.py file looks like this: from django.urls import path from django.conf.urls import url, include from .import views #this is the main thing we are going to be doing ....returning views! urlpatterns = [ path(r'^$', views.index,name='index'), ] Can anyone shed any light on the correct syntax or what I am doing wrong? -
Celery tasks are not always getting executed in the right order
I have several periodic tasks that run every few minutes/hours along with many more event-driven tasks. Sometimes an event-driven task will be received by a worker that is already busy executing one of the longer periodic tasks, and then the event-driven task will not run until the longer periodic task is completed. I checked using celery flower, and there ARE available workers, so I don't understand why the busy worker claimed the task. I would like the event-driven task to go to an available worker. I have a machine with 16 workers and celery beat running. I am running Celery 4.1.0 with Django 1.8.16. I am also using Redis as my broker. Here are the commands used to start all the celery workers: celery beat -A proj & celery multi start 16 -A proj -l info -c1 -Ofair