Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Problem with static file on vps (Django, gunicorn ,nginx)
My problem is when I request in a browser like 194.22.167.3 it can't find the static file. But if I write 194.22.167.3:8000 it finds the static file. This is my nginx default file from '/etc/nginx/sites-available/' server { listen 80; server_name 194.110.54.227; access_log /var/log/nginx/example.log; location ~ ^/(static)/ { root /home/ubuntu/KazArma/kazarm/static/; expires 30d; } location /{ proxy_pass http://127.0.0.1:8000; proxy_set_header Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } -
Django ForeignKey can't select
I have movies_movie and casts_cast tables. Each movie can have many cast. In model for movies i have the following: class Cast_movie(models.Model): movie = models.ForeignKey('movies.movie', on_delete = models.CASCADE, blank=True, null=True) cast = models.ForeignKey('casts.cast', on_delete = models.CASCADE, blank=True, null=True) def __str__(self): return self.name When i go to a movie page, i cannot select cast? I'd like to be able to search for a cast(not display all of them) and select, for the current movie page user is on. How do i solve? -
Inheritance Vs Composition: Angular State Management - Django Rest Framework
I am writing a frontend app uses data store "ngxs: a state management pattern library" in "angular" connected to backend "django rest framework". The store has common behavior for managing paginated data: Offset Limit pagination: which i use to manage data intended to be rendered as atable (example table of clients, payments, ..): fetch page form the server using query parameters (offset, limit) change page size using query parameters (limit) change the search terms using search query parameters (search) change the ordering using ordering query parameters (ordering) add custom filters, example: (age__exact>20) Cursor pagination: which i use to manage data intended to be rendered as an unordered (example chat messages) fetch next page form the server using query parameters (nextCursor) fetch previous page form the server using query parameters (previousCursor) change the search terms using search query parameters (search): example search for a chat message Assumptions: Features like pagination(next previous), search, are common for both pagination types. Both pagination types will be affected by CRUD operations (add/remove/update -> message, client). Entity is a generic type for objects fetch from server (Client, Chat messages, payment ..). My Appreoch: I started with OffsetLimitEntityStore and CursorEntityStore each of offset-limit and cursor pagination strategy. … -
Django UpdateView can edit user who created and user to whom record is assigned
Let's say I have model like class Record(models.Model): created = ...... assigned = ....... some_other_fields = ..... How should I modify test_func() in views to allow edit Record both to creator and user to whom the Record is assigned? I would like to enable functionality in frontend side, not in the django admin panel. I'm working with Class Based Views. Standard test_func in UpdateView looks like: def test_func(self): return self.request.user == self.object.created Thanks a lot! -
(DRF) Unable to pass in <int:id> to function via axios post request
I am trying to axios to send id=1 to the django url.py. frontend: const baseURL = 'http://localhost:8000/'; const axiosInstance = axios.create({ baseURL: baseURL, timeout: 5000, }); await axiosInstance.post(`api/public/favourites/1/`, { headers: { 'content-type': 'application/json', } }); url.py path('public/favourites/<int:id>/', add_favourites, name='add_favourites'), view.py @csrf_exempt def add_favourites(request, id): thread = get_object_or_404(Thread, id=id) if request.method == 'POST': if thread.liked.filter(username=request.user.username).exists(): thread.liked.remove(request.user.username) else: thread.liked.add(request.user.username) return Response(thread, status=status.HTTP_200_OK) However, I kept receiving error: ValueError: Field 'id' expected a number but got ''. I really can't find anything wrong in url.py & view.py, so I suspect there are mistakes in the axios request, I have tried deleting my whole database & removing all the migrations, still no luck. Anybody has an idea what is going on about the error? Much appreciated. -
Django CSRF verification failed in django 3.1, used to work in django 1.x
I'm resurrecting and old site which worked using django 1.x. I am running django 3.1.2 now. I converted to python 3 from 2.7. I have 3 forms that post to the site. They all work when running django server on the local machine. But when I test from another machine on my network they give CSFR cookie not sent the form: <form action="/blog/upload" method="POST" enctype="multipart/form-data"><ul><li><label for="id_title">Title:</label> <input type="text" name="title" maxlength="50" required id="id_title"></li> <li><label for="id_file">File:</label> <input type="file" name="file" required id="id_file"></li></ul><input type="hidden" name="csrfmiddlewaretoken" value="eYpdkogXUvof1IqJzgMvJcEGMBpXbvoNLTZNfEjz6aY7WebxbxsvId3nPmT7S4PF"> <input type="submit" value="Go" /> </form> The view: 219 def handle_uploaded_file(f, to_filename): 220 print("In handle_uploaded_file") 221 with open(f'uploads/{to_filename}', 'wb+') as destination: 222 for chunk in f.chunks(): 223 destination.write(chunk) 224 print(f"wrote {to_filename}") 225 226 227 def upload_file(request): 228 print("in upload_file") 229 if request.method == 'POST': 230 print("request.method == 'POST'") 231 form = UploadFileForm(request.POST, request.FILES) 232 if form.is_valid(): 233 print("form is valid") 234 print(request) 235 handle_uploaded_file(request.FILES['file'], request.POST['title']) 236 return HttpResponseRedirect('upload') 237 else: 238 print("in upload_file else clause") 239 form = UploadFileForm() 240 return render(request, 'blog_app/upload_form.html', {'form': form}) I suspect that there are new settings in settings.py but I haven't been able find an answer. -
Is it possible to manipulate image object's values in a Django template?
I have a UserImageForm in Django: class UserImageForm(forms.ModelForm): class Meta: model = UploadImage fields = ['image'] I likewise have a template, which looks like this: {% extends 'base.html' %} {% block content %} {% if user.is_authenticated %} <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form.as_p }} <button type="submit">Upload</button> </form> {% if img_obj %} <h3>Successfully uploaded: {{img_obj.caption}}</h3> <img src="{{ img_obj.image.url}}" alt="connect" style="max-height:300px"> {% endif %} {% endif %} {% endblock content %} What is bothering me is if it is possible to attribute a value to img_obj.caption. In case this is possible, how can it be achieved? I tried it with the „set“ and „define“ keywords but to no avail. -
Cannot launch my Django project with Gunicorn inside Docker
I'm new to Docker. Visual Studio Code has an extension named Remote - Containers and I use it to dockerize a Django project. For the first step the extension creates a Dockerfile: # For more information, please refer to https://aka.ms/vscode-docker-python FROM python:3.10.5 EXPOSE 8000 # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app COPY . /app # Creates a non-root user with an explicit UID and adds permission to access the /app folder # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app USER appuser # During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug # File wsgi.py was not found. Please enter the Python path to wsgi file. CMD ["gunicorn", "--bind", "0.0.0.0:8000", "project.wsgi"] Then it adds Development Container Configuration file: // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/docker-existing-dockerfile { "name": "django-4.0.5", // Sets the run context to one level up instead of the .devcontainer folder. "context": … -
Django: Celery only works on local but not production using the cookiecutter project
I set up a project using the django cookie cutter and deployed it with the docker option https://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html Celery perfectly works on my local machine and gives me a lot of logging information but on production i get nothing about Celery or redis at all. (I'm using Redis as the worker). Since i'm new to celery and couldn't find anything inside the cookiecutter or the celery doc i thought one of you might know more. Is there anything i have to do differently when using Celery with the django cookiecutter? Or is there a way to debug this? So far i tried the internal caprover logs and the docker logs. This is my dockerfile for production: ARG PYTHON_VERSION=3.9-slim-bullseye # define an alias for the specfic python version used in this file. FROM python:${PYTHON_VERSION} as python # Python build stage FROM python as python-build-stage ARG BUILD_ENVIRONMENT=production # Install apt packages RUN apt-get update && apt-get install --no-install-recommends -y \ # dependencies for building Python packages build-essential \ # psycopg2 dependencies libpq-dev # Requirements are installed here to ensure they will be cached. COPY ./requirements . # Create Python Dependency and Sub-Dependency Wheels. RUN pip wheel --wheel-dir /usr/src/app/wheels \ -r ${BUILD_ENVIRONMENT}.txt # … -
django.core.exceptions.FieldError: Cannot resolve keyword into field
#################################### I have following code : ##################################### class AppExpandAbstract(BaseModel): class Meta: abstract = True foreign_key = App target = models.ForeignKey( App, blank=True, default=None, on_delete=models.PROTECT, related_name="%(app_label)s_%(class)s", related_query_name="%(app_label)s_%(class)s", ) app_label = "com_longgui_app_proxy_nginx" class LongguiAppProxyNginxAppConfig(AppConfig): name = app_label class NginxAPP(AppExpandAbstract): class Meta: app_label = app_label is_intranet_url = models.CharField(verbose_name=_('Is Intranet URL', '是否内网地址'), max_length=128) class ExpandManager(models.Manager): """ Enables changing the default queryset function. """ def get_queryset(self, filters:dict={}): table_name = self.model._meta.db_table field_expands = field_expand_map.get(table_name,{}) queryset = self.model.objects.all() annotate_params = {} related_names = [] # values = [] # for field in self.model._meta.fields: # if field.name == 'password': # continue # values.append(field.name) for table, field,extension_name,extension_model_cls,extension_table,extension_field in field_expands: related_name = extension_name+'_'+extension_model_cls._meta.object_name related_names.append(extension_table) annotate_params[field] = F(extension_table+'__'+extension_field) # values.append(field) # return queryset.annotate(**annotate_params).select_related(*related_names).values(*values) queryset = queryset.annotate(**annotate_params).select_related(*related_names) print(queryset.query) return queryset.values() ######################################## when code run here,somthing wrong happens! ######################################### apps = App.expand_objects.filter( tenant_id=tenant_id, is_active=True, is_del=False ) ######################################## error log ######################################### Traceback (most recent call last): File "/home/fanhe/workspace/arkid-v2.5/.venv/lib/python3.8/site-packages/ninja/operation.py", line 99, in run result = self.view_func(request, **values) File "/home/fanhe/workspace/arkid-v2.5/arkid/core/api.py", line 143, in func response = old_view_func(request=request, *params, **kwargs) File "/home/fanhe/workspace/arkid-v2.5/.venv/lib/python3.8/site-packages/ninja/pagination.py", line 141, in view_with_pagination items = func(*args, **kwargs) File "/home/fanhe/workspace/arkid-v2.5/api/v1/views/app.py", line 33, in list_apps apps = App.expand_objects.filter( File "/home/fanhe/workspace/arkid-v2.5/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/fanhe/workspace/arkid-v2.5/arkid/core/expand.py", line 64, in get_queryset queryset = … -
Graphql Wrapper for Rest APIs with Django
Trying to implement wrapper for existing REST APIS using Django graphQL. Found similar one in JS but not in Django. https://graphql.org/blog/rest-api-graphql-wrapper/ Could anyone please suggest if there is a GraphQL Django wrapper for REST calls. Haven't found in documentation either -
deleting object by senting two id's in django by ajax call
am trying to delete an object in django via ajax call.I need to pass two id's.When I perform delete the id's are not passing .I get an url like 127.0.0:8000/delete// what is wrong with my script and views.py?? urls.py path('delete/<int:id1>/<int:id2>',views.delete,name="delete") views.py def delete(request,id1,id2): if request.method == "POST": obj=ShopUserMapping.objects.get(id1=id1,id2=id2) obj.delete() return render(request,"delete_mapping.html",{'obj':obj}) delete.html <form method="post" id="form_delete"> {% csrf_token %} <input type="hidden" id="id1" name="id1" data-value="{{obj.id1}}"> <input type="hidden" id="id2" name="id2" data-value="{{obj.id2}}"> Are you sure want to delete this item? <button type="submit" class="btn btn-danger login-btn" id="delete">Delete</button> </form> delete.js $("#form_delete").submit(function(event){ event.preventDefault();//prevent the form submitting via browser var formData=new FormData(); var id1=$("#id1").data("value"); var id2=$("#id2").data("value"); formData.append('csrfmiddlewaretoken','{{ csrf_token }}'); $.ajax({ //submit a request to the backend(server) using ajax url:'delete/'+ id1 + '/' + id2,//server script to process data type:'POST', data:new FormData(this), processData:false, contentType:false, success:function(res) { console.log("Successfully Deleted"); }, error:function(errResponse) { console.log(errResponse); } }); return false;}); -
Django: How Can I get 'pk' in views.py when I use class based views?
I'm writhing an app with class based views. I need to receive 'pk' in my views.py file when I load my page using generic DetailView. My urls.py file: from django.urls import path from . views import HomeView, ProfileView, AddPetView, EditPetView, DeletePetView, PetProfileView urlpatterns = [ ... path('profile/pet/<int:pk>', PetProfileView.as_view(), name='pet_profile'), path('', HomeView.as_view(), name='home'), ] My views.py file: from django.shortcuts import render from django.views.generic import TemplateView, ListView, UpdateView, CreateView, DeleteView, DetailView from django.urls import reverse_lazy from . models import Pet class PetProfileView(DetailView): model = Pet template_name = 'pet_profile.html' #key = Pet.objects.values_list('birth_date').get(pk=1) I need to extract from database birh_date column for this specific pet. How to get this pk=? when I load pet_profile page? I'm not sure if I can describe the case well. If something is not clear, ask me. I will try to explain again. Thanks in advance, -
Django admin panel does't work correctly on Debug=False on production
I can't add or delete items when Debug = False on production. On Debug = True everything is fine. Screenshot when Debug = True: Screenshot when Debug = False: Code from models.py: class Portfolio(models.Model): miniaturka=models.FileField(blank=False) logo=models.FileField(blank=True) nazwa=models.CharField(max_length=300, blank=False) link=models.CharField(max_length=400, blank=True) grafika=models.FileField(blank=True) grafika_mobilna=models.FileField(blank=True) opis=models.TextField(blank=True) class Meta: verbose_name="Portfolio" verbose_name_plural="Portfolio" def __str__(self): return self.nazwa class PortfolioRow(models.Model): portfolio = models.ForeignKey(Portfolio, default=None, on_delete=models.CASCADE) portfolioRowType = models.ForeignKey(PortfolioRowType, null=True, blank=True, on_delete=models.CASCADE) photo1 = models.FileField(blank=True) photo2 = models.FileField(blank=True) def __str__(self): return self.portfolio.nazwa class PortfolioVideo(models.Model): portfolio = models.ForeignKey(Portfolio, default=None, on_delete=models.CASCADE) link = models.CharField(max_length=300) def __str__(self): return self.portfolio.nazwa Code from admin.py: from typing import List from django.contrib import admin from main.models import * class PortfolioRowAdmin(admin.StackedInline): model = PortfolioRow class PortfolioVideoAdmin(admin.StackedInline): model = PortfolioVideo @admin.register(Portfolio) class PortfolioAdmin(admin.ModelAdmin): inlines = [PortfolioRowAdmin, PortfolioVideoAdmin] class Meta: model = Portfolio -
is there a way to use something like p=product.objects.filter(category=home)?
I have some categories that I can filter them by primary key like this : p=product.objects.filter(category=2) but I do not want to bother my self with primary keys I want to filter with exact name of the category not primary key. I have categories like this : image is there a way to use something like p=product.objects.filter(category=home) ? models: class category(models.Model): name=models.CharField(max_length=255, db_index=True) def __str__(self): return self.name class product(models.Model): category = models.ForeignKey(category, related_name='products',on_delete=models.CASCADE) image=models.CharField(max_length=500) description=models.CharField(max_length=500) price=models.CharField(max_length=50) buy=models.CharField(max_length=100) -
Upload document to all the related inquiries
So in my application there is something called Inquiry which also has related_inquiries associated with it. so in my model Inquiry i have a field related_inquires which is m2m field to self i.e is same model Inquiry have file upload page linked to this inquiry, I need a checkbox on my file upload page which should be displayed only if the inquiry has related_inquiries when checked that it should upload file to all the related_inquiries. class Inquiry(models.Model): name = models.Charfield(max_length = 255) related_inquiries = models.ManytoManyField('Self', null=True) file = models.FileField() class InquiryFileUpload(APIView): queryset = Inquiry.objects.all() lookup_url_kwarg = 'inquiry.id' def post(self, request, *args, **kwargs): '''code''' class InquiryModel(forms.ModelForm): upload_to_related_inquiries = models.Booleanfield() class Meta: model = Inquiry fields = '__all__' -
bulk_create , ignore_conflicts=True is not working in django?
ps_data=[PassengerDetail(name=j.get(name) for i, j in enumerate(ps)] PassengerDetail.objects.bulk_create(objs=ps_data, ignore_conflicts=True) Here I bulk create a django objects. I tried to bulk create objects without duplicate entries in db. But this isn't working. Where i get problem? -
django taking post request as get. django forms not working properly
django is taking my post request and get and the action of the form is returning the wrong url over and over. (my html template):- <div class="flex flex-col text-center w-full mb-12"> <h1 class="sm:text-3xl text-2xl font-medium title-font mb-4 text-gray-900">Change Password</h1> <p class="lg:w-2/3 mx-auto leading-relaxed text-base">Change Your Accounts Password.</p> </div> <div class="lg:w-1/2 md:w-2/3 mx-auto"> <form action="/profile/change-password/" method="post"> {% csrf_token %} {{ form|crispy }} <div class="p-2 w-full"> <button class="flex mx-auto text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-none hover:bg-indigo-600 rounded text-lg">Change</button> </div> </form> </div> </div> (views.py):- def change_password(request): if request.method == "POST": form = PasswordChangeForm(data=request.POST, user=request.user) if form.is_valid(): form.save() messages.info(request, "Password Changed Succesfully!") update_session_auth_hash(request, form.user) return redirect("/profile/") else: messages.info(request, "Please Try Again.") return redirect("/change-password/") else: form = PasswordChangeForm(user=request.user) return render(request, "change_password.html", {'form': form}) (urls.py):- urlpatterns = [ path("", profile), path("edit-profile/", edit_profile), path("change-password/", change_password), ] Please help -
Django F expression in boolean expression raises a TypeError exception
I am using Django 3.2 in a project. I have a method that compares the value of a field to an integer (see code below). Django throws an error (which makes sense because of the different types). My question is - how else am I to implement this check (whilst using F expression to avoid race conditions)? Code def bookmark(self, actor, note=''): if self.can_bookmark(actor): ct, object_id = self.get_content_info() found_objects = self.bookmarks.filter(content_type=ct, object_id=object_id, actor=actor) if found_objects: # We are unbookmarking found_objects.delete() self.bookmarks_count = F('bookmarks_count') - 1 # Sanity check (-ve value may occur if Db has been manipulated manually for instance) if self.bookmarks_count < 0: # <- Barfs here self.bookmarks_count = 0 if self.bookmarks_count == 0: # <- Barfs here too self.last_bookmarked = None self.save() return True else: # Create bookmark object and save it if self.create_and_increment(self.bookmarks, actor, note=note): self.bookmarks_count = F('bookmarks_count') + 1 self.last_bookmarked = timezone.now() actionable_object = self.actionable_object self.save() self.refresh_from_db() item_bookmarked.send(sender= actionable_object.__class__, instance=actionable_object, event_type = BOOKMARK, actor=actor) return True else: return False else: # do nothing return False [[Edit]] Here is the full traceback: Traceback (most recent call last): File "<console>", line 1, in <module> File "/path/to/myproj/models.py", line 455, in bookmark if self.bookmarks_count < 0: TypeError: '<' not supported … -
Recovered XML File Error and File contents shows some numeric-character combinations
Due to Crash of My OS, I Have lost some files, I need to recover some important xml files. After using some Recovery Softwares, i got the file restored, but in all recovery softwares, file contents seems like below. Its not XML. Anyone can help me to convert it to xml 582b 11f7 624f 4c90 7094 9d7d 65b2 ca2d 96b5 8d6c 5357 5ac4 4716 de88 d540 deae 6950 0480 d84d 88ba 8cd2 0938 480b deb5 9492 ef16 5d44 ff01 828d ceef 38be 4ed3 5ce1 a292 a0af a837 8d8c 910a 82c1 c9f0 e936 e889 d112 8da0 30b5 8ee5 2a10 6487 e6b5 0080 2b4f 73c9 e2dd 1d0e 8189 c0a6 28c2 0c32 b08e 95dc d17a ebd8 0f97 ffdc add5 86dd c1ad c438 5953 a77d c842 f0a6 5aba 9669 fb04 6eb6 ded5 ee48 d882 62e3 16a2 2441 a368 632a 619d 3e08 7f92 b735 78da 4cdf c435 d58f df02 9f07 75be 3548 996d 78d2 dd08 a2d9 dda3 d497 9e8e 1a88 cbff 48da de46 db44 25f8 5562 e9ad 4ba7 2f67 53f9 1582 19ea d48a 79f5 b59d da2d 3a08 7a9c dd62 60e9 45f1 6348 4676 550a d122 539b 6269 9b21 05d4 cb42 cd19 f076 de29 a1ae 0c06 623f 8225 83b6 0a0e a95b................... -
(DRF) ValueError: Field 'id' expected a number but got ''. Unable to pass in id to the url
I am writing a custom function to add favourite to Thread model. The function should expect an id pass in to the get_object_or_404. @csrf_exempt def add_favourites(request, id, *args, **kwargs): thread = get_object_or_404(Thread, id=id) if request.method == 'POST': if thread.liked.filter(username=request.user.username).exists(): thread.liked.remove(request.user.username) else: thread.liked.add(request.user.username) and I have my url.py like this to receive an id from axios url: path('api/public/favourites/<int:id>/', add_favourites, name='add_favourites'), However, when I perform the axios post request like this: axiosInstance.post(`api/public/favourites/4/`) It should be receiving id = 4, but it always return error: (DRF) ValueError: Field 'id' expected a number but got ''. Anybody has an idea whats wrong with my code? Much Thanks. -
Django pagination has_previous and has_next methods doesn't work
I'm using pagination in Django 1.11. But when I use has_next and has_previous it returns false everytime. Don't print anything. I'm sure that there is previous and next pages. In views I'm using TableView which is like ListView. Here is my code: <div class="pagination"> <span class="step-links"> {% if customers.has_next %} <p>HAS NEXT</p> {% endif %} {% if customers.has_previous %} <p>HAS PREVİOUS</p> {% endif %} </span> </div> views.py class TableView(ExportMixin, SingleTableView): model = Customer table_class = CustomerTable template_name = 'admin_pages/user_admin_page.html' context_object_name = 'customers' paginate_by = 3 *I'm using tableview just for export table. -
Django doesn't load a default picture. I have MEDIA root connected to urls
So I want the imageField to load a default picture when one is not uploaded by user. When I upload something in the imageField form, they end up in the correct folder. When I want it to load a default pic, it simply doesn't show up. I checked online, but the solutions I found point to things that I already have done (I think) right. models.py: class Ingredients(models.Model): type = models.IntegerField(choices=ingredientType) name = models.CharField(max_length=100) image = models.ImageField(default='no-photo-available-hi.png') def __str__(self): return self.name class DrinkRecipe(models.Model): name = models.CharField(max_length=100) ingredients = models.ManyToManyField(Ingredients) utensil = models.IntegerField(choices=requiredUtensil, default=0) preparation = models.CharField(max_length=1000) image = models.ImageField(default='no-photo-available-hi.png') def __str__(self): return self.name def __unicode__(self): return self.ingredients.name forms.py: class DrinkForm(forms.Form): name = forms.CharField(max_length=100, label="Name:") utensil = forms.ChoiceField(choices=requiredUtensil, label="Required utensil:") ingredients = forms.ModelMultipleChoiceField( queryset=Ingredients.objects.all(), widget=forms.CheckboxSelectMultiple() ) preparation = forms.CharField(widget=forms.Textarea) image = forms.ImageField(required=False) class IngredientForm(forms.Form): name = forms.CharField(max_length=100, label="Ingredient name") type = forms.ChoiceField(choices=ingredientType) image = forms.ImageField(required=False) settings.py: STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static") MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'static/shakerApp/media') project's (not app's) urls.py: urlpatterns = [...] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Project's directory: |Project |Project folder |App folder |Static |AppName |media |no-photo-available-hi.png |venv -
how to see OperationProxy attributes using zeep
from requests import Session from zeep import Client, Settings from zeep.plugins import HistoryPlugin from zeep.transports import Transport session = Session() session.verify = True transport = Transport(session=session) history = HistoryPlugin() wsdl_url = 'https://argusgate2.fitorf.ru/debug/ws/uz3?wsdl' settings = Settings(strict=False, xml_huge_tree=True) client = Client( wsdl_url, transport=transport, settings=settings, plugins=[history]) logging.getLogger("zeep").propagate = False parametrs = { "a": "something", } def send_request(cl, **parametrs): r = cl.service.Request91.input(**parametrs) return r enter code here a = send_request(client, **parametrs) print(a) When i sending this request it shows this error message: AttributeError: 'OperationProxy' object has no attribute 'input' . How to identify which attributes has OperationProxy -
is my problem from regex or youtube_dl ? the high quality videos downloaded without sounds
i have published a site for online youtube video downloader , { https://ytv.pythonanywhere.com } , everything is working Good But if i choise to download the video with high Resolution the video will be without sounds , here's my views enter image description here enter image description here