I am trying to run a command while deploying my Django code to Heroku. I want to accept any question it might get in terminal. I tried to add following to the procfile, but it didn't work. release: python manage.py …
I have to override the blocks like branding,site_title, and index title to a custom template. But the user tools are not displaying. How I get. How I want. <a href="https://i.stack.imgur.com/bMqYX.png" …
My Form : date = forms.DateField(widget=forms.DateInput(attrs={'class': 'form-control'})) My HTML : <label class="form-label">Date</label> {{ form.date }} <div class="invalid-feedback"> Enter Date </div> Also I don't want to add type "date" in my forms. Issue picture : enter …
I have seen lots of questions and answers on this topic, but the solution seems to evade me. common/urls.py path('use-selected/<str:app_base>/<str:board_number>/', views.UseSelectedItem.as_view(), name='use-selected'), If I enter the the following code in my template, it works correctly <a id="use-selected" href="{% url …
I need to create a Paginator object for function based view. When I send a request to googleapi I receive json with totalItems and items keys. GoogleApi paginates request to 10 items. Let's say the totalItems is 800 so I …
First time asking question will try and make it clear what I'm trying to do. I have 2 models called Configuration and Results. class Configuration(models.Model): title = models.CharField(max_length=50, default="") houseType = models.CharField(max_length=50) numberOfHouses = models.CharField(max_length=50) maxAmpere = models.CharField(max_length=50) date = …
I want to create a timer in such a way that when the time is set in the admin model, the timer will be activated. Thank you if anyone knows. enter image description here
Не запускается Docker когда использую entrypoint.sh Выдает ошибку ERROR: for debt_web_1 Cannot start service web: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "usr/src/app/entrypoint.sh": stat usr/src/app/entrypoint.sh: no such file or directory: unknown ERROR: for web Cannot start …
I am trying to override the basic structure of a Django admin page using the below code: {% extends "admin/base_site.html" %} But the problem is, using this I only get the branding of the site, everything else like the …
Settings.py import os import dj_database_url ... DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': os.environ.get('DB_NAME'), 'USER': os.environ.get('DB_USERNAME'), 'PASSWORD': os.environ.get('DB_PASSWORD'), 'HOST': os.environ.get('DB_HOST'), 'PORT': 5432 } DATABASES['default'] = dj_database_url.config(os.environ.get('DATABASE_URL'),conn_max_age=600) I have a environment variable in my machine postgres://<user>:<password>@<host>:5432/cust_manage this …
In django user table password are encrypted automatically with a secure algorithm (pbkdf2_sha256) with salt and iterations. But what I don't understand is why the django password field shows the algorithm, iterations and salt in this format: <algorithm>$<iterations>$<salt>$<hash> I thought …
When I was adding a template from the internet to my login.html code I encountered a problem. When I try to login it did not work. Even after I added CSRF tokens and login form control code. It has a …
I would like to display the different dates for each course. A course can also have several dates. Unfortunately I can't find a solution. Models: class Course(models.Model): course_number = models.CharField(max_length=24, blank=True) course_location = models.ForeignKey(Course_location, on_delete=models.CASCADE) course_dates = models.ManyToManyField('Course_dates', through="Course_Course_dates") def …
Есть вопрос, в каких случаях используют контроллеры-функции, а в каких контроллеры-классов в django?
I am trying to save strings, floats and an image via a POST request made to a Django Rest Framework backend: # My view: class CreatePost(APIView): # tried with and without parser: # parser_classes = [FormParser, MultiPartParser] def …
Django is centered towards allow access to all the majority of the time, and restricting acces on the exception. I am making a site whereby I would like access restricted the most of the time, and the rare case is …
I've implemented graphql_ws to subscribe to updates from a Notification model that uses multiple GenericForeignKeys. My setup works well, except when I try to query information from those foreign objects. I then get the following error: graphql.error.located_error.GraphQLLocatedError: …
I have these two models: order and route. The route has a oneToMany relation with Order as you can see: class Order(models.Model): customer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='customer') retailer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='retailer') date_publish = models.DateField(default=datetime.date.today) date_available = models.DateField() weight = …
I have a Django application where I am using AJAX to do a post when submitting a form. My issue is what do I set the URL to in my JavaScript? JavaScript snippet: $.ajax({ url: "search/do_post/", // the endpoint …
In my case, the user gives a word in the front-end and in the back-end, i will call some function that i wrote and at the end i will build a .PDF file in the /media/reports directory. how i can …
I am trying to search with Elasticsearch using django_elasticsearch_dsl and 'django_elasticsearch_dsl_drf',, but I get RequestError(400, 'search_phase_execution_exception', 'failed to create query: For input string: "MM"'). I am able to search if my input is an integer or a float , but …
I have created a calendar with drf and react js which has all calendar features including events. Now, I'm trying to see my calendars and events on mobile calendar apps like Samsung or iphone calendar. I use google to authenticate …
I keep getting the 'TypeError' below when running a Django project in the virtual environment. What could be the problem? Thanks in advance! File "D:\Studio\Python\REST\elections\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 190, in close if not self.is_in_memory_db(): File "D:\Studio\Python\REST\elections\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 287, in is_in_memory_db return …
I'm trying to use multi language for my website by default its language is english , but i 've to add arabic and kurdish(arabic character) to the website ,i want to get input from the user to translate the website …
I have a django website that shows data which is seperated in 3 differents databases corresponding to different servers. I have a dropdown list on my website that allow to choose the desired server. What i would like …
I am writing an api for Auth. and I have 2 user types ( Donors , Charity ) when they did registration my data is changing. So that I need to update my fields according to the data. Here is …
I am trying to deploy a Django project on Heroku but I am getting the following error. 2021-08-07T10:05:35.789899+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=betabrains.herokuapp.com request_id=2e0f8a7e-ce6f-492b-88d9-81b89a3d7ec0 fwd="223.187.110.102" dyno= connect= service= status=503 bytes= protocol=https 2021-08-07T10:05:36.294818+00:00 heroku[router]: at=error code=H10 desc="App crashed" …
Right now i am successfully able to return every article without issue. But what i want to do is this: I want to return the articles,only followed by the current authenticated user. How can i do it? models.py class User(AbstractUser,PermissionsMixin): …
Hi everyone I have a doubt with the use of forms and models. I have to create a code that creates records in multiple tables and I don't know how to do it. my goal is to create a page …
I'm trying to get my Django project up and running but keep getting the error below when I run the code in the virtual environment. What could be the problem? Thanks! Traceback (most recent call last): File "D:\Studio\Python\REST\elections\manage.py", line …
I can't figure out how to connect two models (product and images) in views and output images in html. At the moment, several images are loaded for a specific project (for example, photos of a 3D model) all this through …
This is my views.py: class ChoicesViewSet(viewsets.ModelViewSet): queryset = SingleChoice.objects.all() serializer_class = SingleChoiceSerializer ... class AssessmentTakersViewSet(viewsets.ModelViewSet): queryset = AssessmentTaker.objects.all() serializer_class = AssessmentTakersSerializer ... @api_view(['POST']) @parser_classes((JSONParser,)) def studio_create_view(request, format=None): """" A view that accept POST request with JSON content and in turn …
I'm trying to do something on the value of a ModelForm in Django before saving that on the database. that "something" is changing the value of the DateTime field... I want to take Jalali DateTime from the user in the …
When I close a tab or browser and then I run the application again opening the browser again, the previous session remains active. I tried SESSION_EXPIRE_AT_BROWSER_CLOSE = True in settings.py file in the project directory as per the Django documentation. …
I would like to create a bidirectional one-to-many and many-to-one relationship in django like: class User(models.Model): device = dont_know_what_to_write() class Device(models.Model): user = models.ForeignKey( User, on_delete = models.CASCADE ) What should I do?
I have a django project, this is the installed apps entry in settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'crawler', ] when I run python manage.py migrate everything seems to be fine. But when I try …
I'm learning Django and I would like to know if there's a way to trigger intellisense within an html django template file to get a parameter declared in a python class from another file under the same app, I'm trying …
I have the following model class CoinsQuotes(models.Model): coinQuotesID = models.AutoField(primary_key=True) coinID = models.ForeignKey(Coins, on_delete=models.CASCADE) coinCurrency= models.CharField(max_length=10) coinPrice = models.DecimalField(decimal_places=8, max_digits=40) coinVolume24h = models.DecimalField(decimal_places=2, max_digits=30) coinPercentageChange1h = models.DecimalField(decimal_places=2, max_digits=20) coinPercentageChange24h = models.DecimalField(decimal_places=2, max_digits=20) coinPercentageChange7D = models.DecimalField(decimal_places=2, max_digits=20) coinPercentageChange30D = models.DecimalField(decimal_places=2, max_digits=20) …
Just started Django last month. I needed help running concurrency tests in Django, so what I've done is tried to write code that will prevent issues that arise due to lack of concurrency but what I don't know is how …
I want to use Arabic letters in my addresses, there is no problem in local mode, but it causes an error on the server. models.py class Product(models.Model): title = models.CharField(max_length=40, verbose_name='عنوان محصول') slug = models.SlugField(max_length=100,unique=True,allow_unicode=True, verbose_name='آدرس') urls.py urlpatterns = …