Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can I make only 4 results but still continue the data in Templates in Django
I have a ListView that returns all the User (with profile pictures) and render it on an Sliding Div and in that Div there's only need a 4 Users and the other x are on the next slide. Till now I can figure it out :( -
How can a page stay where it is instead of refreshing and going to the top after interact with a domestic link such as 'edit'?
So I've built a Django forum, just added in the comment function. Here's a minor annoying thing needs to be sorted... Problem: When editing a comment, after pressing edit button/link, the page naturally refreshes itself, going to the top of the page instead of, what I hope for, staying right where it was... This isn't nice or friendly at all... Here's the code: url.py app_name = 'forum' urlpatterns = [ path('topic_<int:topic_pk>/<int:post_pk>/edit_<int:comment_pk>/', views.post, name='edit_comment'), ] views.py def post(request, topic_pk, post_pk, comment_pk=None): '''displaying one post under a topic and all the comments under this post''' # get existing topic and post topic = get_object_or_404(Topic, pk=topic_pk) try: post = topic.post_set.get(pk=post_pk) except: raise Http404 # get all the comments under this post comments = post.comment_set.order_by('-pk') # deal with comment editing if comment_pk != None: comment_to_be_edited = get_object_or_404(Comment, pk=comment_pk) if 'delete' in request.POST: comment_to_be_edited.delete() return redirect('forum:post', topic_pk, post_pk) # get form with existing data ready to be rendered or edited/updated edit_comment_form = CommentForm(instance=comment_to_be_edited) if 'update' in request.POST: edit_comment_form = CommentForm(instance=comment_to_be_edited, data=request.POST) if edit_comment_form.is_valid(): edit_comment_form.save() return redirect('forum:post', topic_pk, post_pk) # if not to delete or to update, simply render the existing form with comment data ready to be edited return render(request, 'forum/post.html', { 'topic': topic, 'post': … -
Django & Bootstrap: Updating form using Django Bootstrap Modals
My current path: ticket-strap/ ticketstrap/ templates/ home.html index.html tickets/ __pycache__ migrations templates/ tickets/ tickets_dashboard.html (ticket_dashboard file in question) __init__.py admin.py apps.py forms.py (forms file in question) models.py (models file in question) tests.py urls.py (urls file in question) views.py (views file in question) ticketstrap/ __pycache__ __init__.py asgi.py settings.py urls.py (urls file in question) views.py wsgi.py I am working on a ticket management system program that incorporates Bootstrap 4 and Bootstrap 4 Modals. Right now I am trying to be able to edit data in Django datbase through the use of a modal form. I have a page that displays a ticket's information such as name, subject, priority, etc. At the bottom of the page is an Edit button. Once this button is clicked it activates and shows a Bootstrap Modal form that allows the user to enter in new information. There are no required fields - if the user wants to edit only the ticket subject they can, which should only update the ticket subject field in Django database. If they submit the form without entering anything it should make no changes. After submission the user should be redirected back to the same ticket details page with the updated information. I've … -
Combine Django and React in a single full stack project properly
I want to make a project where in backend I use Django and for fronted I want to use React. So in one project how can i combine this two with the help of Pycharm IDE or any other jetbrains IDE? Please give me some resources or a way to start. Thanks. -
update fields of created object django in one go
I am trying to update the get_or_create object. I don't know if there is any simple way. myapp/models.py from django.db import models class MyModel(models.Model): code = models.CharField(max_len=5) valid = models.BooleanField(default=True) relevant = models.BooleanField(default=True) use = models.CharField(max_len=10) date = models.DateField('date', null=True, blank=True) myapp\management\commands_my_command.py from myapp import MyModel my_obj_defaults = {'valid': False, 'relevant': False, 'use': 'useless'} my_obj, created = MyModel.get_or_create(code=mycode) if created: my_obj.save() else: my_obj.update(my_obj_defaults) It is giving AttributeError: 'MyModel' object has no attribute 'update' -
Django filter by month / year include all objects for previous years
So, I'm querying by an interative process, from user input of different month/years, to form collective sums of all objects before their input (financial data aggregates) If I do: mymodel.objects.filter( datetime__month__lte=query_month, datetime__year__lte=query_year, ) Then this doesn't work because let's say I do 12/2019. Great we get everything for 2019 as expected. Now, if I do 1/2020. It should include all of 2019 as well. But, naturally it will only do 1/2019 and 1/2020. How can I do inclusivity this way? -
Django error no such table: main.auth_user__old
I'm creating my first Django project. I am getting an error when I press the save button after adding the data to the text fields inside the products. This is the error I get: OperationalError at /admin/products/product/add/ no such table: main.auth_user__old Request Method: POST Request URL: http://127.0.0.1:8080/admin/products/product/add/ Django Version: 2.1 Exception Type: OperationalError Exception Value: no such table: main.auth_user__old Exception Location: C:\Users\Ehtsham\PycharmProjects\firstproject\venv\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296 Python Executable: C:\Users\Ehtsham\PycharmProjects\firstproject\venv\Scripts\python.exe Python Version: 3.8.1 Python Path: ['C:\\Users\\Ehtsham\\PycharmProjects\\firstproject', 'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', 'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', 'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', 'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32', 'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv', 'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages', 'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages\\setuptools-40.8.0-py3.8.egg', 'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages\\pip-19.0.3-py3.8.egg'] Server time: Sun, 5 Jan 2020 15:00:27 +0000 I'm using Django version 2.1 and SQLite DB browser on PyCharm IDE. -
Django form.is_valid() failing class based views - Form, SingleObject, DetailMixins
I have two apps, here we will call them blog and comments. Comments has a Comment model. Blog has a blog Model. Comments has a CommentForm. Blog has a DetailView. I want my CommentForm to appear on by Blog DetailView, so people can submit comments from the blog detail page. The form renders OK - it makes a POST request, it redirects to get_success_url() but (I've added a couple of prints to views.py - see below) in testing in views.py to see if the form data is received I see the form.is_valid() path is not met, and I don't understand why. I'm essentially trying to follow this, the 'alternative better solution': https://docs.djangoproject.com/en/2.2/topics/class-based-views/mixins/#using-formmixin-with-detailview blog/views.py class CommentLooker(SingleObjectMixin, FormView): template_name = 'blogs/blog_detail.html' form_class = CommentForm model = blog def get_object(self): #self.team = get_object_or_404(team, team_id=self.kwargs['team_id']) #queryset_list = blog.objects.filter(team = self.team) team_id_ = self.kwargs.get("team_id") blog_id_ = self.kwargs.get("blog_id") return get_object_or_404(blog, blog_id=blog_id_, team=team_id_) def post(self, request, *args, **kwargs): if not request.user.is_authenticated: return HttpResponseForbidden() self.object = self.get_object() return super(CommentLooker, self).post(request, *args, **kwargs) def get_success_url(self): return reverse('blogs:teams') class blogDisplay(View): def get(self,request,*args,**kwargs): view = blogFromteamContentView.as_view() return view(request, *args, **kwargs) def post(self,request,*args,**kwargs): view = CommentLooker.as_view() return view(request,*args,**kwargs) class blogFromteamContentView(LoginRequiredMixin, DetailView): model = blog template_name = 'blogs/blog_detail.html' # override get_object so we … -
'ManyRelatedManager' object has no attribute 'user'
i am trying to create a notifications system but am facing issues doing so. here is my code: I created a Notifications model where each entry is a notification. Every time a new entry is made into my SalesTask model , it invokes my signal handler which will create a new entry into my Notifications Model. I will then pass this model into my context and render it in my HTML. class Notifications(models.Model): notifications_id = models.AutoField(primary_key=True) user = models.ForeignKey(User) time = models.DateTimeField(auto_now=True) message = models.TextField(max_length=100 ,default ='test') object_url = models.CharField(max_length=500, default ='test') is_read = models.BooleanField(default=False) def CreateTaskNotification(sender,**kwargs): if kwargs['created']: notification = Notifications.objects.create(user = kwargs['instance'].salesExtra.username, message = 'You have been assigned a new task', object_url = kwargs['instance'].get_absolute_url(self) ) post_save.connect(CreateTaskNotification,sender=SalesTask) The issue with this is that my SalesTask Models : class SalesTask(models.Model): sales_status= ( ('p1','Phase 1'), ('p2','Phase 2'), ('p3','Phase 3'), ('p4','Phase 4'), ) sales_priority= ( ('Urgent','Urgent'), ('Medium','Medium'), ('Low','Low'), ) task_id = models.AutoField(primary_key=True) salesExtra= models.ManyToManyField('SalesExtra') sales_project= models.ForeignKey('SalesProject',on_delete=models.CASCADE) title = models.TextField(max_length=50 , default='Your Title' ) description = models.TextField(max_length=200 , default='Your Description' ) priority = models.TextField(max_length=10 , choices= sales_priority ,default='Low' ) date_time = models.DateTimeField(auto_now=True) status = models.TextField(max_length=10, choices= sales_status ,default='p1') due_date = models.DateTimeField(default=timezone.now) def __str__(self): return str(self.task_id) def get_absolute_url(self): return reverse('sales-task') has a many to … -
Django, override template block conditionally
{% extends "Flow/base.html" %} {% if no_tracking %} {% block head %} {% include "Flow/common/tracking/disabled.html" %} {% endblock %} {% endif %} The snippet of code aboves overrides the head block in base.html, even though no_tracking is False. How can I make this behavior conditional? I thought of this: {% block head %} {% if no_tracking %} {% include "Flow/common/tracking/disabled.html" %} {% endif %} <!-- How can I get "head" of base.html here? --> {% endblock %} But this would also override the head of base.html. head of base.html is not empty, it contains scripts that must be on the page when no_tracking is False. I could override them in base.html, but base.html has no concept of no_tracking since that is a context variable passed to the view being rendered and not the one it extends. How can I solve this? -
How to place search query on url on django?
I am creating a search application with Django. I made an article model and a Feedback model that records the rating of articles. After entering search box and displaying the search results, click one of the results then goes to the detail screen. After selecting feedback on the detail screen and pressing the submit button, I want to save a search query to the feedback model. I think that solution is to add a query in the URL like portal/search/?=query and read it, but I don't know how to code it. Also, could you teach me if there is an implementation method other than reading query in the URL? Also, when I go back from the detail screen, I want to display the previous search results too. Please comment if you have any questions. Forgive for my poor English. models.py from django.db import models from django.urls import reverse from taggit.managers import TaggableManager class KnowHow(models.Model): BASIC_TAGS =( ('1','one'), ('2','two'), ('3','three'), ('4','four'), ('5','five'), ('6','six'), ) CATEGORY =( ('1','Type2'), ('2','Type1'), ) author = models.ForeignKey('auth.User',on_delete=models.CASCADE) category = models.CharField(max_length=1,choices=CATEGORY,default='1') title = models.CharField(max_length=200) text = models.TextField(blank=True,default=' ') # delault=' ':import system will give a error if text column is null file = models.FileField(blank=True,upload_to='explicit_knowhows') basic_tag = models.CharField(max_length=1,choices=BASIC_TAGS,default='1') … -
After installation module django version switched to lowest version
I am working on project which use django as main project library. I faced with a need to install for this project new module django-inspect-model and django-inspect after playing with both i understood that those modules aren't appropriate solutions for me and i uninstall them by pip uninstall django-inspect-model I don't remember but one of these modules When was in installation progress i saw in console about messages about compatibility with my django version but i didnt pay attention for them. Because they are succesfully installed. After deinstallation of them i tried to run python manage.py shell which didn't run and printed in console that some of my installed modules imporerly configured for example celery after googling message error i understand that this kind of errors rise due to incompatibility with django i decided to check django version by python -c "import django;print(django.__version__)" Which promted me that installed django version is 1.8.6 but i exactly knew that before above described actions my django's version was 2.2.0 After checking of my requirements.txt file there isn't a doubt it was 2.2.0. How its possible that installed module can switch django on lowest version than it was? Is anyone who faced with the … -
Extending Custom User Model - Multiple User Types in Django
I'm relatively new(er) to django but very excited to learn such a versatile framework. I'm working on a project where I will have 2 user types, account 1 and account 2. Account 2 will have the ability to "add a user" to their account. Think of account 2 as a company who can add users to their company. So far I've extended the generic User model and have created a class for each of the account types but I'm not sure if I'm doing it correctly. Ultimately I will want to create a login/register form for each of the account types - similar to how ziprecruiter functions so some advice on how to approach that would be awesome too if possible. class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), unique=True) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) date_joined = models.DateTimeField(default=timezone.now) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = UserManager() def __str__(self): return self.email class account1(User): profile = models.ForeignKey(User, on_delete=models.CASCADE, related_name='+', null=True) # account 2 fields here first_name = models.TextField(max_length=30, blank=True) last_name = models.TextField(max_length=30, blank=True) location = models.TextField(max_length=30, blank=True) class Meta: db_table = 'account1_user' class account2(User): profile = models.ForeignKey(User, on_delete=models.CASCADE, related_name='+') # account2 user fields here class Meta: db_table = 'account2_user' -
What is pgettext_lazy in Django?
I was working with an open-source project (made in Django). I couldn't understand what pgettext_lazy is used for. Can you please tell me What is pgettext_lazy? Usage of pgettext_lazy? -
Assistance Required with Running Python Server
I am trying to execute 'python manage.py runserver' and keep receiving this error message. I have tried using SQL_Server.pyodbc and SQLServer_ADO as SQL Engines - but this does not appear to resolve the errors I am receiving. I have also excluded a few new python files from my project which I recently added since the system worked fine prior to adding in new python files. Traceback (most recent call last): File "\\shareddrives.nkfaulknerandsons.co.uk\Tutoring\PhD\DjangoWebProject1\DjangoWebProject1\manage.py", line 17, in <module> execute_from_command_line(sys.argv) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line utility.execute() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 338, in execute django.setup() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 108, in populate app_config.import_models() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\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 ".\polls\models.py", line 6, in <module> class Question(models.Model): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 124, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 325, in add_to_class value.contribute_to_class(cls, name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class self.db_table = truncate_name(self.db_table, … -
How do you set up django_extensions with postgresql in local dev?
Set up - local dev environment with postgres in a docker container and another running my web app. Problem - I'm unable to get django-extensions to print the sql query in the console. I've narrowed the problem down to postgresql. In my django settings I have DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres_db', 'USER': 'user', 'PASSWORD': 'password', 'HOST': 'db', 'PORT': 5432 } } Per https://django-extensions.readthedocs.io/en/latest/shell_plus.html#sql-queries it warns that - If using PostgreSQL the application_name is set by default to django_shell to help identify queries made under shell_plus. I'm guessing herein lies the problem but I don't know what 'application_name' refers to. Thanks in advance. -
How to call function within if statement in Django template
I have a custom template tag as following: @register.simple_tag def call_method(obj, method_name, *args): """ Usage in shell obj.votes.exists(user_id) in template {% call_method obj.votes 'exists' user.id %} """ method = getattr(obj, method_name) return method(*args) Then I can call it in the template (Class-based detail view) as following. {% call_method object.votes 'exists' user.id %} My question is how can use this template tag in If statement? For example, why I cannot use like: {% if call_method object.votes 'exists' user.id %} I am using django-vote [https://github.com/shanbay/django-vote][1] My goal is to check whether a user already voted so that I can change the class of the vote button. Otherwise, I can already check it in view. And it works fine. If it is not possible to use the simple tag with argument within If statement, could you please suggest a way to reach my goal? -
How to fix the error " 'id': Select a valid choice" on Modelformset validation?
I have a Modelformset that raises this validation error on submission: {'id': ['Select a valid choice. That choice is not one of the available choices.']} This error appears the same number of times as objects in my queryset, which is: qs = Task.objects.filter(property=property) Over the last few days I have been trying to fix this. I've read a lot of other similar posts and tried different solutions but none of them worked for me. My formset can be seen here: def add_taskcheck(request, property_pk, pk): property = get_object_or_404(Property, pk=property_pk) pcheck = get_object_or_404(Propertycheck, pk=pk) qs = Task.objects.filter(property=property) tasks = Task.objects.filter(property=property_pk) TaskCheckFormset = modelformset_factory(TaskCheck, form=TaskCheckForm, fields=('status','image','notes'), extra=0) if request.method == 'POST': formset = TaskCheckFormset(request.POST, request.FILES, queryset=qs) print(formset.errors) if formset.is_valid(): taskcheck = formset.save(commit=False) taskcheck.property_check=pcheck.id return HttpResponseRedirect(reverse('propertycheck:details', args=[pk])) else: formset = TaskCheckFormset(queryset=qs) context = { 'title':"Add Property Check", 'task':tasks, 'reference':property_pk, 'formset':formset, } return render(request, 'propertycheck/add-taskcheck.html', context) And my form: class TaskCheckForm(forms.ModelForm): status = forms.ModelChoiceField(queryset=TaskStatus.objects.all(), to_field_name="name", widget=forms.Select(attrs={ 'class':'form-control custom-select', 'id':'type', })) image = ... notes = ... class Meta: model = TaskCheck fields = ('status','image','notes') And finally my models: class TaskCheck(models.Model): status = models.ForeignKey(TaskStatus) image = models.ImageField(upload_to='task_check', blank=True, null=True) notes = models.TextField(max_length=500, blank=True) task = models.ForeignKey(Task) property_check = models.ForeignKey(Propertycheck) I already know that the problem is … -
options disabled once selected. (doing through multi-step form)
So I've implemented this through multi step wizard this time. here is where I've done with a simple way already. Waiting for the solution there. Well the issue is the same. I want to disable those option from the dropdown once they are selected and submitted. form.py class ContactForm1(forms.Form): dated = forms.ChoiceField(label="dates", widget=forms.Select(attrs={'class':'form-control'}), choices=dates ) class ContactForm2(forms.Form): sender = forms.CharField() view.py class ContactWizard(SessionWizardView): template_name = "mainapp/index.html" form_list = [ContactForm1] def done(self, form_list, **kwargs): return render(self.request, 'mainapp/done.html', { 'form_data': [form.cleaned_data for form in form_list], }) index.html {% block content %} <p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> <form action="" method="post"> {% csrf_token %} <table> {{ wizard.management_form }} {% if wizard.form.forms %} {{ wizard.form.management_form }} {% for form in wizard.form.forms %} {{ form }} {% endfor %} {% else %} {{ wizard.form }} {% endif %} </table> {% if wizard.steps.prev %} <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">"first step"</button> <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">"prev step"</button> {% endif %} <input type="submit" value="submit"> </form> {% endblock %} Again, how would I achieve it. I know this is storing the value into session and proceeding to the next step, but after the date is selected and submitted, how would I make it disable that … -
Which decorator can used for some view functions in djnago, which operates on input request?
Recently, I created a Django project. Now I want to use a decorator to control who can access a specific view. Actually I want to process header request and only allow to some users which their header request has a certain value. What is the best way to implement a decorator for it? first I decided to use user_passes_tests standard decorator but it can't accept header request as input argument. -
How to enter any budget value?
I set my Django model field budget but when I try the following... budget = models.DecimalField(max_digits=5, decimal_places=2) ...only non-numeric characters can be entered (like abc,# etc... This should work. - I can key in digits in other programs on my computer, but not in my web form budget field. - I tried other fields like: models.IntegerField() or models.PositiveIntegerField() - I ran npm run dev, python manage.py makemigrations, migrate, runserver. Same thing. Digit keys frozen. Any other ideas? Thanks. -
Why is channel layer not communicating with Redis in my django project?
Goodday everyone, I am new to channels and Redis and i tried to follow the this part of the channels documentation, which says; Let’s make sure that the channel layer can communicate with Redis. Open a Django shell and run the following commands: $ python3 manage.py shell >>> import channels.layers >>> channel_layer = channels.layers.get_channel_layer() >>> from asgiref.sync import async_to_sync >>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'}) >>> async_to_sync(channel_layer.receive)('test_channel'){'type': 'hello'} but i run into this error; >>> import channels.layers >>> channel_layer = channels.layers.get_channel_layer() >>> from asgiref.sync import async_to_sync >>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'}) Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\asgiref\sync.py", line 116, in __call__ return call_result.result() File "C:\Python37\Lib\concurrent\futures\_base.py", line 428, in result return self.__get_result() File "C:\Python37\Lib\concurrent\futures\_base.py", line 384, in __get_result raise self._exception File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\asgiref\sync.py", line 156, in main_wrap result = await self.awaitable(*args, **kwargs) File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\channels_redis\core.py", line 293, in send async with self.connection(index) as connection: File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\channels_redis\core.py", line 820, in __aenter__ self.conn = await self.pool.pop() File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\channels_redis\core.py", line 70, in pop conns.append(await aioredis.create_redis(**self.host, loop=loop)) File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\aioredis\commands\__init__.py", line 175, in create_redis loop=loop) File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\aioredis\connection.py", line 113, in create_connection timeout) File "C:\Python37\Lib\asyncio\tasks.py", line 414, in wait_for return await fut File "C:\Users\LENOVO\Project\BuildUp\lib\site-packages\aioredis\stream.py", line 24, in open_connection lambda: protocol, host, port, **kwds) File "C:\Python37\Lib\asyncio\base_events.py", … -
Is django-ckeditor a truly wysiwyg editor?
When I'm editing content in ckeditor, it looks great with all the styling applied. code snippet looks like: blockquote looks like: But when content is rendered it doesn't preserve any of the styling. Code snippets becomes : and blockquote becomes : -
converting python data to json and sending it as response to axios function
print(type(json.dumps(res))) print(json.dumps(res)) return HttpResponse(json.dumps(res), content_type="application/json") output: [[5671, 204], [5673, 192], [5674, 120], [5683, 120], [5684, 192], [5685, 204]] res is simple list , i am using this response in axios and it is array . what i don't understand how json.dump(res) is returning json object , it is simple str . json should be "key" : "value". Can some help me to understand this please. -
Gunicorn error running same Django configuration and code for the last three years
For the last three years below gunicorn configuration worked well: [program:hys] command= /usr/local/bin/gunicorn /var/www/h/o/u67098/public_html/project/apps/,/var/www/h/o/u67098/public_html/project/,/var/www/h/o/u67098/public_html/apps/,/var/www/h/o/u67098/public_html/ project.wsgi:application -b=0.0.0.0:8001 --workers=3 --timeout=90 --graceful-timeout=10 --log-level=INFO --log-file /var/www/h/o/u67098/public_html/logs/gun.log directory = /var/www/h/o/u67098/public_html/project/ user = hys autostart=true autorestart=true stdout_logfile = /var/www/h/o/u67098/public_html/logs/gunicorn_supervisor.log stderr_logfile= /var/www/h/o/u67098/public_html/logs/gunicorn_err_supervisor.log redirect_stderr = true ; Save stderr in the same log environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8 Since NY I am getting this error: [2020-01-05 10:45:16 +0000] [20624] [INFO] Starting gunicorn 19.7.1 [2020-01-05 10:45:16 +0000] [20624] [INFO] Listening at: http://0.0.0.0:8001 (20624) [2020-01-05 10:45:16 +0000] [20624] [INFO] Using worker: sync [2020-01-05 10:45:16 +0000] [20629] [INFO] Booting worker with pid: 20629 [2020-01-05 10:45:16 +0000] [20629] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/arbiter.py", line 578, in spawn_worker worker.init_process() File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/workers/base.py", line 126, in init_process self.load_wsgi() File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/workers/base.py", line 135, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python2.7/dist-packages/gunicorn-19.7.1-py2.7.egg/gunicorn/util.py", line 352, in import_app __import__(module) ImportError: Import by filename is not supported. The code works, I can start the dev server in Django, no errors. Gunicorn self seems to be working as well, it responds in the command line. I have no other project to test it, but …