Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django admin page login causing IIS to crash, need to restart iis everytime
My site is working fine. I can access all the pages. But when I am accessing admin page, it loads, prompts for username and password. After entering username and password when clicked login, it takes sometimes and after that I get below error: This page isn’t working mytestapp.company.com didn’t send any data. ERR_EMPTY_RESPONSE After refreshing the page, I get below error: Service Unavailable HTTP Error 503. The service is unavailable. After this no page loads. After restarting IIS using cmd (iisreset /noforce) again when I try to refresh the homepage, I see I am logged in which means admin page logged me in but after that response did not come and it something went wrong on the server side which caused server to crash. I am not sure how to proceed with this. Earlier my admin site use to work fine. No recent changes in code. The only change I did is I synced the DB from another DB which has more data. I am using virtual env which has python version is 2.7.3, Django version 1.3 in it IIS version 7.5 on WindowsServer 2008R2 (Python IsAPIe handler) Please help me on this. I am stuck with this issue... -
Creating a Path Based on SlugFields in Django
I have a Django project based around creating tournaments and nesting specific objects within them. For instance, every tournament has multiple committees. When someone creates a tournament, I allow them to create a link with a SlugField. My code (so far) is as follows: models.py from django.db import models from django.utils.text import slugify class Tournament(models.Model): name = models.CharField(max_length=50) slug = models.SlugField(max_length=50, unique=True) def _get_unique_slug(self): ''' In this method a unique slug is created ''' slug = slugify(self.name) unique_slug = slug num = 1 while Tournament.objects.filter(slug=unique_slug).exists(): unique_slug = '{}-{}'.format(slug, num) num += 1 return unique_slug def save(self, *args, **kwargs): if not self.slug: self.slug = self._get_unique_slug() super().save(*args, **kwargs) class Committee(models.Model): name = models.CharField(max_length=100) belongsTo = models.ForeignKey(Tournament, blank=True, null=True) slug = models.SlugField(max_length=50, unique=True) def _get_unique_slug(self): ''' In this method a unique slug is created ''' slug = slugify(self.name) unique_slug = slug num = 1 while Committee.objects.filter(slug=unique_slug).exists(): unique_slug = '{}-{}'.format(slug, num) num += 1 return unique_slug def save(self, *args, **kwargs): if not self.slug: self.slug = self._get_unique_slug() super().save(*args, **kwargs) views.py from django.shortcuts import render, get_object_or_404 from .models import Tournament, Committee def tournament_detail_view(request, slug): tournament = get_object_or_404(Tournament, slug=slug) return render(request, 'tournament/detail.html', {'tournament': tournament}) def committee_detail_view(request, slug): committee = get_object_or_404(Committee, slug=slug) return render(request, 'committee/detail.html', {'committee': committee}) urls.py … -
How do i fix an error that occus when creating django model manager
I am creating a blog app from the book django 2 by example by antonio mele. I am on the sub topic creating model managers. However, as soon as i edit my models.py file, the power shell window that hosts the local server displays this error: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03B61300> Traceback (most recent call last): File "C:\Users\public\django\my_env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\public\django\my_env\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inne r_run autoreload.raise_last_exception() File "C:\Users\public\django\my_env\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception raise _exception[1] File "C:\Users\public\django\my_env\lib\site-packages\django\core\management\__init__.py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Users\public\django\my_env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\public\django\my_env\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\public\django\my_env\lib\site-packages\django\apps\registry.py", line 112, in populate app_config.import_models() File "C:\Users\public\django\my_env\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Users\public\django\my_env\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\public\django\mysite\blog\models.py", line 1, in <module> class PublishedManager(models.Manager): NameError: name 'models' is not defined This is the code on the models.py file class PublishedManager(models.Manager): def … -
How to downgrade CKEditor js library to 4.6.2 version in Django?
I need the old style Paste dialog. How can I use CKEditor library 4.6.2? I am using Django 2.1. When I install django_ckeditor 5.2.2 I get error ModuleNotFoundError: No module named 'django.core.urlresolvers' -
Create Custom admin table in django
I have an existing database with 58 tables that has two tables for administrators called admins and admin_permissions, and now i want to make django admin panel for my database and create admin users in admins table, how can i do this? note: I run the python manage.py inspectdb > models.py command for creating models from my database -
Celery as daemon on FreeBSD
I'm looking for set Celery as Daemon on my FreeBSD server with my Django web application. This server contains already a Celery Daemon for an other application and I would like to create a new service. There aren't lot of documentations about Celery Daemon on FreeBSD so I need your help. In Django I have a celery.py file : import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings.base') app = Celery('app-main') app.config_from_object('django.conf:settings', namespace='CELERY') # Load task modules from all registered Django app configs. app.autodiscover_tasks() Then I created a celeryd-app file in /etc/default/ : # Names of nodes to start # most people will only start one node: CELERYD_NODES="worker" # but you can also start multiple and configure settings # for each in CELERYD_OPTS #CELERYD_NODES="worker1 worker2 worker3" # alternatively, you can specify the number of nodes to start: #CELERYD_NODES=10 # Absolute or relative path to the 'celery' command: #CELERY_BIN="/usr/local/bin/celery" #CELERY_BIN="/usr/local/www/app/venv/bin/celery" CELERY_BIN="/usr/local/bin/celery" # App instance to use # comment out this line if you don't use an app CELERY_APP="main-app" # Where to chdir at start. CELERYD_CHDIR="/usr/local/www/app/src/web/" # Extra command-line arguments to the worker CELERYD_OPTS="--time-limit=300 --concurrency=8" # Configure node-specific settings by appending node name to arguments: #CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1" … -
'CategoryDetail' object has no attribute '_state'
Iam a newbie and I would love to get your. I want to get the properties by categories. When i try to reach for example : http://127.0.0.1:8000/category/Berlin following error comes. 'CategoryDetail' object has no attribute '_state' What Iam doing wrong ???? Any help would be highly appreciated. Kind regards models.py from django.db import models from django.urls import reverse # Create your models here. class Property(models.Model): title = models.CharField(max_length=140) description = models.TextField() rooms = models.PositiveIntegerField() bed_rooms = models.PositiveIntegerField() land_size = models.PositiveIntegerField() slug = models.SlugField() living_size = models.PositiveIntegerField() build_year = models.PositiveIntegerField() price = models.PositiveIntegerField() category = models.ForeignKey(to='Category', null=True, related_name='categories', on_delete=models.SET_NULL,) def get_absolute_url(self): return reverse('properties:PropertyDetail', kwargs={'slug': self.slug}) def __str__(self): return '{} - {}'.format( self.title, self.build_year ) class Category(models.Model): name = models.CharField(max_length=150) slug = models.SlugField() def get_absolute_url(self): return reverse('properties:CategoryDetail', kwargs={'slug': self.slug}) def __str__(self): return '{}'.format(self.name) views.py from django.shortcuts import render from .filters import PropertyFilter # Create your views here. from django.views.generic import ( TemplateView, DetailView, ListView ) from .models import Property, Category class HomePage(TemplateView): template_name = 'home.html' class PropertyList(ListView): model = Property class PropertyDetail(DetailView): model = Property class CategoryList(ListView): model = Category class CategoryDetail(ListView): queryset = Category.categories template_name = 'categorydetail.html' def search(request): property_list = Property.objects.all() property_filter = PropertyFilter(request.GET, queryset=property_list) return render(request, 'prop_list.html', {'filter': property_filter}) … -
Could not parse the remainder: '[0]' from 'rates[0]' - porting flask app to Django 2
I have this method on my views.py: def getExchangeRates(request): """ Here we have the function that will retrieve the latest rates from fixer.io """ rates = [] response = urlopen('http://data.fixer.io/api/latest?access_key=c2f5070ad78b0748111281f6475c0bdd') data = response.read() rdata = json.loads(data.decode(), parse_float=float) rates_from_rdata = rdata.get('rates', {}) for rate_symbol in ['USD', 'GBP', 'HKD', 'AUD', 'JPY', 'SEK', 'NOK']: try: rates.append(rates_from_rdata[rate_symbol]) except KeyError: logging.warning('rate for {} not found in rdata'.format(rate_symbol)) pass return render(request, 'index.html', rates) This is my template (originally from a Flask app): {% block header %} <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <div align="center" style="margin-top:35px;"><a href="/historical"><button type="button" class="btn btn-primary">Historical</button></a></div> {% endblock %} {% block body %} <script type="text/javascript" src="https://www.google.com/jsapi"> </script> <div id="chart_div" style="width: 900px; height: 500px;"><div> <script type='text/javascript'>//<![CDATA[ google.load('visualization', '1', {packages: ['corechart', 'bar']}); google.setOnLoadCallback(drawBasic); function drawBasic() { var data = google.visualization.arrayToDataTable([ ['Currency', 'Rate', { role: 'style' }], ['USD', {{rates[0]}}, 'gold'], ['GBP', {{rates[1]}}, 'silver'], ['HKD', {{rates[2]}}, 'brown'], ['AUD', {{rates[3]}}, 'blue'], ['SEK', {{rates[1]}}, 'red'], ['JPY', {{rates[2]}}, 'yellow'], ['NOK', {{rates[3]}}, 'orange'], ]); var options = { title: 'Exchange rate overview', chartArea: {width: '50%'}, hAxis: { title: '', minValue: 0 }, vAxis: { title: '' } }; var chart = new google.visualization.BarChart(document.getElementById('chart_div')); chart.draw(data, options); } //]]> </script> {% endblock %} Now, it throws me this: Internal Server Error: / Traceback (most recent call … -
Google App Engine Standard - ImportError - Exception Value: cannot import name exceptions
I am trying to deploy a Django 1.11.18 project to google app engine standard and I am getting following error. I am uploading all the required library along with my project. Any help is appreciated. -
Downloading files from the server in a Django application
I want an app in my Django project to generate a list of files stored at a known location on the server, present them as a list to the user, with links for them to download. I am comfortable with Python, and am also familiar with Jinja templating syntax, rendering a template etc.. The bit I am struggling with is the concept of MEDIA files in Django. Everything seems concerned with handling uploaded files. I simply want to access files at a known location on the server (one which is however, outside of my Django project). Is this possible? Is this workflow sensible or am I fundamentally misunderstanding a core concept? Is there some kind of approach (like collectstatic) that should be used, to pull all media files into the project for deployment and then allow them to be served? I am just getting in to Django and have made some basic sites and applications which work well. The fundamentals seem to make sense to me. This is my first attempt a doing some file downloading, and this is where I have run into issues. Note: I have a feeling that perhaps getting files from outside the Django project might … -
Redis+Django cause a servor error (500) with ubuntu 18.04 on a cloud server
I tried to install Redis on Django in a Digitalocean droplet following this guide : https://www.digitalocean.com/community/tutorials/how-to-install-redis-from-source-on-ubuntu-18-04 and this other guide before : https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04. I can use redis via the console with redis-cli, but on each web page a redis command there is an error 500. In views.py : # Redis import redis from django.conf import settings # Connect to Redis r = redis.StrictRedis ( host = 'localhost', port = 6379, db = 0) I don't know at all what is the source of this problem. -
django-notifications-hq: how to implement
I'm using the django-notifications-hq for my django practice project which is an online booking for salon clients. I'm quite new to django and hoping to learn much more. How can I implement the notification so that my users/employee will be notified that a new booking was created. Can you please give me some examples as the django-notifications-hq documentation is a little bit confusing for me. Any pointers or examples are much appreciated. Thank you. -
How display post "on moderation" for admin at site page "Post list" at Django 2.1?
I want to display a new post, which exist "on moderation", for the administrator (staff), at site page "Post list" (template "post_list.html"), for example "scrin1" (Post 1 - published; Post 2 - "on moderation"). Regular user can see "Post list" only with published posts, see "scrin2". This to ensure that each admin didn't enter in to the admin panel of the site, but can published this post from the site page "Post update" (template "post_form.html"), for example "scrin3". I tried to do it with staff_member_required in views.py (form_valid in PostListView), but it didn't work out. If post was edited, must go moderation too before publish edited version. models.py class Post(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=50) body = models.TextField() moderation = models.BooleanField(default=False) def __str__(self): return self.title def get_absolute_url(self): return reverse('post-detail', kwargs={'pk': self.pk}) forms.py from .models import Post class PostForm(forms.ModelForm): title = forms.CharField(required=True) body = forms.CharField(widget=forms.Textarea) class Meta: model = Post fields = ['title', 'body'] views.py from .forms import PostForm class PostListView(generic.ListView): model = Post paginate_by = 10 def get_queryset(self): queryset = super(PostListView, self).get_queryset() return queryset.filter(moderation=True) class PostCreateView(FormView): form_class = PostForm template_name = 'blog/post_form.html' success_url = reverse_lazy('posts') def form_valid(self, form): response = super(PostCreateView, self).form_valid(form) form.instance.user = self.request.user form.save() return response … -
Unable to Update last_login field of djnago in-built user
Built in User model of django contains last_login field. I am updating last_login when user logouts from the website. views.py: def logout(request): template = loader.get_template('logout.html') print("I am Loging out... BYY", request.user.id) User.objects.filter(id=request.user.id).update(last_login=timezone.now) auth.logout(request) return HttpResponse(template.render({}, request)) I am getting Error on User.objects.filter(id=request.user.id).update(last_login=timezone.now) which says expected string or bytes-like object -
Perform trigonometric operations or any mathematical expression in Django annotate
I have a table which is having latitude and longitude fields. ` location.objects.annotate( distance =math.fabs(math.pow((math.sin( F('latitude') - float(90.378770)) /2 )),2) + math.cos(90.378770) * math.cos( F('latitude')) * pow((math.sin( (F('longitude') - float(-59.826830)) /2)),2) ) ).values_list('distance', flat=True) ` How to do perform this equivalent mathematical operation on data and store the values in a list while doing database query. -
PYTHON / JAVA Socket: ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
The following error occurred when the client server was trying to hit my django API via JAVA Socket. I am using Python's local server Exception happened during processing of request from ('192.168.10.36', 59028) Traceback (most recent call last): File "D:\ProgramFiles\Python\Python36\lib\socketserver.py", line 651, in process_request_thread self.finish_request(request, client_address) File "D:\ProgramFiles\Python\Python36\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "D:\ProgramFiles\Python\Python36\lib\socketserver.py", line 721, in __init__ self.handle() File "D:\ProgramFiles\Python\Python36\lib\site- packages\django\core\servers\basehttp.py", line 153, in handle self.handle_one_request() File "D:\ProgramFiles\Python\Python36\lib\site- packages\django\core\servers\basehttp.py", line 161, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "D:\ProgramFiles\Python\Python36\lib\socket.py", line 586, in readinto return self._sock.recv_into(b) ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host My API code is as follows: def API_detect(self, request): """Start the script""" serializer = serializers.DetectionSerializer(data=request.data) if serializer.is_valid(): on_off = serializer.data.get('checker') if on_off == "start": print("on") if on_off == "stop": print("off") m = 'Received {0}'.format(on_off) return Response({'message': m}) else: return Response( serializer.errors, status=status.HTTP_400_BAD_REQUEST) -
Get the Users list : Except the user which is looking for the Users / Logged In User
Get all the users except current logged in user, so for example if a user X is logged in and he wanted to see all the users, the query should return all the users except the user X. I just getting started with python so it's the learning phase, I am very thankful for your help. So far i have tried with different params: users = User.objects.filter(username!=current_user.username) -
i cant set AbstractUser Data
i cant change user fields with form and it s not give errors form.is_Valid functions always return false how can i solve this problem Code Pictures: https://i.hizliresim.com/bVyGyn.png https://i.hizliresim.com/dvXGXQ.png https://i.hizliresim.com/5aYQYA.png https://i.hizliresim.com/AD3knQ.png -
Service provided by mobile operators and plans available for particular services
I want to integrate the below requirement in the website I want to show services related to Telecom operators like Plans - Calls/Messages/Data, Bundles, Packages, Phones, Plans with phones, Recharges, ADSL, VAS, Roaming on the website. is there any API available for getting plan and packages available for the particular operator for e.g if the user selects AIRTEL I want to display all the plans and bundles details in the webpage. Can anyone please advice me I should I implement, where can I get particular operator data, is it through some API? Also, I want to use mobile OTP activation, Can anyone please recommend API for sending messages to mobile through a web application. Note: I am using DJANGO for creating this application Thanks in advance -
How to redirect to a url when using modal forms in django
Having a model (ProductSerialNumbers) which simulates a product with a serial number and after a successful implementation of the CRUD cycle with the aid of modal fm forms https://github.com/django-fm/django-fm i face up the problem of unsuccessful redirection to other url after a successful delete of the object. The app keeps showing the modal fm window after clicking ok(for delete). How can i solve that to redirect to my list of ProductSerialNumbers? Here is my code of the view and a part of my template concerning the modal-delete. view class ProductSerialNumbersDeleteView(LoginRequiredMixin, AjaxDeleteView): model = ProductSerialNumbers success_url = reverse_lazy('warehouse_stuffing') '''Function for deleting only the ProductSerialNuumbers which belong to an order, otherwise can not delete ''' # Patch queryset to get the productSerialNumber def delete(self, request, *args, **kwargs): self.object = self.get_object() if (self.object.order): print("It belongs to an order, do not delete") return redirect('/warehouse_stuffing/') else: print("It is not in an order,delete") self.object.delete() print(self.success_url) return redirect('/warehouse_stuffing/') seems that the redirect() function is not working properly. template <td><a href="{% url 'warehouse_stuffing_delete' products_with_serial_numbers.id %}" class="fm-delete" data-fm-head="Delete of entry {{ products_with_serial_numbers }};" data-fm-callback="reload" ><button class="btn btn-danger btn-sm" type="">Delete</button></a></td> -
AttributeError when setting custom DEFAULT_METADATA_CLASS
I have written a custom metadata class for OPTION requests. This class is located in myproject.api.metadata.py and is called PermissionsMetadata. On individual views, I can set metadata_class = PermissionsMetadata and it works as expected. However, when setting DEFAULT_METADATA_CLASS in my settings like so: REST_FRAMEWORK = { 'DEFAULT_METADATA_CLASS': 'api.metadata.PermissionsMetadata', ... } ... I get the following when running any test: ImportError: Could not import 'api.metadata.PermissionsMetadata' for API setting 'DEFAULT_METADATA_CLASS'. AttributeError: module 'rest_framework.views' has no attribute 'APIView'. I just need the metadata class to apply to all views by default without having to set the metadata_class attribute on every view. I don't mind moving the class elsewhere. By the way, setting the default metadata class to rest_framework.metadata.SimpleMetadata doesn't result in this exception. Help greatly appreciated. -
How to fix ImageField upload in django rest framework?
I am trying to upload a profile image to the media folder, while this works perfectly from the django admin web interface, it doesn't upload from the api endpoint, it gives the media root with image name, but i cannot access the image nor is it in the location pointed to by the get_upload_path method. Any help would be greatly appreciated. settings.py: MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, "media") This is expected result: '"http://127.0.0.1:8000/media/profile_photo/aafaaaaaa2a%40gmail.com/lol.jpg"' This is what am getting: "http://127.0.0.1:8000/media/test.jpg" -
install django on centos 6 (sqlite3 error)
I am trying to install Django 2.1 on Centos6 but I'v got no success. according to this issue and this documentations of Django 2.1, Django 2.1 needs SQLite 3.7.15 and later. after knowing this I tried to upgrade sqlite and sqlite-devel to 3.7.17 by CERT Forensics repo but nothing changed after upgrading to 3.7.17 and I still get this error at running server by manage.py: Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f7561c29950> Traceback (most recent call last): File "/root/django-project/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/root/django-project/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect self.connection = self.get_new_connection(conn_params) File "/root/django-project/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 159, in get_new_connection conn = Database.connect(**conn_params) sqlite3.NotSupportedError: URIs not supported The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/root/django-project/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/root/django-project/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run self.check_migrations() File "/root/django-project/venv/lib/python3.6/site-packages/django/core/management/base.py", line 442, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/root/django-project/venv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/root/django-project/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/root/django-project/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph self.applied_migrations = recorder.applied_migrations() File "/root/django-project/venv/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations if self.has_table(): File "/root/django-project/venv/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table return self.Migration._meta.db_table … -
How to set field value based on what user click in Django ListView
I have two models Parent and Child. I would like to display both values in a ListView, whereby there is an Add Child button for each family. Supposed that the parents are already populated, when I click Add Child, I would love that in the form of Child, the parent field are already set to the corresponding family name (please see code below). Simple model would be: class Family(models.Model): family_name = models.CharField(max_length=100, default='', blank=False) father_name = models.CharField(max_length=100, blank=False, default='') mother_name = models.CharField(max_length=100, blank=False, default='') def get_absolute_url(self): return reverse('family-list') def __str__(self): return str(self.family_name) class Children(models.Model): parent = models.ForeignKey(Family, blank=False, default=None, null=True, on_delete=models.PROTECT, related_name='their_child') child_name = models.CharField('4Jet ID', max_length=100, default='', blank=False) birth_date = models.DateField(default=timezone.now, blank=False) def get_absolute_url(self): return reverse('family-list') # both return to family list view The View using simple generic view: class FamilyList(ListView): model = Family template_name = '/family_list.html' context_object_name = 'fam_list' # class NewParent omitted class NewChild(CreateView): model = Children template_name = '/child_new.html' context_object_name = 'child' fields = [ 'parent', 'child_name', 'birth_date' ] and the simplified template: <!--file: family_list.html--> {% for fam in fam_list %} <table> <tr> <th class="header"></th> <th class="header">Family Name</th> <th class="header">Father's First Name</th> <th class="header">Mother's First Name</th> <th class="header">Add Child</th> </tr> <tr> <td>+</td> <td>{{ fam.family_name }}</td> <td>{{ … -
Use Celery with 2 Django applications
I have a question about Celery with 2 Django applications on the same server (server is a FREEBSD server). Let suppose that we have app1 and app2. App1 gets a celery.py file like this : import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings.base') app = Celery('main-app1') app.config_from_object('django.conf:settings', namespace='CELERY') # Load task modules from all registered Django app configs. app.autodiscover_tasks() The second one has the same file but I changed app = Celery('main-app1') to app = Celery('main-app2') On my server, I have a celeryd file configured for app1 like this : # Names of nodes to start # most people will only start one node: CELERYD_NODES="worker" # but you can also start multiple and configure settings # for each in CELERYD_OPTS #CELERYD_NODES="worker1 worker2 worker3" # alternatively, you can specify the number of nodes to start: #CELERYD_NODES=10 # Absolute or relative path to the 'celery' command: #CELERY_BIN="/usr/local/bin/celery" #CELERY_BIN="/usr/local/www/app1/venv/bin/celery" CELERY_BIN="/usr/local/bin/celery" # App instance to use # comment out this line if you don't use an app CELERY_APP="main-app1" # Where to chdir at start. CELERYD_CHDIR="/usr/local/www/app1/src/web/" # Extra command-line arguments to the worker CELERYD_OPTS="--time-limit=300 --concurrency=8" # Configure node-specific settings by appending node name to arguments: #CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1" # Set …