Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to call django forms inlineformset into django templates
i am new to django and learning some from stackoverflow. Now i am creating a website for post with images and title. I found ways to connect my two models (images and post) at https://stackoverflow.com/a/62158885/13403211. it is working fine when i add post from admin. But i want to know how can i add those inlineformset fields into my template for user to fill in.Does anyone knows?? Here is the code i found. I copy the same code in my app to try. models.py class Item(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="items") name = models.CharField(max_length=100) class ItemImage(models.Model): item = models.ForeignKey(Item, on_delete=models.CASCADE) img = models.ImageField(default="store/default_noitem.jpg", upload_to=get_image_dir) forms.py from django import forms from django.forms.models import inlineformset_factory from .models import Item, ItemImage class ItemImageForm(forms.ModelForm): class Meta: model = ItemImage exclude = () class ItemForm(forms.ModelForm): class Meta: model = Item fields = ["name",] ItemImageFormSet = inlineformset_factory( Item, ItemImage, form=ItemImageForm, fields=['img'], extra=3, can_delete=True # <- place where you can enter the nr of img ) views.py class ItemCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView): template_name = "items/add_item_form.html" success_message = 'Item successfully added!' form_class = ItemForm def get_context_data(self, **kwargs): data = super(ItemCreateView, self).get_context_data(**kwargs) data['form_images'] = ItemImageFormSet() if self.request.POST: data['form_images'] = ItemImageFormSet(self.request.POST, self.request.FILES) else: data['form_images'] = ItemImageFormSet() return data def form_valid(self, form): … -
'+add' button doesn't work properly when django-ajax-select is used
In short: django-ajax-selects works fine with filtering existing items, but gives JS error by adding new item. Details. Using Django 3.1. At Admin site one needs to create object of model Choice with ForeignField to model Question. Django-ajax-selects (DAS) is used to populate the field (dynamic filtering). By typing letters DAS handles the queryset and outputs the list of relevant questions. One can choose a question from the list and save new Choice. All this works fine. If no proper questions by typing are found then one can click +add button and add new question in popup window with form. After clicking 'Save' according to DAS docs: new question must be saved into the database; popup window must be closed; the edited field must be populated with new question . Screenshot with popup window The problem is that Django stops at step2: new question is created, the popup window is getting blank and doesn't close with "Popup closing ..." in the head. There is an JS error in the window: Uncaught TypeError: window.windowname_to_id is not a function at window.dismissAddRelatedObjectPopup (:8000/static/ajax_select/js/ajax_select.js:194) at popup_response.js:13 The HTML-code of the blank page is <!DOCTYPE html> <html> <head><title>Popup closing…</title></head> <body> <script id="django-admin-popup-response-constants" src="/static/admin/js/popup_response.js" data-popup-response="{&quot;value&quot;: &quot;6&quot;, … -
After deleting my database and trying to apply a new migrations i get this errors that say django.db.migrations.exceptions.NodeNotFoundError
Am trying to apply a migration to a new database but I keep getting this error, I have deleted all migration files in my old database and also files in the apps. when I tried applying migrations to a new database or running python manage.py runserver then I get this error..? I wonder what might be the problem. am using Django 3.1.1 E:\All django project\Real-Estate-Django-Web-App-master>manage.py migrate Traceback (most recent call last): File "E:\All django project\Real-Estate-Django-Web-App-master\manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python38\lib\site-packages\django\core\management\base.py", line 371, in execute output = self.handle(*args, **options) File "C:\Python38\lib\site-packages\django\core\management\base.py", line 85, in wrapped res = handle_func(*args, **kwargs) File "C:\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 92, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "C:\Python38\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__ self.build_graph() File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 255, in build_graph self.graph.validate_consistency() File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in validate_consistency [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in <listcomp> [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 58, in raise_error raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_user_following dependencies reference nonexistent parent … -
Template tag outputs nothing
Why is template_tags not displaying content? models.py @register_snippet class RegisterPageText2 (models.Model): title = models.CharField (max_length = 255) text = RichTextField () def __str __ (self): return self.title wtpages_tags.py @ register.inclusion_tag ('form.html', takes_context = True) def texts (context): print (RegisterPageText2.objects.all ()) return { 'texts': RegisterPageText2.objects.all (), 'request': context ['request'], } form.html <div class = "form-order"> <div class = "container"> <h1> Invoice for OzonePRO </h1> <a onclick="closeForm()"> <img src = "/ static_files / images / close-gray.png"> </a> {% for text in texts%} <p> {{text.text}} </p> {% endfor%} </div> </div> {% for text in texts%} <p> {{text.text}} </p> {% endfor%} outputs nothing -
Render fields conditionally with Django-Filters
I'm working on my Django SAAS app in which I want to allow the user to have some custom settings, like disable or enable certain filters. For that I'm using django-user-setttings combined with django-filters and simple forms with boolean fields: class PropertyFilterSetting(forms.Form): filter_by_loans = forms.BooleanField(required=False) filter_by_tenants = forms.BooleanField(required=False) The issue is that when trying to apply those settings, I keep running into serious spaghetti code: views.py class PropertyListView(LoginRequiredMixin, FilterView): template_name = 'app/property_list.html' context_object_name = 'properties' def get_filterset_class(self): print(get_user_setting('filter_by_tenants', request=self.request)) return PropertyFilterWithoutTenant if not get_user_setting('filter_by_tenants', request=self.request)['value'] else PropertyFilter filter.py class PropertyFilter(django_filter.FilterSet): ... class PropertyFilterWithoutTenant(PropertyFilter): ... and I'd have to do the same thing with the rest of the features. Is there any better way to implement this? -
How to integrate AngularJs with Django
I have little/no knowdlege in AngularJs, i want to create a very simple SPA with django as backend and AngularJs as frontend. User will be able to Register, Login & logout all taking place on the same page when a user logs in they will see a message"Welcome (user email)". This is very easy to do in a normal django web app as we don't even need to create the whole authentication system. But i want to learn how to do this with AngularJS as my employer wants me to do. I have read the basics of AngularJs and it looked well explained (it made sense) but how to integrate it with django. I tried searching on the internet but there is nothing out there, the tutorials that are there are more then 7 years old. -
Why is gunicorn displaying so many processes?
I have a simple web app built with Django & running with Gunicorn with Nginx. When I open HTOP, I see there are so many processes & threads spawn -- for a single tutorial app that just displays a login form. See screenshot of HTOP below: Why are there so many of them open for such a simple app? Thanks -
Executing django server as a subpackage
I am attempting to run a Django server as part of a project which, so far, has another package. If only for learning purposes, I'd like to keep it that way for the moment instead of merging both the core and web packages. I have looked at similar questions, but have not found a solution to my specific problem The tree listed below is the result of running the following command in the root project folder: django-admin startproject web . ├── __init__.py ├── core │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-38.pyc │ ├── server.py │ └── task_manager │ ├── __init__.py │ ├── __pycache__ │ └── main.py ├── test ├── venv │ ├... │ └── pyvenv.cfg └── web ├── __init__.py ├── __pycache__ │ ... ├── db.sqlite3 ├── manage.py └── web ├── __init__.py ├── __pycache__ ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py As I want the Django server to be able to access the outer package, my understanding is that I have to cd into the base project directory, and run the web server as such: python -m web.manage runserver Since by default the files created by the django-admin createproject contain absolute package references, I changed the "web.XYZ" … -
collectstatic whitenoise can't see my existing file on deployment to heroku
I've been workingon my app making multiple pushes to deploy on heroku and everything was fine but when I added settings for my django app to use cloudinary to store uploaded files in production whitenoise acted up failing to see files that are existent in my project , I have not made any changes to my static files and my previous pushes to heroku were all okay but now once the collectstatic part of the deploy starts whitenoise presents an issue of not seeing my files yet their paths are still okay and nothing has been changed in static files Im not sure if its the cloudinary settings that are causing this settings.py ... INSTALLED_APPS = [ # my apps 'user.apps.UserConfig', 'store.apps.StoreConfig', 'pages.apps.PagesConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'whitenoise.runserver_nostatic', 'cloudinary_storage', 'django.contrib.staticfiles', 'django.contrib.sites', # 3rd party apps 'crispy_forms', 'allauth', 'allauth.account', 'allauth.socialaccount', 'cloudinary', #'djangorave', #providors 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.google', ] ... MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] .... STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] STATIC_ROOT = os.path.join(BASE_DIR, 'static_root') STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' CLOUDINARY_STORAGE = { 'CLOUD_NAME': 'YOUR_CLOUD_NAME', 'API_KEY': 'YOUR_API_KEY', 'API_SECRET': 'YOUR_API_SECRET', } DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage' project file structure showing file in question exists error on deployment to heroku -
django getting perticular post from models in view.py class
how to get a photo, video, and other objects related to a particular post from PostImage, PostVideo, PostAudio.... class in views.py? It's returning all the photos, videos of PostImage, PostVideo.... models in the models.py to the display template. here are the models.py and views.py what to change in views.py or models.py so that it returns only the particular image, video from PostImage, PostVideo, PostAudio..... classes in models.py models.py from django.urls import reverse from django.template.defaultfilters import slugify from django.contrib.auth.models import User from django.contrib.contenttypes.fields import GenericRelation from django_resized import ResizedImageField from django.shortcuts import render from django.http import HttpResponseRedirect from comment.models import Comment class Post(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE, default=None) email = models.EmailField(max_length=254, blank=False) date = models.DateTimeField(auto_now_add=True) editdate = models.DateTimeField(auto_now=True) slug = models.SlugField(unique=True) title = models.CharField(max_length=150) body = models.TextField() image = ResizedImageField(size=[480, 360], upload_to='blog/images', blank=True) audio = models.FileField(blank=True) video = models.FileField(blank=True) file = models.FileField(blank=True) YoutubeUrl = models.CharField(blank=True, max_length=200) ExternalUrl = models.CharField(blank=True, max_length=200) # comment app comments = GenericRelation(Comment) class Meta: ordering = ['-editdate', '-date'] def get_absolute_url(self): return reverse('post:postdetail', kwargs={'slug': self.slug}) def __str__(self): return f"By {self.author}: {self.title[:25]}" def save(self, *args, **kwargs): if not self.id: # Newly created object, so set slug _title = self.title if len(_title) > 45: _title = _title[:45] unique_slug = self.slug … -
Django: Change a DB record of a model extending an existing model by 1-1-relation
I am extending the default User model with a custom Profile model. They have a 1-to-1 relation (OneToOneField). The Profile stores custom settings of its user. class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) allow_export = models.BooleanField(default=False) language = models.CharField(max_length=8, default='en') theme = models.CharField(max_length=32, default='light') I created a JS function which calls a Python API. The Python API should change the theme field of the online user (the page can just be reached when the user is logged in.). So this is the API call. Please not that the function request is a simple post/get request. The only important thing I do here is to send a JSON object with {theme: theme}, for instance {theme: 'dark'}. The request works well. from django.contrib.auth.models import User function changeTheme(theme) { let url = 'api/change-theme'; let data = { theme: theme }; let onSuccess = function (data) { console.log(data); } let onServerError = function () { console.log(data); } let onError = function () { console.log(data); } request('POST', url, data, onSuccess, onServerError, onError); } Now the issue: There is the python function api_change_theme. This function should change the theme of the user`s profile. def api_change_theme(request): # Get post data post = json.loads(request.body) # Get theme name theme … -
Search certain value in comments of reddit post
What is the best way to search text in reddit comments? I saw the "body" objects were nested quite deep in the json and it feels already wrong to use this code comment['data']['body']. Additionally, I get an empty array back so it doesn't find anything. Is there any cleaner/efficient way to loop over all the comments? https://www.reddit.com/r/apexlegends/comments/j3qiw4/heirloom_sets_should_include_a_unique_finisher/.json url = "https://www.reddit.com/r/apexlegends/comments/j3qiw4/heirloom_sets_should_include_a_unique_finisher/.json" if 'comments' in url: comments_json = performRequest(url) for comment in comments_json: if "body" in comment['data'].keys(): foundText = searchText(comment['data']['body']) for text in foundText: tickers.append(text) def performRequest(text): url = text request = requests.get(url, headers = {'User-agent': 'your bot 0.1'}) json_response = request.json() return json_response def searchText(text): return re.findall(r'[0-9]€(\w+)', text) -
change context after the response in sent in django
I have a django view and I'm expecting some of the data in the context to change a few times a second. Can I load a new context into the template after the response is sent without sending a new request? Thanks. the view def debug(request): return render(request, 'all/debug.html', context={"x": x, "y": y}) the template <div class="container"> <canvas id="data"></canvas> <div class="graphing"> <select class="graph-select"></select> <canvas id="graph" width="500"></canvas> </div> </div> <script> let y = "{{ y }}"; let x = "{{ x }}" Chart.defaults.global.animation.duration = 0; var ctx = document.getElementById('graph').getContext('2d'); var chart = new Chart(ctx, { // The type of chart we want to create type: 'line', // The data for our dataset data: { labels: x.split` `.map(n => +n), datasets: [{ label: 'My First dataset', backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', data: y.split` `.map(n => +n) }] }, // Configuration options go here options: { responsive: false, } }); </script> What I want is to dynamically change the x and y data without sending a new request -
how to filter chained dependent select box in django inline formset for every new form
I am developing Django web apllication for Electronics departmental store with full F.A.S. I have two mysql databases for it, 1st is 'product_mast' and 2nd is product_tran. i want to create 'Sales invoice' with one to many relationship in one page. for that i have used two related tables in 2nd "Tran" database, (1)sale_mast and (2)sale_tran. i have created inline-formset template with master and tran form, in which master form data goes to 'master' Table and multiple formset forms data goes to 'Tran' table. in these forms I have used 4 drop down select box,(for that data comes from 1st product_mast database) one from 'supplier' table, 2nd from 'Brand' table, 3rd from 'Items' table and 4th from 'Product' table. all are chained dependent. what i want to do, when i select 'supplier', 'brand' should be filter, 'item' should filter depend on 'brand', 'Product' should depend on 'Item', and finally when i select 'Product', product related price and other fields should be filled in Inputbox automatically. now problem is that all this works fine for first form in formset, but when i add new 2nd form and select all this select box, 1st form data get blank and filled with 2nd … -
Django & Django REST Framework - Adding @decorator_from_middleware(MyMiddleware) to API class based view
I'm wondering if there is a simple way to utilise the @decorator_from_middleware from Django decorators with a class based Dango REST Framework view on a per action basis: e.g., something like this: @decorator_from_middleware(DatasetViewsMiddleware) def retrieve(self, request, uuid=None, *args, **kwargs): ... I can't see anything in the Django REST Framework documents that allows this to be achieved. I assume it may have to be applied as some sort of class Mixin? -
pagination in function based view shows all objects
I have function based view and my pagination won't work properly. I see all objects in a single page, which is a problem, but page numbers are displayed correctly, which is a good thing. my views.py looks like this: def myview(request): qs = A.objects.prefetch_related(Prefecth('something', something, something)) paginator = Paginator(qs, 200) page = request.GET.get('page') page_obj = paginator.get_page(page) context = {'something': something, 'page_obj': page_obj} return render(request, 'mytemplate.html', context) Below is mytemplate.html snippet. I literally used this example from django docs <div class="pagination"> <span class="step-links"> {% if page_obj.has_previous %} <a href="?page=1">&laquo; first</a> <a href="?page={{ page_obj.previous_page_number }}">previous</a> {% endif %} <span class="current"> Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} </span> {% if page_obj.has_next %} <a href="?page={{ page_obj.next_page_number }}">next</a> <a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a> {% endif %} </span> </div> I hope someone can shed some light on it. Thanks in advance. -
Issued with uploading large file in Nginx , resulting in 502 bad gateway error
I am using Nginx, gunicorn and django framework for running my web application , here i am facing issue with file upload which will be stored in db ,the max file size i can upload is 1mb which is approximate ( 5000 rows) , but as i upload more than 1 mb it is showing 502 bad gateway error , my nginx confi file is : code : """ server { listen 80; server_name xxx xxx; client_max_body_size 100M; error_log /var/log/nginx/error.log debug; keepalive_timeout 100; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/ubuntu/mainframe;} location /{ include proxy_params; proxy_pass http://unix:/home/ubuntu/mainframe/mainframe.sock; } } """" my Gunicorn Configration: """ [Unit] Description=gunicorn daemon After=network.target [Service] User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/mainframe ExecStart=/home/ubuntu/.local/bin/gunicorn --access-logfile - --workers 3 --bin unix:/home/ubuntu/mainframe/mainframe.sock mainframe.wsgi:application [Install] WantedBy=multi-user.target """ any help will be appreciated 2 -
FormView not saving data in Django
I am trying to allow users to save details of a workout for a specific exercise through submitting a form. My ExerciseDetailView displays the form how I'd like it to: class ExerciseDetailView(DetailView): model = Exercise template_name = 'workouts/types.html' def get_context_data(self, **kwargs): context = super(ExerciseDetailView, self).get_context_data(**kwargs) context['form'] = WorkoutModelForm return context But my problem is with saving the inputted data in the database. I have tried making both a FormView and a CreateView but am clearly missing something: class ExerciseFormView(FormView): form_class = WorkoutModelForm success_url = 'workouts:exercise_detail' def form_valid(self, form): form.save() return super(ExerciseFormView, self).form_valid(form) Here is my referenced WorkoutModelForm: class WorkoutModelForm(forms.ModelForm): class Meta: model = Workout fields = ['weight', 'reps'] My template: <form action="{% url 'workouts:workout' exercise.id %}" method="post"> {% csrf_token %} {{ form }} <button type="submit">Save</button> </form> Urls: path('exercise/<int:pk>/detail/', ExerciseDetailView.as_view(), name='exercise_detail'), path('exercise/<int:pk>/detail/', ExerciseFormView.as_view(), name='workout'), And for context here is my Workout model which contains a get_absolute_url method: class Workout(models.Model): weight = models.FloatField(default=0) reps = models.PositiveIntegerField(default=0) created = models.DateField(auto_now_add=True) updated = models.DateField(auto_now=True) exercise = models.ForeignKey(Exercise, on_delete=models.CASCADE, default=None) def get_absolute_url(self): return reverse('exercise_detail', args=[str(self.pk)]) I am not receiving any errors, but when I submit the form my url remains the same, as I hoped, however the page just appears blank and the objects are … -
How to download an updated file by admin in Django
what i am trying to do is: Admin uploads a PDF file from admin panel. (1) It needs to go to the specified template. (2) And it should be downloaded by pressing download button in the template. So here are codes: (1) class Reports(models.Model): name = models.CharField(max_length=100, null=False, blank=False, verbose_name="File Name") report = models.FileField() (2) <tr> <td>"File Name must be showed in here"</td> <td class="text-center">PDF</td> <td class="text-center lang-tr-src"><a href="What way should i give here?" target="_blank"><i class="fas fa-file-download"></i></a></td> <td class="text-center lang-en-src"><a href="" target="_blank"><i class="fas fa-file-download"></i></a></td> </tr> In the website there will be one report for every month. I want to list them in the template and make them downloadable. Should i write a view for that(if yes how it should be?) or what should i do? -
python static variable value is switching between old value and new value after frequently request in production-environment
service.py class TestProduction: test_varible = None views.py @public def display_value(request): # calling API-2 return HttpResponse(json.dumps({"code": 1, "msg": str(TestProduction.test_varible )}), content_type="json") api.py @public def set_value(request): # calling API-1 value = request.POST['value'] TestProduction.test_varible = value return HttpResponse(json.dumps({"code": 1, "msg": str(TestProduction.test_varible )}), content_type="json") the above code is tested with the postman it working fine in the development-environment but in production-environment case1 first time assign a value in TestProduction.test_varible it returns a value which is right case2 again assign a new value to the same variable TestProduction.test_varible and frequently hit the API it switching the result some time old and new value Results API-1 assign 50 API-2 return 50 in every call API-1 assign 60 API-2 return sometimes 60 and sometimes 50 in every call -
Creating List APi for two models having many to one relationship
Here I have two models Ailines and Flight Details. The second model is many to one reln with Airlines model. When I create ListAPi view for Flight Details, the airline name doesnt appear on the apis, instead only id(pk) appears. Check the picture below, airlines only has number not airline name. class Airlines(models.Model): Airline_Name = models.CharField(max_length=200, unique= True) Email = models.EmailField(max_length=200, unique= True, help_text='example@gmail.com') Address = models.CharField(max_length=200) Phone_Number = PhoneField(help_text='Contact phone number') def __str__(self): return self.Airline_Name class FlightDetails(models.Model): Flight_Name = models.CharField(max_length=200) Aircraft_name = models.CharField(max_length=200) airlines = models.ForeignKey(Airlines, null=True, on_delete=models.CASCADE) Destination = models.CharField(max_length=200, verbose_name = "To") Destination_Code = models.CharField(max_length=200) Destination_Airport_name = models.CharField(max_length=200) Here we can see in airlines it says 1, instead of airlines name.How can we solve it?? -
Selenium script in django running with gunicorn server failed
I have a selenium script and the run on when a API call and the API built with django. Everything is working very well in my both local server and cloud But the problem is, when i run the app with gunicorn instead of python3 manage.py runserver It fires me too many error: and this is my gunicorn /etc/systemd/system/site.service code: [Unit] Description=gunicorn daemon After=network.target [Service] User=root Group=www-data WorkingDirectory=/var/www/workorder Environment="PATH=/var/www/workorder/env/bin" ExecStart=/var/www/workorder/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/var/www/workorder/site.sock -m 007 workorder.wsgi:application [Install] WantedBy=multi-user.target and i run this with Nginx reverse proxy and this is my chrome driver example code: options = webdriver.ChromeOptions() options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') driver = webdriver.Chrome(options=options) driver.get(url) As i said, my selenium script method in api view so when the endpoint call, then it run the selenium script. but it It fires me this error: and when i add the chromedirver link: driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options) and it gives me this error: I am not getting whats wrong with this. When run the server with python manage.py runserver, it works very well but when i run it in backround, it gives me error Even it gives me when i run it with gunicorn and nginx server. Can anyone please help … -
Running Django server from Jenkins pipeline in Docker container
I am trying to setup a Jenkins pipeline that deploys a Django project and runs the Django's development server in background. I would like to separate it into 3 steps, Build, Test, Run. Everything is fine except the last step, indeed, when I setup it like this: ... stage('Run') { steps{ dir('auto'){ sh 'pwd' sh '/usr/bin/python3.8 manage.py runserver 0.0.0.0:8000' } } } the server starts well, I can access to the project through http://127.0.0.1:8000 but the job is not ending. I have tried to bypass this issue to have the server running in background using nohup $: ... stage('Run') { steps{ dir('auto'){ sh 'pwd' sh 'nohup /usr/bin/python3.8 manage.py runserver 0.0.0.0:8000 $' } } } but the server is not reachable at http://127.0.0.1:8000 I am a Jenkins beginner and maybe this is not the right way to have a process running in background. -
DJANGO - Call a TKINTER program using a button
I made a program using python TKINTER, and now I need to run it in a Web application, so that everyone in the company can access it. That's when I found out that DJANGO does this kind of service! But I'm being beaten up here to call the TKINTER program when a button is pressed. Can anyone give me a light? Is it doable? I wanted something very simple, just a button on the web to run TKINTER .... -
Problem direction typing in ckeditor codesnippet
I have a problem with the code snippet plugin Both typing and output are cluttered The output of the print("Hello") code is: image image please help