Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Stylized HTML fields in Django admin
I Have TextField to store HTML text. I want to colorize HTML tags. I use TinyMCE but didn't need an HTML editor like WordPress just simple to colorize like IDE, Search a lot but didn't find anything useful, So if you can help I appreciate it. My field: I want output like this but changeable: -
django API view for javascript Ajax request
Let's say I have a Chart demo class Chart(models.Model): data = models.TextField() I store and load data in format of JSON, manipulate data and tries to render a chart on frontend. User case can be: user use app interface to generate data, upload it data is uploaded to backend and stored within an Chart instance use detail view and a redirect url to illustrate the result def chartDetailView(request, pk): chart = Chart.objects.get(pk=pk) return render(request, 'chart/chart.html', {'data': chart.data}) there are many website that allows costume JS request, for example, Web: how to redirect to a CodePen or JsFiddle with information filled?. since the static page only requires a data context to perform functionality, is there a way I can build an Ajax for javascript to open a new tab for the view? I mean, to code a view which can be requested by anchor link, form, Ajax or fetch with data passed in by JS, and return a static page. (no Chart instance stored) sorry the question may seems ignorant to you, I have learned little about rest framework. I will be very grateful for any suggestion you make. any source to look at. -
How to default language - error in changing it - Django
I have been struggling for quite a while with translation in django. I want to set a default language that is being set everytime user access the website (in a new session). I have studied django documentation, and I found the following algorithm: First, it looks for the language prefix in the requested URL. This is only performed when you are using the i18n_patterns function in your root URLconf. See Internationalization: in URL patterns for more information about the language prefix and how to internationalize URL patterns. Failing that, it looks for a cookie. The name of the cookie used is set by the LANGUAGE_COOKIE_NAME setting. (The default name is django_language.) Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations. Failing that, it uses the global LANGUAGE_CODE setting. So I am trying to set the language prefix in the requested URL. I have configured my app as follows: settings.py MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'crm.middleware.RequestMiddleware', ] .... EXTRA_LANG_INFO = { 'md': … -
How to store static file on Google cloud storages using heroku deployment?
I used whitenoise to save static files, but now I want to save them to Google cloude storage. So I reset dyno and set it as follows, but the static folder is not created in storage. I'm not sure what I'm missing. google_credential is working well. The upload file is well stored. The level is also done without problems. However, static files are not generated in GCS. settings.py configuration if DEBUG is False : ALLOWED_HOSTS = ["cineacca.herokuapp.com", 'cineacca.com',] GOOGLE_APPLICATION_CREDENTIALS = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") DEFAULT_FILE_STORAGE = "config.custom_storages.UploadStorage" STATICFILES_STORAGE = "config.custom_storages.StaticStorage" STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') GS_DEFAULT_ACL = "publicReadWrite" GS_BUCKET_NAME = "cineacca_bucket" GS_PROJECT_ID = os.environ.get("GS_PROJECT_ID") MEDIA_URL = "/media/" STATIC_URL = "/static/" django_heroku.settings(locals()) custom_storages.py from storages.backends.gcloud import GoogleCloudStorage from storages.utils import setting class StaticStorage(GoogleCloudStorage): bucket_name = setting('GS_BUCKET_NAME') location = "static/" class UploadStorage(GoogleCloudStorage): bucket_name = setting('GS_BUCKET_NAME') location = "uploads/" -
Button type "submit" doesn't let bootstrap modal to open but type="button" doesn't fulfill my need
I have a web page in which there is an input field. And below is an edit button. When I enter some text in the input field and press the edit button, a modal pops up and there is an input field in it also. I want to pass the text from the first input field to the input field in the modal window. But then a problem arises. The modal window only opens when the edit button has type="button". But this type="button" doesn't submit the text input to the backend when I click the edit button. It submits the text to the backend when I use button type="submit", but then the modal doesn't open because the page reloads. Here's my HTML code: <div class="container"> <div class="row manage-groups"> <div class="row g-0 login_form justify-content-center" id="contactForm" novalidate="novalidate"> <form method="POST"> {% csrf_token %} <div class="col-md-12 form-group"> <input type="text" class="login-inpt" id="name" name="type-groups" placeholder="type in the group name"> </div> <div class="row g-0 justify-content-center group-action"> <div class="col-sm-4 submit-group"> <div> <button type="submit" data-bs-toggle="modal" data-bs-target="#ModalAddGroups" class="button-box">Add</button> </div> </div> <div class="col-sm-4 submit-group"> <button type="button" onclick="form_submit()" data-bs-toggle="modal" data-bs-target="#ModalEditGroups" class="button-box">Edit</button> </div> <div class="col-sm-4 submit-group"> <button type="submit" data-bs-toggle="modal" data-bs-target="#ModalDeleteGroups" class="button-box">Delete</button> </div> </div> </form> </div> </div> </div> <!-- Modal window for Edit button … -
Django - Create random dummy data for testing that doesn't break the test suite
I'm trying to think of a way to create random test data of a certain model type for running python manage.py test. So for example if I have a model Post like below. model.py class Post(models.Model): uuid = models.UUIDField(primary_key=True) created = models.DateTimeField('Created at', auto_now_add=True) updated_at = models.DateTimeField('Last updated at', auto_now=True, blank=True, null=True) creator = models.ForeignKey( User, on_delete=models.CASCADE, related_name="post_creator") body = models.CharField(max_length=POST_MAX_LEN, validators=[MinLengthValidator(POST_MIN_LEN)]) some sort of library that'll generate this with random body, random creator from user table would be nice. I tried factory boy, but when the test DB rolls back the DB after a test function it seems to rollback factory boy created dummy data as well even if it's declared in setUpTestData function. This rollback process causes a constrain error since the original data no longer exists. What's a good library or way to create dummy data for Django testing that doesn't break the test suite? dummy_factory.py class PostFactory(DjangoModelFactory): class Meta: model = Post creator = factory.Iterator(User.objects.all()) body = factory.Faker('text') Note: Another option is to just create a function let's say make_dummy_post that uses Post.objects.create() and randomly samples a User and users factory boy to generate body, but I feel like there's a better way to do it … -
Bootstrap toast messages showing for the first card in loop element in a Django project
I want to toast messages for all those cards. but it is showing for the first card only. I have attached a view of my page where I want to add a toast message to view the details of the card if a user is not logged in. Here is a view of my page. document.getElementById("toastbtn").onclick = function() { var toastElList = [].slice.call(document.querySelectorAll('.toast')) var toastList = toastElList.map(function(toastEl) { return new bootstrap.Toast(toastEl) }) toastList.forEach(toast => toast.show()) } <section class="details-card"> <div class="container"> <div class="row"> {% for homes in home %} <div class="col-md-4 mb-4"> <div class="card-content"> <div class="card-img"> <img src="{{ homes.coverImg.url }}" alt="Cover Image"> <span><h4>{{ homes.pricePerMonth }}Taka</h4></span> </div> <div class="card-desc"> <p class="small mb-1"> <i class="fas fa-map-marker-alt mr-2"></i>{{homes.address}}</p> <h3>{{ homes.title}}</h3> {% if request.user.is_authenticated %} <a href="{% url 'HomeDetails' homes.id %}" class="btn btn-md btn-primary hover-top">Details</a> {% else %} <button type="button" class="btn btn-primary" id="toastbtn">XDetails</button> {% endif %} </div> </div> </div> {% endfor %} </div> </div> </section> <!-- Alert Message Popup--> <!--bottom-0 end-0 p-3--> <div class="position-fixed top-50 start-50 translate-middle p-3" style="z-index: 11"> <div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> <img src="({% static 'img/icon.png' %})" class="rounded me-2" alt="..."> <strong class="me-auto">My Second Home</strong> <small>0.1s ago</small> <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> </div> <div class="toast-body"> Hello!<br>You need to login … -
Pytest-xdist does not honour settings.DATABASES (or I am doing something wrong)
I am trying to use pytest-xdist for running parallel tests. It works and I see improved performance. To improve further more, I wanted to provide it multiple databases by using django_db_modify_db_settings_xdist_suffix I override that functions in my conftest.py. Since I have four workers, I created four databases manually. Then I use conftest to modify the settings.DATABASES to test for DBNAME against DBNAME_ I verified that my settings.DATABASES has changed and is correct. But the queries are still going to old db DBNAME (which is no longer in my settings.DATABASES) What could be going wrong? Do I need to make any other change? Or change in conftest.py fixture is enough? Thanks in advance for any help or direction. -
DJANGO PARENT AND CHILD CLASS DEFINITION
I actually defined a child class that would inherit the same attributes from the parent class. I also registered the models because I needed to work with them through the admin site just to ensure they work as intended. On accessing the child class at the Django's admin site, the error message displayed; Exception Type: TypeError Exception Value: init() missing 3 required positional arguments: 'content', 'topic', and 'date_added' This was my syntax: class Topic_SON(Topic_SHIM): """A class that models research topics related to Nursing Sciences (NS).""" def __init__(self, topics, date_added): """Initializes attributes from the parent class""" super().__init__(topics, date_added) class Content_SON(Content_SHIM): """A class that models research topic contents related to NS.""" def __init__(self, content, topic, date_added): """Initializes attributes from the parent class""" super().__init__(content, topic, date_added) I feel my approach to defining the child class isn't good enough. Please how do I resolve this? -
what's the value type of the value of request.POST in djagno?
This is from print(request.POST) <QueryDict: {'csrfmiddlewaretoken': ['2Tg4HgJ07qksb3hPUDWSQYueYOjYOkQcmzll9fnjbJ0GZHkWHdM8DtYqZB4uv3Fv'], 'username': ['boycececil'], 'password': ['sunescafe..']}> This is from print(request.POST.get('username')) boycececil So as you can see, list -> string, that's magic!Isn't it? So, somebody know what's going on? -
python selenium chromedriver high CPU usage on parallel execution
I need to run multiple (i.e. 100) scans parallelly using selenium but because of the high CPU usage, my server is getting crushed very quickly. I'd like to know how can I significantly decrease high CPU usage because even if I run 5 scans at a time the CPU usage still hits more than 50%? Should I use another webdriver or can I somehow slow down the scan time but save CPU power(i.e. apply limits)? I've applied some options to decrease the CPU utilization but it didn't help. Below is the chrome options def get_chrome_options(): options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('window-size=1200x600') options.page_load_strategy = 'normal' options.add_argument('--no-sandbox') options.add_argument("--disable-setuid-sandbox") options.add_argument("--disable-dev-shm-usage") options.add_argument('--disable-gpu') options.add_argument("--disable-extensions") options.add_argument('--ignore-certificate-errors') options.add_argument("--FontRenderHinting[none]") return options I need to create and run a web driver from my web app (Django) so I have to create a new webdriver each time I make an HTTP request and I can't reuse the same webdriver. Below is the example. def run_scan(request, url): driver = webdriver.Chrome(executable_path=settings.CHROME_DRIVER, options=get_chrome_options()) driver.get(url) print(driver.page_source) Below info describes my current environment Python - 3.9.7 Selenium - 3.141.0 Chromedriver - 93.0.4577.82 OS - alpine linux -
Docker Postgres volume erasing on container restart
Every time I kill my containers and restart them, the data within the db tables is no longer there. docker-compose.yml: version: "3.8" services: db: image: postgres:13-alpine env_file: - .env.dev volumes: - pgdata:/var/lib/postgresql/data backend: build: context: ./backend command: python manage.py runserver 0.0.0.0:8000 expose: - 8000 env_file: - .env.dev volumes: - ./backend:/backend depends_on: - db frontend: build: context: ./frontend dockerfile: Dockerfile volumes: - ./frontend:/frontend - frontend_build:/frontend/build environment: CHOKIDAR_USEPOLLING: "true" depends_on: - backend nginx: build: context: ./nginx ports: - 80:80 volumes: - frontend_build:/var/www/frontend depends_on: - backend - frontend - db volumes: backend_vol: pgdata: frontend_build: .env.dev: POSTGRES_ENGINE='django.db.backends.postgresql' POSTGRES_DB=test-db POSTGRES_USER=dev-user POSTGRES_PASSWORD=dev-pw POSTGRES_HOST='db' POSTGRES_PORT=5432 Any thoughts on why this is happening would be appreciated... -
Django Admin page outdated? showing nonexistent model
My django admin page is still showing a model I used to have. I have deleted this model in the code, Then I updated the imports / serializers and registered the new model I made to admin: admin.site.register(watcher_item_tracker_db) and then ran python .\manage.py makemigrations python .\manage.py migrate I have also tried: python manage.py migrate --run-syncdb However, when I go to the admin page for django I can still see the old model I used to have, and I cannot see the new model. Whenever I click on the old model that should not be there, I get this error: OperationalError at /admin/jobs/selenium_watcher_item_db/ no such table: jobs_selenium_watcher_item_db Request Method: GET Request URL: http://10.0.0.233:8000/admin/jobs/selenium_watcher_item_db/ Django Version: 3.1.1 Exception Type: OperationalError Exception Value: no such table: jobs_selenium_watcher_item_db There is no mention of "selenium_watcher_item_db" in my code anywhere after I replaced it with the new item, I tried everything I could think of other than restarting. -
I keep getting this error when i want to query data from a model in mysql database : AttributeError: 'str' object has no attribute 'utcoffset'
This is the code from my Django shell from Inec_results.models import PollingUnit, Lga local = Lga.objects.all() print(local) And I get this error all the time I try to query that model. I'm new to Django please help me out Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\db\models\query.py", line 256, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\db\models\query.py", line 262, in __len__ self._fetch_all() File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\db\models\query.py", line 1354, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\db\models\query.py", line 68, in __iter__ for row in compiler.results_iter(results): File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\db\models\sql\compiler.py", line 1149, in apply_converters value = converter(value, expression, connection) File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\db\backends\mysql\operations.py", line 311, in convert_datetimefield_value value = timezone.make_aware(value, self.connection.timezone) File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\utils\timezone.py", line 262, in make_aware if is_aware(value): File "C:\Users\olaniran\.virtualenvs\BincomDev-TkuS52cz\lib\site-packages\django\utils\timezone.py", line 228, in is_aware return value.utcoffset() is not None AttributeError: 'str' object has no attribute 'utcoffset' -
Django pip freeze > requirements.txt not getting the exact packages installed in the virtual env
Django pip freeze > requirements.txt not getting the exact packages installed in the virtual env rather it's getting all the packages i have ever installed and it's kinda not what i exactly wants, let me show some image of whats happening there are still more packages below, please what can i do -
Can't refresh image on pythonanywhere website
Good evening! I have created a webapp using Django framework. I have replaced a file in the /static/ folder locally (and put the same name for the new file). Then I pushed those changes to my GitHub repo and pulled them using bash console for my pythinanywюhere web app. Then I tried to reload the page, but I got the following message on pythonanywhere: "Your webapp took a long time to reload. It probably reloaded, but we were unable to check it". The file was not replaced and the webpage shows and old version of image. What should I do with this situation? I can't even suggest what the problem is. -
Adding Field Manually in DJango Form
I am making a login system in django, I want the Data of My Forms to Save in The in-built "User" table and my custom made "coders" together. My Form Has 6-7 fields which i want to insert in custom table. but I can only insert "username" and "password" in "User" table. I cant figure out how i can separate "username" and "password" from "FORM" . Here is My Code def f1(request): form = codersform() form2 = User() if request.method == 'POST': form = codersform(request.POST) if form.is_valid: form.save() form2 = coders.objects.filter('name', 'pasw') form2.save() user = form.cleaned_data.get('name') messages.success( request, "Account Created Successfully For " + user) return redirect('login') else: messages.error(request, "Please Fill Out All Fields Correctly") return render(request, 'signup.html', {'form': form}) Thanks :) -
Package libffi was not found in the pkg-config search path Docker
I would like to install some Django packages including django-rest-auth and django-allauth. These packages are able to be installed in my local venv but when building and running Docker containers they give exit code 1 with the errors: Package libffi was not found in the pkg-config search path. -
Simplify writing if/else collection of Django queries
I have code in a Django views.py that looks like: if query_type == 'list': if column == 'person': person_qs = Person.objects.filter(Person__in = query_items_set) elif column == 'grandparent': person_qs = Person.objects.filter(grandparent__name__in = query_items_set) elif column == 'child': person_qs = Person.objects.filter(child__name__in = query_items_set) elif query_type == 'regex': if column == 'person': person_qs = Person.objects.filter(Person__regex = regex_query) elif column == 'grandparent': person_qs = Person.objects.filter(grandparent__name__regex = regex_query) elif column == 'child': person_qs = Person.objects.filter(child__name__regex = regex_query) When it comes to writing views, is there a more accepted/concise way of avoiding repitition, while still maintaining readability and extensibility? -
ModelMultipleChoiceField is not working with UUID as primary key
I have a scenario where I have a field that is hidden....and when this field is a normal PK as generated by Postgresql all is well. When I change said PK to a UUID instead...not so much. When the field is defined as a normal PK the form submits fine. When it's a UUID...I get SELECT A VALID CHOICE....... class AuthorForm(forms.ModelForm): def __init__(self, user, *args, **kwargs): super(AuthorForm, self).__init__(*args, **kwargs) self.fields['book'] = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple(), queryset=Author.objects.filter(author=user).exclude(Q(is_active="False")),required=False) The above works fine if Author PK is a normal PK. When it's a UUID...that's when it won't submit. I've read about this and it would appear that you have to override the selections somehow as a possible answer..so I tried... class AuthorForm(forms.ModelForm): def __init__(self, user, *args, **kwargs): super(AuthorForm, self).__init__(*args, **kwargs) self.initial['book'] = [c.pk for c in Author.object.filter(author=user)] But it still gives me that same error...SELECT A VALID CHOICE..... Anyone else run into this? -
Django-filter does not filter
I have a project model that is connected to manytomany with a user. Initially, I create a queryset that includes all the projects of the logged in user. The queryset contains two projects, one of them author = False. After I filter it as /project/list/?Shared=True but this does not work. After filtering, there should have been only one project left, but still two are returned, I cannot understand what this is connected with model class Project(models.Model): name = models.CharField(max_length=255, blank=True, null=True) members = models.ManyToManyField(User, through="UserProject", related_name="project") class UserProject(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) project = models.ForeignKey(Project, on_delete=models.CASCADE) author = models.BooleanField(default=False) api class ListProjectApi(ListApi): serializer_class = ProjectSerializer lookup_field = "id" queryset = Project.objects.all() filter_backends = (DjangoFilterBackend,) filterset_class = ProjectFilter def get_queryset(self): user = self.request.user projects = user.project.all() return projects filter class ProjectFilter(rest_framework.FilterSet): author = rest_framework.BooleanFilter(field_name="author", method="filter_author") shared = rest_framework.BooleanFilter(field_name="shared", method="filter_shared") class Meta: model = Project filter_fields = ["author", "shared"] def filter_author(self, queryset, name, value): if name == "author" and value is True: logger.info(queryset) projects = queryset.filter(userproject__author=True) logger.info(projects) return projects logs 2021-12-24 17:54:59,927 ruchnoi INFO <QuerySet [<Project: test>, <Project: author>]> None 2021-12-24 17:54:59,932 ruchnoi INFO <QuerySet [<Project: test>, <Project: author>]> None -
uploading file is not working in django update forms but working in create
i'm using a forms to create and update a form. template and form is the same but view is different. the problem is uploading image is working in create but not in update. no file will not be applied and in post method i receive i get this: /media/<filename> it seems that upload_to path is not applied and no file is uploaded. here is the model: image = models.ImageField(upload_to='%Y/%m/%d', null=True, blank=True) and here is the form: image = forms.ImageField(label='Image', required=False, allow_empty_file=True) and here is the template: <form enctype="multipart/form-data" action="{% if edit == True %}{% url 'update' device_type serial_number %}{% else %}{% url 'addItem' %}{% endif %}" method="POST"> {% csrf_token %} <div style="padding-right: 20px; padding-left: 20px"> {{ form.image.label }}: {{ form.image }} </div> <button type="submit" class="btn">submit</button> </form> above codes are simplified btw. anyone knows why this happening. -
How can I upload to different buckets in Django and Google Storage?
I'm able to upload a file in Google Storage but the problem is that it goes to the default bucket where my static files are: GS_BUCKET_NAME='static-files' I'd like to continue uploading the static files to the 'static-files' bucket, but I would like to also upload the user files to a different bucket: 'user-upload-files' How can I do this in Django 3.2.7, Python 3.9.7 For reference, right now I'm doing: from django.core.files.storage import default_storage file = default_storage.open(filename, 'w') file.write('testing'') file.close() -
How can I control the column order using 'annotate', 'values' and 'union' in Django?
I have 2 models: class Hero(models.Model): name = models.CharField(max_length=50) age = models.PositiveSmallIntegerField() identity = models.TextField(max_length=50) class Villain(models.Model): villain_name = models.CharField(max_length=50) age = models.PositiveSmallIntegerField() identity = models.TextField(max_length=50) and I create some test instances: Hero(name="Superman", age=30, identity="Clark Kent").save() Hero(name="Iron Man", age=35, identity="Tony Stark").save() Hero(name="Spider-Man", age=18, identity="Peter Parker").save() Villain(villain_name="Green Goblin", age=45, identity="Norman Osborn").save() Villain(villain_name="Red Skull", age=38, identity="Johann Schmidt").save() Villain(villain_name="Vulture", age=47, identity="Adrian Toomes").save() Since the Villain model doesn't have a name field, we use annotation before doing a union. Then, using them in a union produces results where the columns aren't all where they should be: >>> from django.db.models import F >>> characters = Hero.objects.all().values('name', 'age', 'identity').union(Villain.objects.all().annotate(name=F("villain_name")).values('name', 'age', 'identity')) >>> for character in characters: ... print(character) {'name': 38, 'age': 'Johann Schmidt', 'identity': 'Red Skull'} {'name': 45, 'age': 'Norman Osborn', 'identity': 'Green Goblin'} {'name': 47, 'age': 'Adrian Toomes', 'identity': 'Vulture'} {'name': 'Iron Man', 'age': 35, 'identity': 'Tony Stark'} {'name': 'Spider-Man', 'age': 18, 'identity': 'Peter Parker'} {'name': 'Superman', 'age': 30, 'identity': 'Clark Kent'} Looking at the raw sql queries, we see this: >>> str(Hero.objects.all().values('name', 'age', 'identity').query) 'SELECT "myapp_hero"."name", "myapp_hero"."age", "myapp_hero"."identity" FROM "myapp_hero"' >>> str(Villain.objects.all().annotate(name=F("villain_name")).values('name', 'age', 'identity').query) 'SELECT "myapp_villain"."age", "myapp_villain"."identity", "myapp_villain"."villain_name" AS "name" FROM "myapp_villain"' The auto-generated sql contains columns that aren't in the same order for … -
celery flower connection issue with --persistent True
I was running celery flower 1.0.0 as a systemd service with --persistent=True. And every time on restarting the service, it didn't use to restart successfully, instead, it used to throw error SSLV3_ALERT_HANDSHAKE_FAILURE. Upon removing --persisten=True it used to work perfectly on every restart, but then I couldn't get my celery flower database be intact after each restart. Here is what worked for me.