Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Where is the Postgres username/password being created in this Dockerfile?
So I was following this tutorial: https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/ I have everything up and running, however theres a few things going on that I'm not able to follow or understand. In the main Docker-Compose we have: web: restart: always build: ./web expose: - "8000" links: - postgres:postgres - redis:redis volumes: - /usr/src/app - /usr/src/app/static env_file: .env command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000 postgres: restart: always image: postgres:latest ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data/ You will notice there is a .env with environment variables which include postgres user and pass. My question is when is the postgres user and password being created? If I run this docker-compose everything works, meaning the web app can pass credentials to the postgress database and establish a connection. I'm not able to follow however, where those credentials are being set in the first place. I was assuming this part (the setup and configuration) of postgres would be contained within the base postgres Dockerfile, and maybe it is but I just don't see where it's setting up a postgres user and password. # vim:set ft=dockerfile: FROM debian:jessie # explicitly set user/group IDs RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres # grab gosu … -
Preventing the multi tab login in Django
I have a django application and i want to prevent the user with same credentials to login multiple times. i am able to achieve this using the following code as middleware: class UserRestrict(object): def process_request(self, request): """ Checks if different session exists for user and deletes it. """ if request.user.is_authenticated(): cache = get_cache('default') cache_timeout = 86400 cache_key = "user_pk_%s_restrict" % request.user.pk cache_value = cache.get(cache_key) if cache_value is not None: if request.session.session_key != cache_value: engine = import_module(settings.SESSION_ENGINE) session = engine.SessionStore(session_key=cache_value) session.delete() cache.set(cache_key, request.session.session_key, cache_timeout) else: cache.set(cache_key, request.session.session_key, cache_timeout) However , this prevents the login from different IP addresses. Now i want to implement something that can prevent the login if the user trying to login through different tab of the same browser? PS - i am open if this could be achieved just through javascript as i know that Django user session key is same for the browser. -
django-admin.py startproject can't create project on Windows.
I am on Windows server, and when I type "django-admin.py startproject", I'm getting the following message. Looks like I'm not using the command properly, but it is correct. My Django version is Django 1.10, and Pythhon 2.7. c:\test>django-admin.py startproject mysite Usage: django-admin.py subcommand [options] [args] Options: -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output --settings=SETTINGS The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used. --pythonpath=PYTHONPATH A directory to add to the Python path, e.g. "/home/djangoprojects/myproject". --traceback Raise on exception --version show program's version number and exit -h, --help show this help message and exit Type 'django-admin.py help <subcommand>' for help on a specific subcommand. Available subcommands: [django] check cleanup compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages runfcgi runserver shell sql sqlall sqlclear sqlcustom sqldropindexes sqlflush sqlindexes sqlinitialdata sqlsequencereset startapp startproject syncdb test testserver validate -
use class Media in apps
I everyone I have some extension page and apps in my django-cms, I try to load some JS file in my app like this, in my admin.py class CustomCodeAdmin(admin.ModelAdmin): class Media: js = ('js/connect.js', 'js/testing.js') admin.site.register(CustomCode, CustomCodeAdmin) But the I have the same configuration en my extension page and it works perfectly. from django.contrib import admin from cms.extensions import PageExtensionAdmin from .models import IconExtension class IconExtensionAdmin(PageExtensionAdmin): class Media: js = ('js/connect.js', 'js/testing.js') admin.site.register(IconExtension, IconExtensionAdmin) Any idea why work in one and no in the others? Thanks in advance! -
multiple models in one form only one is required
I have two models, one view and one form. all the fields are required in both models. but, I want the user to be able to fill up the first model's fields without require filling the second model's fields as long as the fields are all empty. models.py : class Parent(models.Model): title = models.CharField(max_length=250) address = models.CharField(max_length=250) class Kid(models.Model): family = models.ForeignKey(Parent) title = models.CharField(max_length=250) age = models.CharField(max_length=250) views.py def add_family(request): if request.method == 'POST': parent_form = ParentForm(request.POST) kid_form = KidForm(request.POST) if parent_form.is_valid() and kid_form.is_valid(): parent = parent_form.save(commit=False) parent.save() kid = kid_form.save(commit=False) kid.family = parent kid.save() return redirect('index') else: parent_form = ParentForm() kid_form = KidForm() template = 'add_family.html' context = {'parent_form': parent_form, 'kid_form': kid_form} return render(request, template, context) template: {% csrf_token %} {{ parent_form.title }} {{ parent_form.address }} {{ kid_form.title }} {{ kid_form.age }} Send and ideas? -
single sign on and authorization using python and django/flask
i have a large database which is used for running more than one project with django. I want to implement a system where each projects of these asks for authentication from another project whose only task is to return success/failure flag for user when provided with credentials. Plus, I want to make a system of authorization, like one user from southern region can only see data related to south region,(I think a custom manager will solve my problem). I also want that at UI level i should be able to mark some button or table appear only if user logged in is authenticated and has permissions to view that button and thus access data accordingly. how should i go about the authorization of UI-elements is a great fix for me. Thanks. -
Django Trouble Creating ManyToMany Field
Migrating my Access app to Python/Django. Existing database, so used Inspectdb to create models, which I adjusted as needed until they matched actual db. All models marked Manage = False in Meta. Now I want to add a many-to-many field in a parent table, and having troubles. Snippets of models: class Federalprograms(models.Model): fedpgmid = models.IntegerField(db_column='FedPgmID', primary_key=True) # Field name made lowercase. fedpgmname = models.CharField(db_column='FedPgmName', max_length=50) # Field name made lowercase. active = models.IntegerField(db_column='Active', blank=True, null=True, default=0) # Field name made lowercase. seq = models.IntegerField(db_column='Seq', blank=True, null=True, default=0) # Field name made lowercase. loanfee = models.DecimalField(db_column='LoanFee', max_digits=10, decimal_places=5, blank=True, null=True, default=0.00000) # Field name made lowercase. class Reports(models.Model): reportname = models.CharField(db_column='ReportName', primary_key=True, max_length=50) # Field name made lowercase. reporttitle = models.CharField(db_column='ReportTitle', max_length=50, blank=True, null=True) # Field name made lowercase. datefielddefault = models.IntegerField(db_column='DateFieldDefault', blank=True, null=True) # Field name made lowercase. startdatedefault = models.CharField(db_column='StartDateDefault', max_length=15, blank=True, null=True) # Field name made lowercase. enddatedefault = models.CharField(db_column='EndDateDefault', max_length=15, blank=True, null=True) # Field name made lowercase. detailsdefault = models.BooleanField(db_column='DetailsDefault', max_length=1, blank=True, null=False) # Field name made lowercase. totalsdefault = models.BooleanField(db_column='TotalsDefault', max_length=1, blank=True, null=False) # Field name made lowercase. askfedpgm = models.BooleanField(db_column='AskFedPgm', blank=True, null=False, default=0) # Field name made lowercase. fedpgms = models.ManyToManyField('Federalprograms') So I added the … -
Django Url.py Parameters
I followed the Django tutorial on how to use the url dispatcher, but for the life of me cannot figure out why I am getting this error. Reverse for 'details' with arguments '('my_address',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['details(?P<zip>[0-9]+)/$'] My url.py: url(r'^details(?P<zip>[0-9]+)/$', views.search_details, name='details'), The url used in my template: <h1><a href="{% url 'details' data.zip%}">Data for {{data.zip}}</a></h1> My view method declaration: def search_details(request,zip): When I try remove the parameter(zip) from the above code, the template renders, so I would believe the url is correct. -
Python Social Auth - Django - Check if the social media e-mail already is in the DB
I am having the following problem: Ex: Jonh register: username; John123 email: foo@gmail.com then Paul register using his gmail social foo@gmail.com In my DB I will end up heving two e-mails (which I allow them to login using it), besides other problems it can generate. So, how can I check if the e-mail already exists when the user login/register through goolgle+ api? Thanks -
How to install Django app on a customers server without exposing the business logic and db access
I'm developing a simple data mining web application using Django Rest Framework + some simple javascript on client side and I want to offer it as a paid service in future. The problem is, that the application will be processing sensitive and some times huge data with restricted access. So my initial idea is to treat this kind of cases by installing the simpler version of the website on the customers server in his intranet (only localhost) and all the data handling could be done on his machine, so there would be no need to set up special permissions to access his data from my website and also I would not have the need to host all the data. The database for the administration of this local server should be of course on my server, so I could easily change the content and functionality through the db. Now the problem is, that I would like to do all this without exposing the business logic of my application. The main data handling functions would be done in cython, so the customer would only see the compiled code. But how to hide my master database for user administration, logging and everything sensitive … -
object of type 'WSGIRequest' has no len()
I'm running Python3 Django 1.10.3 with current Celery 4.0.0, redis-server stable and rabbitmq. This error happens on both Windows and Linux ubuntu. Google search of this error doesn't turn any conclusive results. This is the error stack: Environment: Request Method: POST Request URL: https://*/rod/eposta/?cid=17 Django Version: 1.10.3 Python Version: 3.5.2 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'vodnik', 'schedule', 'djangobower'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _legacy_get_response 249. response = self._get_response(request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view 23. return view_func(request, *args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view 23. return view_func(request, *args, **kwargs) File "/var/www/etaborniki/rod/views.py" in eposta 133. email = rodSendEmail.delay(zadeva, clan, sporocilo, request, msgid) File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py" in delay 413. return self.apply_async(args, kwargs) File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py" in apply_async 536. **options File "/usr/local/lib/python3.5/dist-packages/celery/app/base.py" in send_task 709. root_id, parent_id, shadow, chain, File "/usr/local/lib/python3.5/dist-packages/celery/app/amqp.py" in as_task_v2 333. argsrepr = saferepr(args, self.argsrepr_maxsize) File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in saferepr 74. o, maxlen=maxlen, maxlevels=maxlevels, seen=seen File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in _saferepr 104. for token, it in reprstream(stack, seen=seen, maxlevels=maxlevels): File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in reprstream 155. for val in it: File … -
Django Gunicorn error
I'm trying to deploy django application on digital ocean using their tutorial how to setup django. Like others I'm also facing 502 error. I saw that no myproject.sock file generated. How to fix the error. my /etc/systemd/system/gunicorn.service [Unit] Description=gunicorn daemon After=network.target [Service] User=root Group=www-data WorkingDirectory=/home/root/myproject ExecStart=/home/root/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/root/myproject/myproject.sock myproject.wsgi:application [Install] WantedBy=multi-user.target -
How to add custom migrations to external Django apps
I've done some monkeypatching to some third-party apps in my custom Django 1.10 app, and now, when I try to create an initial migration, it also generates migrations for these external apps, but it puts those migrations in my virtualenv's site-packages directory, where they can't be version controlled. Moreover, the monkeypatching doesn't actually change the schema. I'm just changing the verbose name and help text to be more user-friendly. There are no changes being made to the database, so there's no actual need to generate migrations for them. How do I generate my app's migration without generating them for external apps? I tried deleting them, and removing them from my app's migration's dependencies list, but then my unittests won't run and I get the error: django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases for... -
Can I query the DB using a glob pattern?
I'm having trouble trying to query db using a glob pattern. I thougth that maybe glob could be translated to regex, and I know I can query db using regex. I was going to to that translation myself, but I found that python has fnmatch to do just that, explicitly the function translate fnmatch.translate(pattern) Return the shell-style pattern converted to a regular expression for using with re.match(). So I tried to combine both things but... >>> from vte.models import VTE >>> import fnmatch >>> regex = fnmatch.translate('19*') >>> regex '19.*\\Z(?ms)' >>> VTE.objects.filter(ipaddr__regex=regex) Traceback (most recent call last): File "<console>", line 1, in <module> File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 234, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__ self._fetch_all() File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all self._result_cache = list(self.iterator()) File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 52, in __iter__ results = compiler.execute_sql() File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 848, in execute_sql cursor.execute(sql, params) File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/var/www/vtfx/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) DataError: invalid regular expression: quantifier operand invalid I don't understand the error message. According to django's … -
Django Autocomplete Light - FK Field Results not Forwarding
I'm following along in the DAL documentation to add a filtered field to my form, but the forwarding isn't working to connect one field to the other: Forms.py class PurchaseForm(forms.ModelForm): commodity = forms.ModelChoiceField( queryset=Commodity.objects.all(), widget=autocomplete.ModelSelect2(url='commodity-autocomplete'), required=False, ) class Meta: model = Purchase fields = ["variety"] widgets = { 'variety': autocomplete.ModelSelect2(url='variety-autocomplete', forward=['commodity'], } Views.py class VarietyAutocompleteView(autocomplete.Select2QuerySetView): def get_queryset(self): qs = Variety.objects.all() commodity = self.forwarded.get('commodity', None) print("Commodity:" + str(commodity)) if commodity: qs = qs.filter(commodity=commodity) if self.q: qs = qs.filter(name__istartswith=self.q) return qs I'd like my Variety choices to be filtered by their foreign key relationship to Commodity objects. Both autocomplete fields are working on their own just fine, but the choice from the commodity field is not being forwarded to the VarietyAutocompleteView (my print command prints Commodity:None). Is this perhaps because I am passing a foreign key object? Or have I set this up incorrectly somehow? -
Maximum recursion depth trying to create Django migration
When I try to generate an initial migration for my Django app with: python manage.py makemigrations myapp I get a traceback like: File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct name, path, args, kwargs = super(USStateField, self).deconstruct() File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct name, path, args, kwargs = super(USStateField, self).deconstruct() File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct name, path, args, kwargs = super(USStateField, self).deconstruct() File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct name, path, args, kwargs = super(USStateField, self).deconstruct() RuntimeError: maximum recursion depth exceeded while calling a Python object The only odd thing I'm doing that's probably the cause is I'm trying to monkeypatch the USStateField from the localflavor package. Specifically, I need to set custom state choices from the field's state list, so I'm doing: from localflavor.us import models as us_models _USStateField = us_models.USStateField class USStateField(_USStateField): description = _("U.S. state (two uppercase letters)") def __init__(self, *args, **kwargs): kwargs['choices'] = MY_STATE_CHOICES kwargs['max_length'] = 2 super(_USStateField, self).__init__(*args, **kwargs) us_models.USStateField = USStateField This worked perfectly in Django 1.7, but now gives me this error in Django 1.10. Is there a better way to do this? -
pagination and m2m field
I am creating a simple slideshow and am having trouble getting pagination to work. The list of images returned is correct but I can't work out how to paginate .Currently all images show on each page, including ones who's publish field is set to false. eg: If a slideshow has 10 images and two of them are publish=False the pagination links will correctly display "Image 1 of 8" but all ten images will display on each of the 8 pages. The update filter is alsi ignored models.py class Image(models.Model): ... image = models.FileField(upload_to="img/site/slideshow/images/") publish = models.BooleanField(default=True) ... class Slideshow(models.Model): ... title = models.CharField(blank=False, max_length=45) images = models.ManyToManyField(Image) ... views.py def slideshow(request, pk): this_slideshow = Slideshow.objects.filter(pk=pk) image_list = slideshow_list.filter.filter(images__publish=True).order_by('-updated') paginator = Paginator(image_list, 1) page = request.GET.get('page', '1') try: p = paginator.page(page) except PageNotAnInteger: p = paginator.page(1) except EmptyPage: p = paginator.page(paginator.num_pages) return render_to_response('slideshow/image_slideshow.html', {'slideshow_list': slideshow_list, 'image_list': image_list, 'p': p}) urls.py urlpatterns = [ url(r'^images/slideshow/(?P<pk>[0-9]+)/$', views.slideshow), template {% if p.paginator %} {% for item in p.object_list %} {% for img in item.images.all %} {{ img.title }}<br /> <img src="/media/{{ img.image }}"> {% endfor %} {% endfor %} {% endif %} {% if p.paginator %} <p> {% if p.has_previous %} <a href="?page={{ p.previous_page_number … -
How to link foreign key in a class based view in Django
class IndexView(generic.ListView): template_name = "posts/index.html" def get_queryset(self): return Inspectionfile.objects.all() class DetailView(generic.DetailView): model = Inspectionfile template_name = "posts/detail.html" class createposts(CreateView): model = posts fields = ['title','comments'] via the createposts and using forms I can populate the title and comments but they are not being linked with any Inspectionfile(the foreign key). I want the users to be linked without them having to choose. The following is my model. So I want to link every post to a particular inspectionfile. class Inspectionfile(models.Model): document_upload =models.FileField() document_type = models.CharField(max_length=10) document_title = models.CharField(max_length = 250) document_check =models.CharField(max_length = 250) def __str__(self): return (self.document_title + self.document_type) class posts(models.Model): inspectionfile= models.ForeignKey(Inspectionfile, on_delete = models.CASCADE,default = 1) title = models.CharField(max_length =120) comments = models.TextField() flag = models.BooleanField(default = False) def get_absolute_url(self): return reverse ('posts_form', kwargs={'pk': self.pk}) def __str__(self): return self.title -
django and morris.js charts: not displaying the chart
I am trying to use a morris chart in django. I have the following code but it doesn't display the chart when I load the page. var bar = new Morris.Bar({ element: 'bar-chart', resize: true, data: [ {% for item in data %} { period: '{{ item.period }}', addition: '{{ item.addition }}', depreciation: '{{ item.depreciation }}' }{% if not forloop.last %},{% endif %} {% endfor %} ], barColors: ['#00a65a', '#f56954'], xkey: 'period', ykeys: ['addition', 'depreciation'], labels: ['Addition', 'Depreciation'], hideHover: 'auto' }); This is what I have in my django view: def index(request): mydata = [] mydata = ADRAnalysis.objects.values_list('period', 'addition', 'depreciation').filter(period__in=['Jan-2016', 'Feb-2016', 'Mar-2016']) return render(request, 'app/index.html', {'data': mydata,}) I am not sure why it's not loading the data. Can someone help pointing out what I am doing wrong or how it should be properly done? -
Django 1.10 - TemplateSyntaxError when rendering two dimensional dictionary to js code of template file
I am pretty new to Django. Trying to view my poll statistics via chartjs I am using a two dimensional dictionary to show results to chart. In the dictionary I get all information(they are fine). But when I am trying to render the data within js code of template file, facing a error. Here is the code - var myChart = new Chart(ctx, { type: 'line', data: { labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], datasets: [ {% for key, value in vote_records.items() %} { label: {{ choice_texts[key] }}, data: {{ value }}, backgroundColor: [ 'rgba(255, 99, 132, 0.2)', ], borderColor: [ 'rgba(255,99,132,1)', ], borderWidth: 1 }, {% endfor %} ] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); I get following error - TemplateSyntaxError at .......... Could not parse the remainder: '()' from 'vote_records.items()' But in view I exactly used the same procedure to handle dictionary. Thanks for your help! -
What is the use of STATIC_URL in Django
New to django. building an app for my company.Have the basic setup up and running. Regarding static files. i was able to understand the following: STATIC_ROOT - files where the static files would be copied op collectstatic command STATIC_DIR- list where static files live. Now what is the use of STATIC_URL, Raad through a lot of resources, not able to understand it. Can any one please explain ? Thanks -
How to get a Django ModelForm to redirect to another ModelForm on submit?
I have a template which displays a certain ModelForm at one of the URLs of my Django site. The ModelForm is based on a model with two fields, class ActionCode(models.Model): action_code = models.CharField(blank=False, max_length=10, verbose_name="Action Code") description = models.TextField(blank=True) class Meta: unique_together = ('action_code',) I would like my ModelForm to give the user only the first field (Action Code), then when it is submitted, verify if the value entered already exists or not. If it doesn't already exist, I want to redirect the user to be able to enter a Description for that Action Code (the second field in my model). So I wrote a second ModelForm which uses the Description field of the model, and I would like my first form to redirect to the second form after validating that the data is new. Ideally then, the Description would be linked to this specific piece of data and both would go into the same Django database table (hence them coming from the same model). However, when I enter a new piece of data and hit Submit, the site simply stays at the /action_code/ URL and displays a Submit button, and nothing else. How do I get the first form … -
Multiple foreign keys to one many to many field
Simple question, I want to list two different models in one many to many field like this: campaigns = models.ManyToManyField(PremiumCampaign, SMSCampaign, null=True) Is this possible? OR how should this be done to get the results as expected -
2 virtual env + celery + supervisor unix:///var/run/supervisor.sock no such file
I'm using redis as the backend and I have 2 virtual env each with it's own celery workers. I'm having a weird issue when I'm adding the celery supervisord conf of the second virtual env. This is the error I'm getting after reloading supervisord: unix:///var/run/supervisor.sock no such file This is the supervisord conf file: [program:shopify-celery] command=dir/bin/celery worker --app=app -l warning -Q queue -n worker -P eventlet -c 3 directory=/dir user=user group=webapps numprocs=1 stdout_logfile=/dir/logs/celery-worker.log stderr_logfile=/dir/logs/celery-worker.log autostart=true autorestart=true startsecs=10 ; Need to wait for currently executing tasks to finish at shutdown. ; Increase this if you have very long running tasks. stopwaitsecs = 600pip freez ; When resorting to send SIGKILL to the program to terminate it ; send SIGKILL to its whole process group instead, ; taking care of its children as well. ;killasgroup=true ; if rabbitmq is supervised, set its priority higher ; so it starts first ;priority=998 I couldn't find what might caused this. Do you know what went wrong? -
Heroku free tier billing for a non-stop web and worker process in one application
I have a Python app that pings an API every minute and records data into a database. I also have a Django web app that is the client for displaying this data (it should also not be idling, as I will explain bellow). Heroku recently made changes again to their free tier, allowing 1000hrs/month for verified accounts. I have verified my account to take advantage of this. What is not clear to me is how the usage hours will be counted in my situation. Will my Heroku application accumulate ~750 hours per month, or 2x750 hours after non-stop running? Are the two lines inside the Procfile considered separate dynos, thus each will be accumulating 750 hours per month? Setup Procfile: worker: python api_crawler.py web: gunicorn api_data_client.wsgi --log-file - I found out that if the web process begins to idle after 30 minutes of inactivity, it will also bring down the worker process with it. This is not a desired outcome for me, as I need the worker process to be running non-stop. After some reading I found that the 'New Relic' monitoring addon can help keep the web process from idling, which is good, unless I will run out of …