Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Data that's been sent from client is not valid for my django-rest api
Here is what React client is using to send user sign-up data(to be stored in the database): fetch('http://127.0.0.1:8000/api/user', { 'method': 'POST', 'headers': { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrfToken, }, 'body': JSON.stringify(data), }) Here is the data that is being sent: username: ["palash"] contact: ["singhpalash0@example.com"] dob: ["2021-04-08"] password: ["password"] Here is the response I'm getting back from the server(along with a status code of 400) contact: ["Not a valid string."] dob: ["date has wrong format. Use one of these format instead: YYYY-MM-DD"] password: ["Not a valid string."] username: ["Not a valid string."] view.py @api_view(["GET", "POST"]) def user(request): if request.method == "POST": serializer = CreateUserSerializer(data=request.data) print(serializer.initial_data) if serializer.is_valid(): wantTo = serializer.data.get('wantTo') username = serializer.data.get('Username') password = serializer.data.get('Password') if wantTo == "signup": email = serializer.data.get('Email') dob = serializer.data.get('dob') user = User(username=username, contact=email, dob=dob, password=password) user.save() return Response({'detail': 'registered!'}) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) serializer.py class CreateUserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ("username", "contact", "dob", "password") model.py class User(AbstractUser): contact = models.CharField(unique=True, blank=False, max_length=64) dob = models.DateField(blank=False) date_joined = models.DateTimeField(auto_now_add=True) -
Reverse for 'article_detail' with arguments '('',)' not found. 1 pattern(s) tried: ['article/(?P<pk>[0-9]+)$']
I get frequent errors on different templates, I make a blog, and as soon as I clear my category_detail, then everything works, apparently there is an error in it category_detail.html {% extends 'base.html' %} {% block content %} {% if category_posts %} <h1>{{ cat }}</h1> <ul> {% for post in category_posts %} <l1><a href="{% url 'article_detail' post.pk %}">{{ post.title }}</a> {{ post.category }} | {{ post.author }} {% if user.is_authenticated %} |-<small><a href="{% url 'update_post' post.pk %}">Редакт..)</a></small> {% endif %} <br/>{{ post.body|slice:":50"|safe }} </l1> {% endfor %} </ul> {% else %} <h1>Извините страница не найдена</h1> {% endif %} {% endblock %} If I don't add the code and template for categories, everything works fine. enter code views.py class HomeView(ListView): model = Post template_name = 'home.html' ordering = ['-id'] def CategoryView(request, cats): category_posts = Post.objects.filter(category=cats), return render(request, 'category_detail.html', {'cats':cats.title(), 'category_posts':category_posts}) class ArticleDetailView(DetailView): model = Post template_name = 'post_detail.html' class AddPostView(CreateView): model = Post form_class = PostForm template_name= 'add_post.html' #fields = '__all__' class AddCategoryView(CreateView): model = Category template_name= 'add_category.html' fields = '__all__' class UpdatePostView(UpdateView): model = Post template_name = 'update_post.html' form_class = EditForm #fields = ['title', 'body'] class DeletePostView(DeleteView): model = Post template_name = 'delete_post.html' success_url = reverse_lazy('home') models.py from django.db import … -
I want change required's message in django rest framework
I want change required message to my custom message. my model -> class TeacherProfile(models.Model): address = models.CharField(max_length=100) subject = models.CharField(max_length=100) price = models.IntegerField() bio = models.TextField() tel_number = models.CharField(max_length=25,validators=[number_regex]) teacher = models.OneToOneField(User, on_delete=models.CASCADE) def __str__(self): return str(self.teacher) When I empty the empty form, it gives an default error "This field may not be blank.". i want change this message. class TeacherInfoSerializer(serializers.ModelSerializer): class Meta: model=TeacherProfile fields="__all__" extra_kwargs = { 'bio': {"error_messages": {"required": "My custom error"}}, 'address': {"error_messages": {"required": "My custom error"}}, } but nothing change -
How can I retrieve a single value from a queryset?
I am trying to retrieve the is_winning_bid value of a query set that returns: <QuerySet [{'id': 33, 'user_id_id': 3, 'listing_id_id': 33, 'bid_amount': Decimal('13.00'), 'bid_time': datetime.datetime(2021, 4, 9, 16, 15, 9, 120168, tzinfo=<UTC>), 'is_winning_bid': False}]> Views.py @login_required(login_url="/login") def listing(request, listing_id): listing = Listing.objects.get(pk=listing_id) bids = Bid.objects.filter(listing_id=listing_id) user_id = request.user # time_posted = Comment.time_posted comments = Comment.objects.filter(listing_id=listing_id, user_id=user_id).order_by("-time_posted") current_user = request.user return render(request, "auctions/listing.html", { "listing": listing, "watchlist": Watchlist.objects.filter(user_id=request.user).count(), "current_user": current_user, "comments": comments, "bids": bids.values() }) template extract: <!DOCTYPE html> <html lang="en"> <head> </head> <body> <div class="block my-3"> <div class="row my-1"> <div class="col-sm-2"> {{ bids }} </div> <div class="col-sm-4"> <strong>Number of bids:</strong> {{ listing.number_of_bids }}<br> <strong>Starting Bid:</strong> {{ listing.starting_bid }}<br> {% if listing.current_bid == 0 %} <strong>Current Bid:</strong> <span class="current_bid">No Bid Yet!</span><br> {% else %} <strong>Current Bid:</strong> <span class="current_bid">{{ listing.current_bid }}</span><br> {% endif %} </div> <div class="col-sm-5 text-center"> <form action="{% url 'auctions:bid' listing.id %}" method="post"> {% csrf_token %} <input type="number" name="bid_amount" id="bid_input" required> <button class="btn btn-primary" type="submit">Bid</button> <br> </form> <a href="{% url 'auctions:add_to_watchlist' listing.id %}" style="background-color: black" class="badge badge-secondary"> Add to Watchlist </a> <div class="col-sm-2"></div> </div> </div> </div> </body> </html> -
user not staying logged in after changes to user password and username
I have made a django view and form to update username and password and it does what it's meant to do, but I have trouble with the user staying logged in after the changes are done: Here's my view logic: class UserUpdateView(LoginRequiredMixin, UpdateView): model = User form_class = UserUpdateForm template_name = 'todo_list/userupdate.html' success_url = reverse_lazy("tasks") def get_object(self, queryset=None): return self.request.user def form_valid(self, form): user = form.save() if user is not None: login(self.request, user) return super(UserUpdateView, self).form_valid(form) As you can see the idea is for the user to be logged in after the changes are made, which doesn't happen. The user is automatically logged out and I don't know why. Any help is much appreciated. -
django signals is not updating model
I am trying to send an amount from a user to another user, i can't figure out what i am doing wrong. Also, i just figured i didn't take into consideration the user's balance which makes the entire thing in my signals wrong. It seems i don't understand signals, i've gone through the documentation but i still can't figure it out. signals.py @receiver([post_save,post_delete], sender=wallet) def post_save_sendcoins(sender, instance, **kwargs): wallet = instance.wallet sca=instance.sender waller_receiver=instance.receiver total = wallet.objects.filter(wallet=waller_receiver).aggregate(Sum('amount'))['amount__sum'] wallet.balance = total wallet.save(update_fields=['balance']) sca.save() waller_receiver.save() models.py class wallet(models.Model): owner=models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='owner', null=True) account_number = models.IntegerField() #deposit or withdrawal wallet balance = models.DecimalField(default=0.00,decimal_places=2,max_digits=15) virtualwallet = models.IntegerField(blank=True,null=True) is_active = models.BooleanField( _('active'), default=False, help_text=_( 'Designates whether this wallet should be treated as active. ' 'Unselect this instead of deleting accounts.' ), ) def __str__(self): return f"{self.virtualwallet}-{self.owner}" sendcoins model for sending an amount to a user's wallet class sendcoin(models.Model): receiver = models.ForeignKey(wallet, on_delete=models.CASCADE, null=True) wallet = models.ForeignKey('self', on_delete=models.CASCADE, related_name='walll', null=True) sender = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='xender', null=True) amount = models.DecimalField(max_digits=15,decimal_places=2) created_at=models.DateTimeField(auto_now_add=True) def __str__(self): return f"{self.sender}" -
upload/send file to django REST via post using angular
I see multiple threads here, and i cant fix it. I have a backend django-REST that use django-versatileimagefield to handle the image instead a imagefield. i test the backend using Postman and works fine. But when i send the request via angular POST I got the next error: "The submitted data was not a file. Check the encoding type on the form." In the Angular APP i create the file from a base64, then i generate a blob and finally i create the image and tried to upload this using multiple ways, the last way is the next: <button (click)="guardarCambios()" ....> guardarCambios(){ let base64 = this.croppedImage // this value get a base64 image from another part of my app let imageName = 'name.png' let imageBlob = new Blob([base64], {type: 'image/png'}); let imageFile = new File([imageBlob], imageName, { type: 'image/png' }) let me = this; let reader = new FileReader(); reader.readAsDataURL(imageFile); reader.onload = function () { console.log(reader.result); me.ImageBaseData=reader.result; okok() }; reader.onerror = function (error) { console.log('Error: ', error); }; let okok = () => { if(this.ImageBaseData != undefined){ this.form.get('image').setValue({ filename: imageFile.name, filetype: imageFile.type, value: this.ImageBaseData.toString().split(',')[1] }) const enviar = this.form.value; this.subirfile(enviar) } } } subirfile(enviar){ this.api.upImagen(item.id, enviar).subscribe( (item2:any) => { console.log(item2) … -
Access via URL instead IP address to local dockerized Django project
I got a small django project wich runs within a docker container and is locally only (no need to expose it to the whole internet, just my office), but since it's a coporate project I want to give the persons who use it the possibility to access it using an URL (maybe something like "projectName.corporateWhereIWork.org") instead host machine ip address:port. Being honest, I have already read and search about terms like "reverse-proxy", "companion", "ACME", "DNS" but these are concepts that are very difficult for me to understand and I don't know how to configure nginx properly. This is my nginx config file (see it's a very simple configuration): client_max_body_size 10M; upstream project { ip_hash; server project:8000; } server { location /static/ { autoindex on; alias /src/static/; } location /media/ { autoindex on; alias /src/media/; } location / { proxy_pass http://project/; } listen 8000; server_name localhost; } And my django image entry point: CMD ["sh", "-c", "python manage.py collectstatic --no-input; python manage.py migrate; gunicorn project.wsgi -b 0.0.0.0:8000"] Both containers expose to same port. -
Why my website is rendered correctly on some phones and on others not, using the same browser?
I am trying to build my first webiste and I encountered a big problem with the rendering on different devices. I used Django framework Here is my website, deployed on pythonanywhere. It is a basic one, for educational purposes. http://tudorilade.pythonanywhere.com/ When I try to access it from a Xiaomi phone, for instance on Chrome, I have rendering problems. My website does not want to apply the CSS to the page. I sent my website to different friends, and they opened it with Chrome: 1/3 of them had rendering problems. However, if I use other Browser, or I open it, using the default browser provided by facebook messenger, it looks just fine. I cannot understand why some can have an user-friendly navigation on my website, and others not. I think that it is a phone problem, and my media query does not find the width of the used device. NOTE: if I use inspect element on the browser and I try different sizes in the range of 280px - 726 px, it looks good. @media screen and (max-width:726px) { ...... all the responsive CSS code } And this I have on index page: <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> If somebody … -
Django Rest Framework: how to get the current superuser in serialize?
CreateApiView : class CreateEmployeeApiView(generics.CreateAPIView): # authentication_classes = [TokenAuthentication, SessionAuthentication, ] permission_classes = [IsAuthenticated] queryset = Employee.objects.all() serializer_class = CreateEmployeeApiSerializer def post(self, request, *args, **kwargs): return super(CreateEmployeeApiView, self).post(request, *args, **kwargs) and serializer : class CreateEmployeeApiSerializer(serializers.ModelSerializer): # user = serializers.HiddenField(default=serializers.CurrentUserDefault()) username = serializers.CharField(source='user.username', required=True) email = serializers.EmailField(source='user.email', required=True) password = serializers.CharField(source='user.password', style={'input_type': 'password', 'placeholder': 'Password'}, write_only=True, required=True) class Meta: model = Employee fields = ( 'username', 'email', 'password', 'is_delete', 'first_name', 'last_name', 'father_name', 'birth', 'avatar', 'status', ) def to_representation(self, instance): data = super(CreateEmployeeApiSerializer, self).to_representation(instance) status = instance.status data['status'] = Employee.USER_ROLE[status - 1][1] data['author'] = instance.author.username data['user'] = instance.user.username return data def create(self, validated_data): # Create new user print(validated_data) user = User.objects.create(username=validated_data['user']['username'], email=validated_data['user']['email']) user.set_password(validated_data['user']['password']) user.save() # Create employee # super_user = User.objects.filter(is_superuser=True) employee = Employee(user=user) employee.is_delete = validated_data['is_delete'] employee.first_name = validated_data['first_name'] employee.last_name = validated_data['last_name'] employee.first_name = validated_data['first_name'] employee.father_name = validated_data['father_name'] employee.birth = validated_data['birth'] employee.avatar = validated_data['avatar'] employee.status = validated_data['status'] employee.author = user employee.save() return employee I need a superuser, not a simple user. When employee is created, the employee.author field must be assigned by the logged in user (i.e. the current superuser). How should I do it? I hope you understood me correctly! -
How can exclude the item which is in db Django
I have two issue I just want to exclude the items which is in db, other item which is not in ordeerRequest table will be display, but after my query it show nothing In template when i select any category it just show the last category which i added. After select any category it should show the that category but it show last added category by default View.py def get(self, request, *args, **kwargs): status = self.request.GET.get('action') == 'accept' orderCheck = Order.objects.exclude( orderrequest__order_status__in=OrderRequest.objects.filter(order_status=status) ) args = {'orderCheck': orderCheck} return render(request, self.template_name, args) category show def get(self, request, *args, **kwargs): categories = Category.objects.all() categoryId = self.request.GET.get('SelectCategory') products = Product.objects.filter(category_id=categoryId) args = {'categories': categories, 'products': products, 'selectedCategory': categoryId} return render(request, self.template_name, args) Template <label> <select name="SelectCategory" > <option disabled="disabled" value="True" selected="{{ selectedCategory|yesno:"yeah, no, maybe" }}"> Select Category</option> {% for category in categories %} <option value="{{ category.id }}" selected="{% if category.id == selectedCategory %} {% endif %}"> {{ category.name }} </option> {% endfor %} </select> </label> -
Create, Update and Delete PostgreSQL integer range and keeping sequential order
I have the following tables: person and tiered_princing the column passenger in tiered_pricing must be ordered and sequential and must not overlap at any time. whether you are creating, updating, or deleting a price. person query: SELECT * FROM person; output: +----+--------+--+ | id | name | | +----+--------+--+ | 1 | adults | | +----+--------+--+ tiered_pricing query: SELECT * FROM tiered_pricing WHERE person_type_id=1; output: +----+--------------------+----------------------+----------------+ | pk | person_type_id(FK) | passengers(int4range) | price(decimal) | +----+--------------------+----------------------+----------------+ | 20 | 1 | [1, 1] | 70 | | 21 | 1 | [2, 4] | 60 | | 22 | 1 | [2, 4] | 40 | | 23 | 1 | [5, 10] | 30 | | 24 | 1 | [11, infinity] | 15 | +----+--------------------+----------------------+----------------+ If you created a new price with range [14, Infinity] after query the tiered_pricing table again you should be able to get the following SELECT * FROM tiered_pricing WHERE person_type_id=1; output: +----+--------------------+----------------------+----------------+ | pk | person_type_id(FK) | passenger(int4range) | price(decimal) | +----+--------------------+----------------------+----------------+ | 20 | 1 | [1, 1] | 70 | | 21 | 1 | [2, 4] | 60 | | 22 | 1 | [2, 4] | 40 | | … -
show data in django html table
I'm using django. I get data from a website and I can see it on the pandas and console as in the picture. How do I export this to the django html file? I'm actually passing the variable named "morning_star" but I can't show it. view.py from django.shortcuts import render from binance.client import Client import talib import pandas as pd def home_view(request): client = Client("12", "12") pd.set_option('display.max_rows', None) klines = client.get_klines(symbol="VETUSDT", interval="15m", limit=100) labels = ['T', 'open', 'high', 'low', 'close', 'V', 'CT', 'QV', 'N', 'TB', 'TQ', 'I'] df = pd.DataFrame(klines, columns=labels) candles_df = pd.DataFrame(klines, columns=['T', 'open', 'high', 'low', 'close', 'V', 'CT', 'QV', 'N', 'TB', 'TQ', 'I']) morning_star = talib.CDLMORNINGSTAR(candles_df['open'], candles_df['high'], candles_df['low'], candles_df['close'], penetration=0) engulfing = talib.CDLENGULFING(candles_df['open'], candles_df['high'], candles_df['low'], candles_df['close']) candles_df['morning_star'] = morning_star candles_df['engulfing'] = engulfing print(candles_df) context = { 'morning_star': morning_star } return render(request, 'home.html', context) Home.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> Home page {{ morning_star }} </body> </html> -
Connect a button to the edit change form Django
Am having a list of items, and it has a top button called ADD CUSTOMER PROFILE, so what I want to do is connect the same button at the top of the details page (Where I edit the data) in Django admin page after clicking on any of the items, below is the screenshots : Listing of items page : Details page : The button is located in the templates/admin/items/change_list.html : {% extends "admin/change_list.html" %} {% load i18n static admin_list %} {% block object-tools-items %} <div id="react-create-customer-profile"></div> {% endblock %} Then, the -
Django Query results get all values of same field
Is there a way to get all the values of a field form queryset without looping through and adding to array? I would do like below as simple example. I have a Report class with a visit FK field. results = Report.objects.all() visits = [] for res in results: visits.append(res.visit) But is there as a way to do something like: visits = results.visit (and have the same result i would from query loop above). -
Error while deploying django website on heroku .Exception Type: ProgrammingError at / Exception Value: relation "home_post" does not exist
I'm trying to deploy my django website on heroku. The code works fine in localhost but got the following error while deploying on heroku. Environment: Request Method: GET Request URL: https://santoshach.herokuapp.com/ Django Version: 3.2 Python Version: 3.9.4 Following is my settings.py ```Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'home', 'crispy_forms'] Installed Middleware: ('whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware') Following is the error I'm getting on the browser: Traceback (most recent call last): File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) The above exception (relation "home_post" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "home_post" WHERE "home_po... ^ ) was the direct cause of the following exception: File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/list.py", line 157, in get context = self.get_context_data() File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/list.py", line 119, in get_context_data paginator, page, queryset, is_paginated = self.paginate_queryset(queryset, page_size) File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/list.py", line 69, in paginate_queryset page = paginator.page(page_number) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/paginator.py", line 76, in page number = self.validate_number(number) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/paginator.py", line 54, in validate_number if … -
Is python multiprocessing( not multi-threading ) possible with Django running on Windows
For python multiprocessing, you have to enter a if __name__ == '__main__' check for reasons well explained elsewhere on stackoverflow when running on Windows. How do you overcome this limitation in Django where you are several layers away from the __main__ module. e.g. To run and execute my own command, the flow is: manage.py --> calls mycommand.py --> calls function in anothermodule.py( which carries out the actual work - this is where the code for multiprocessing should go). Neither mycommand.py or anothermodule.py will ever test true for if __name__ == '__main__; it will only be true in manage.py. So is multiprocessing simply not a viable option in Django? How do others get around this limitation? -
Django 3.0 URL parameters
I need to create a link in a template based on the request.GET.arg Lets say I enter the site which has url.com/?order=desc What I'm trying to do is passing arg to url. I need the same link to be generated. <a href="{% url 'index' order=request.get.order %}">Link</a> It raises up this error: Reverse for 'index' with keyword arguments '{'order': ''}' not found. 1 pattern(s) tried: ['$'] -
making multiple get_absolute_url from different tables work in one view
Hello i'm trying to get both get_absolute_url from different tables to work in one class based view but it seems to be getting only the first one. The error message is: Field 'Product_id' expected a number but got 'phones'. my views.py: class ProductListView(ListView): model= models.Product context_object_name = 'product_list' template_name = 'store/product_list.html' def get_context_data(self, **kwargs): context=super().get_context_data(**kwargs) context['cat'] = Category.objects.all() return context My urls.py(slug part is the one which is not working): from django.urls import path, re_path from store import views app_name = 'store' urlpatterns = [ re_path(r'^(?P<pk>[\w-]+)/$', views.ProdView.as_view(),name='prod'), path('signup', views.SignUpView.as_view(), name='signup'), path('<slug>/', views.CategoryList.as_view(), name='cat'), path('search', views.SearchListView.as_view(), name='search_results'), path('change_password', views.PassChange.as_view(), name='passchange'), path('reset_password', views.PassReset.as_view(), name='passreset'), path('logout', views.user_logout,name='logout'), path('user_login', views.user_login, name='user_login'), ] the html page is (important part is the first for loop): <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> </head> <body> <div class="jumbotron"> <form action="{% url 'store:search_results' %}" method="get"> <input name='q' type='text' placeholder="Search products.."> </form> {% for cate in cat %} <h3><li><a href="{{cat.get_absolute_url}}">{{cate.Category_name}}</a></li></h3> {% endfor %} <h1>These are the products</h1> <ol> {% for product in product_list %} <h2><li><a href="{{product.get_absolute_url}}">{{product.Product_name}} </a></li></h2> {% endfor %} </ol> {% if user.is_authenticated %} Hi ! <p><a href="{% url 'store:logout' %}">Log Out</a></p> <p><a href="{% url 'store:passchange' %}">change password</a></p> <p><a href="{% url 'store:passreset' %}">reset password</a></p> {% else %} … -
Serverless WSGI not working in pipelines (works locally)
I have the following steps configured in our bitbucket pipeline: # Configure Serverless - cp requirements.txt src/requirements.txt - serverless config credentials --provider aws --key ${AWS_KEY} --secret ${AWS_SECRET} - cd src - sls plugin install -n serverless-python-requirements - sls plugin install -n serverless-wsgi - sls plugin install -n serverless-dotenv-plugin # Perform the Deployment - sls deploy --stage ${LOCAL_SERVERLESS_STAGE} - sls deploy list functions # Prep the environment - sls wsgi manage --command "migrate" - sls wsgi manage --command "collectstatic --noinput" When the pipeline runs, the sls deploy works perfectly fine and the deployed function operates exactly as expected. The sls wsgi manage commands throw the following error, however: Serverless Error ---------------------------------------- Function "undefined" doesn't exist in this Service Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com Your Environment Information --------------------------- Operating System: linux Node Version: 11.13.0 Framework Version: 2.35.0 Plugin Version: 4.5.3 SDK Version: 4.2.2 Components Version: 3.8.2 I can run the sls wsgi manage commands locally (with same AWS keys) without issue. The issue only seems to happen in the pipeline. Thoughts? -
how can I connect my image processing application in my android application
I have image processing application written in python consists of CRNN model, and I want to take an image from my android application and send it to the image processing and receive back a response from it. what should I use to make it done. -
Django Python annotate ManyToMany Relationship with additional information
my problem is the following. I have two models in the database, which I link together using a ManyToMany relationship. For the admin page I currently use "admin.TabularInline" to bind different objects to one via the graphic. I still want to specify an order in the connections, preferably numbers which represent an order for processing. A bit more figuratively described I have the model "Survey" and the model "SurveyQuestion". So I connect many SurveyQuestions with the Survey. But I can't specify an order, because I don't have an additional field for it. It is not known before how many questions will be in a survey. Nor is it known which questions will be inserted. Usually they are built during the compilation of the survey and may be used later for another survey. I am grateful for every tip! -
Django 3 - Add Context to admin base.html
Django 3: I have a Django Project and i want to modeify the admin page. I can edit the base.html for the admin page. Now i want to pass some context from my models to the base.html. How can i do that? Any ideas? -
I'e just started learning Django and i got stuck while creating a virtrualenv for some project,What does this mean?
Evalyns-iMac:trydjango2 Evalyn$ virtualenv -p python3 usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe] [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download] [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h] dest virtualenv: error: the following arguments are required: dest SystemExit: 2 -
Django 2.2 + AttributeError: 'str' object has no attribute 'decode'
We have done Django Upgrade from 1.11 to 2.2 version, we have almost completed, but there is one issue is present, when we run migrations by using the command "python manage.py makemigrations" then we are getting following error. but when we follow the below link issue is resolved. Migrations error in django 2; AttributeError: 'str' object has no attribute 'decode' but, I just want to know is there any other way to resolve this issue ?, I am feeling like there will be library to update which is causing this issue ? kindly advise Error message is : (env4) user2@SK385 pro % python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle loader.check_consistent_history(connection) File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/db/migrations/loader.py", line 283, in check_consistent_history applied = recorder.applied_migrations() File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations if self.has_table(): File "/Users/user2/Desktop/env4/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 56, in has_table return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()) …