Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django 3.x Python 3.x Ajax : NoReverseMatch + jquery on change triggers only once
form on the page: views.py: @login_required def render_erkb_form(request,trans_id,coach_id): context = {} try: context['transfer'] = Transfer.objects.get(pk=trans_id) clients_assign_form = ErkbRamsis(transfer_id=trans_id, coach_id=coach_id, prefix=trans_id) context['clients_assign_form'] = clients_assign_form return TemplateResponse(request,'forms/erkb.html', context) except Exception as e: return HttpResponse('%s %s <P>Somthing went wrong!</p>' % (e,e.args),status=500) @login_required def clients_assign(request, trans_id): context = {} try: transfer = Transfer.objects.get(pk=trans_id) first_coach = transfer.service.legs.first() if request.method == "POST": clients_assign_form = ErkbRamsis( request.POST or None, files=('transfer_clients','coach','coach_clients',), transfer_id=transfer.pk, prefix=transfer.pk, ) if clients_assign_form.is_valid(): # get data and save it to database # Works Fine if clients_assign_form.is_valid() == False: # Do Some Action clients_assign_form = ErkbRamsis(transfer_id=trans_id,prefix=trans_id) context['clients_assign_form'] = clients_assign_form return TemplateResponse(request,'forms/erkb.html', context) except Exception as e: return HttpResponse('%s %s <P>Somthing went wrong!</p>' % (e,e.args),status=500) forms.py class ErkbRamsis(forms.Form): def __init__(self, *args, **kwargs): self.transfer_id = kwargs.pop('transfer_id') transfer = Transfer.objects.get(pk = self.transfer_id) if 'coach_id' in kwargs: self.coach_id = kwargs.pop('coach_id') leg = Leg.objects.get(pk = self.coach_id) else: leg = Leg.objects.filter(service = transfer.service).first() super(ErkbRamsis, self).__init__(*args, **kwargs) self.fields['transfer_clients'] = forms.ModelMultipleChoiceField( queryset=Client.objects.filter(related_pnr = transfer.service.related_pnr), widget=forms.SelectMultiple( attrs={ 'class':"erkb_source form-control", 'style':"height:100%;width:100%;", }, ), label=False, required=False, ) self.fields['coach'] = forms.ModelChoiceField( queryset=Leg.objects.filter(service = transfer.service), widget=forms.Select( attrs={ 'class':"erkb_coach form-control", 'data-trans':transfer.pk, } ), initial=leg, label=False, required=False, ) self.fields['coach_clients'] = forms.ModelMultipleChoiceField( queryset = leg.clients, widget=forms.SelectMultiple( attrs={ 'class':"erkb_destination form-control", } ), label=False, required=False, ) def clean(self, *args, **kwargs): transfer_clients = self.cleaned_data.get('transfer_clients') coach … -
Display distinct values in a form admin using a m2m relationship class - Django
I'm trying to display only the distinct names in the django admin form. Here are the 3 class: class Topping(models.Model): name = models.CharField(max_length=200) class Pizza(models.Model): name = models.CharField(max_length=200) toppings = models.ManyToManyField(Topping) class C(models.Models): pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE) When I get in the admin page to add a new record on C table, the same pizza appears different times, example: Pepperoni Pepperoni Hawaiian Hawaiian Hawaiian What I expected it was something like that: Pepperoni Hawaiian Thank you! -
AJAX delete POST request in Django Python
I'm building a simple TO-DO Django web application following csdojo tutorial here. I wanted to add Ajax in both addTodo & deletedTodo. Although addTodo is working properly but deleteTodo always render me to a JSON page with whatever return. This is my first Django web app, please help me locate the bug, MUCH THANKS!! urls.py from django.contrib import admin from django.urls import path from hello.views import view from todo.views import todo_view, addTodo, deleteTodo urlpatterns = [ path('admin/', admin.site.urls), path('sayHello/', view), path('todo/', todo_view, name = "todo_view"), path('addTodo/', addTodo, name = "addTodo"), path('deleteTodo/<int:todo_id>/', deleteTodo, name='deleteTodo'), ] views.py def addTodo(request) : if request.is_ajax and request.method == "POST": new_item = TodoItem(content = request.POST['content']) new_item.save() ser_instance = serializers.serialize('json', [ new_item, ]) return JsonResponse({"new_item": ser_instance}, status=200) else : return JsonResponse({"error": new_item.errors}, status=400) def deleteTodo(request, todo_id) : if request.is_ajax and request.method == "POST": item = TodoItem.objects.get(id=todo_id) item.delete() return JsonResponse({'url': reverse('todo_view')},status=200) else : return JsonResponse({"error": item.errors}, status=400) todo.html {% extends "base.html" %} <title>{% block title %} Vixtrum to do list {% endblock title %}</title> {% block content %} <h1>To do list</h1> <ul id="list"> {% for todo_item in all_items %} <li id="todo-{{todo_item.id}}">{{ todo_item.content }} <form class="deleteTD" action="/deleteTodo/{{todo_item.id}}/" method="post" style="display: inline; margin: 10px;">{% csrf_token %} <input type="submit" value="Delete" class="btn btn-outline-danger" … -
How to access reversed relationship using Django rest framework
Here are my models : class Profile(models.Model): user = models.ForeignKey(User, related_name="profile", on_delete=PROTECT) plan = models.ForeignKey(Plans, on_delete=PROTECT) full_name = models.CharField(max_length=2000) company_name = models.CharField(max_length=50, null=True, blank=True) activation_token = models.UUIDField(default=uuid.uuid4) activated = models.BooleanField(default=False) thumb = models.ImageField(upload_to='uploads/thumb/', null=True, blank=True) renew_data = models.DateField() is_paid = models.BooleanField(default=False) And as u see the Profile model have user field that is related to the Abstract user of django framework. now here is how i call them using an API : Serializers class ProfileSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Profile fields = ['company_name'] class UserSerializer(serializers.HyperlinkedModelSerializer): profile_set = ProfileSerializer( read_only=True, many=True) # many=True is required class Meta: model = User depth = 1 fields = ['username', 'id', 'profile_set'] But when I call the API it shows only the fields username and 'id but not the profile_set -
django form is submitting but the object is not saved in the database
Actually i'm working on the library management system project everything is working fine except return book functionality. My project contains books, students and issue and returning the book with fine if it is there. I was making a return book function i made the logic but and it is correct also but it is not saving into the database. Even the calculations which i wanted is done but it is not submitting. I'm doing from last 3 days. Please help me, if you get some idea. And please, let me know if you required any other files. models.py for return Book class ReturnBook(models.Model): actual_return_date = models.DateField(default=datetime.today) book = models.ForeignKey(Book, on_delete=models.CASCADE) student_name = models.ForeignKey(Student, on_delete=models.CASCADE) fine_amount = models.IntegerField(default=0) def __str__(self): return self.book.book_name + ' is returned by ' + self.student_name.first_name + ' ' + self.student_name.last_name forms.py for return book class ReturnBookForm(forms.ModelForm): class Meta: model = ReturnBook fields = [ 'actual_return_date', 'book', 'student_name', 'fine_amount' ] urls.py for return book and returned book path('issuedbooks/<int:pk>/returnbook/', views.returnBook, name='return-book'), path('returnedbook/', views.TransactionandReturnBook, name='returned-book'), returnbookform.html {% extends "lms/base.html" %} {% load crispy_forms_tags %} {% block content %} <div class="section"> <form method="POST" action="{% url 'returned-book' %}"> {% csrf_token %} <fieldset class="form-group"> <div class="card mt-4 detail-view-header"> <h3 class="text-center mt-2 font-weight-bold" … -
Gunicorn - starting server issue?
I am having this issue to start my gunicorn server, but it seems like it's failing to start the server after I did reload daemon and enable my updated gunicorn system. I checked two or three times to make sure all's correct, so alls correct. Pls see the image below: enter image description here - Also, see the errors I received after I started it: Active: failed (Result: resources) May 09 14:40:03 avidfisherman systemd[1]: Failed to start Gunicorn server for superlists-staging.bdienterprises.com. Anyone here is familiar with this issue? Your help would be so appreciated! Thank you! -
Django redirect with data
def view_post(request, post_id): """Display a blog post""" blogpost = BlogPost.objects.get(id=post_id) context = {'blogpost': blogpost} return render(request, 'blogs/blogpost.html', context) def new_post(request): """Create a new blog post""" if request.method != 'POST': # No data submitted; create a blank form. form = BlogPostForm() else: # POST data submitted; process data. form = BlogPostForm(data=request.POST) if form.is_valid(): form.save() return redirect('blogs:index') # Display a blank or invalid form. context = {'form': form} return render(request, 'blogs/new_post.html', context) def edit_post(request, post_id): blogpost = BlogPost.objects.get(id=post_id) if request.method != 'POST': # Initial request; pre-fill form with current blogpost. form = BlogPostForm(instance=blogpost) else: # POST data submitted; process data. form = BlogPostForm(instance=blogpost, data=request.POST) if form.is_valid(): form.save() view_post(request,post_id) # Display form with original contents context = {'blogpost': blogpost,'form': form} return render(request, 'blogs/edit_post.html', context) The code above should process a user's edited post, and then redirect to the post that has been edited. Redirect doesn't allow data to be sent to my knowledge, so I tried to nest a function to no avail. I've seen online that cookies / messages may be a solution. If so, how might I implement it? -
Nginx proxy server to another proxy server Gateway timeout
It's my first time deploying an application on a deployment environment so I am a complete beginner at this, I have an nginx proxy server (call it server1) on an instance with an exposed IP to the internet & it routes requests to another server on a different instance (call it server2) that hosts my Django application, the conf file for server1 goes like this : `server{ server_name _; location / { proxy_pass_header Authorization; proxy_pass http://10.156.0.4:80; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Connection “”; proxy_buffering off; client_max_body_size 0; proxy_read_timeout 36000s; proxy_redirect off; } listen 443 ssl; listen [::]:443 ssl; include snippets/self-signed.conf; include snippets/ssl-params.conf; } server{ listen 80; listen [::]:80; server_name _; return 302 https://35.246.244.220;} and the second server: server{ listen 80; listen [::]:80; server_name _; location / { proxy_pass_header Authorization; proxy_pass http://10.156.0.4:8880; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Connection “”; proxy_buffering off; client_max_body_size 0; proxy_read_timeout 36000s; proxy_redirect off; } location /static/ { alias /opt/app/mydjangoapp/staticfiles/; autoindex off; } } I am running my django application using this command python manage.py runserver 0.0.0.0:8880 & I also did collectstatic before running the application. Everything works fine when i edit proxy_pass in … -
How to get custom column from MYSQL table through Django
I would like to get specific column from DV table based on input from user. db : animal weight height cat 40 20 wolf 100 50 first i need to get what animal user wants input1='cat' and then information about the input1 like weight or height input2='weight' animalwho=Wildlife.objects.get(animal=input1) So if i put animalwho.weight it give me 40 But i want to get column based on input2 as input 2 might be height or any other I tried animalwho.input2 but it does not work. Is that possible to get column based on input2? Would apopreciate any help -
Path does not find in django
I am working on a django project. The project includes 2 apps namely jobs and blog. The url.py of the main project file is: from django.contrib import admin from django.urls import path,include from django.conf import settings from django.conf.urls.static import static import jobs.views urlpatterns = [ path('admin/', admin.site.urls), path('', jobs.views.home, name= 'home'), path('blog/', include('blog.urls')) ] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) You can understand that I am calling the output of the jobs in the home. The url.py of the blog is: from django.urls import path from . import views urlpatterns = [ path('', views.allblogs, name= 'allblogs'), ] and the views.py of the blog is: from django.shortcuts import render def allblogs(request): return render(request, 'blog/allblogs.html') This gives an error that the blogs/ can not be found. The webpage shows that it tries to find the page in this ditrectory: ...project\jobs\templates\blog\allblogs.html I dont know why it is trying to find it in jobs where it should search for it in blogs folder. Can someone help? May be I have done something silly.. -
django-invitations JSON view errors
I simply want to be able to have a user send an email invite to multiple users via an email input field that allows up to 30 emails. I've tried using django-multi-email-field but don't want to have to do more work than necessary. django-invitations already does the invite keys for me so I want to be able to get the json-invite url to work. I get the errors Method Not Allowed (GET): /invitations/send-json-invite/ Method Not Allowed: /invitations/send-json-invite/ when going to that url. I have not modified the package at all but inside the invitations/views.py there is this: class SendJSONInvite(View): http_method_names = [u'post'] @method_decorator(login_required) def dispatch(self, request, *args, **kwargs): if app_settings.ALLOW_JSON_INVITES: return super(SendJSONInvite, self).dispatch( request, *args, **kwargs) else: raise Http404 def post(self, request, *args, **kwargs): status_code = 400 invitees = json.loads(request.body.decode()) response = {'valid': [], 'invalid': []} if isinstance(invitees, list): for invitee in invitees: try: validate_email(invitee) CleanEmailMixin().validate_invitation(invitee) invite = Invitation.create(invitee) except(ValueError, KeyError): pass except(ValidationError): response['invalid'].append({ invitee: 'invalid email'}) except(AlreadyAccepted): response['invalid'].append({ invitee: 'already accepted'}) except(AlreadyInvited): response['invalid'].append( {invitee: 'pending invite'}) except(UserRegisteredEmail): response['invalid'].append( {invitee: 'user registered email'}) else: invite.send_invitation(request) response['valid'].append({invitee: 'invited'}) if response['valid']: status_code = 201 return HttpResponse( json.dumps(response), status=status_code, content_type='application/json') I tried adding 'get' to the http_method_names as well as creating a "pass" … -
How to exclude values of manytomanyfields from from POST method( Django Rest Framework )
I have a Blog project where users can Post,comment and like the posts. When displaying entire Posts (ListCreateView method,ie POST&GET) it displays whoever liked the post but in POST method(as mentioned in attached picture) it exposes the list of entire users as options to like (in attached photo, voters means list of registered users with Blog project, for test purpose they named as a,b,c ) How can I avoid voters (I mean list of people who can like Post ) from CreateView ? My projects works fine but I want to avoid the major data expose. SERIALIZERS.PY class PostSerializer(serializers.ModelSerializer): class Meta: model = Post fields = "__all__" class LikeSerializer(serializers.ModelSerializer): class Meta: model = Post exclude = ("voters",) MODELS.PY class Post(models.Model): ... voters = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name="votes",blank=True) -
Django Template counter++
I am trying to complete this exact code wrote on PHP and Laravel but using Django: @php $a = 0; @endphp @foreach($images as $image) @if($a % 2 == 0) <li class="grid-item"> <!--<li class="grid-item2">--> <img class="img img-fluid"src="{{ route('image.file',['filename' => $image->image_path]) }}" /> </li> @php $a = $a+1; @endphp @else <li class="grid-item grid-item--width2"> <!--<li class="grid-item2 grid-item--width2">--> <img class="img img-fluid"src="{{ route('image.file',['filename' => $image->image_path]) }}" /> </li> @php $a = $a+1; @endphp @endif @endforeach It just simple enter using pair numbers into the if condition or not, for any foreach cycle. and this is what I have on Django: {% for photography in photographies.all%} {% if number|divisibleby:2 == True %} <li class="grid-item"> <!--<li class="grid-item2">--> <img class="img img-fluid" src="{{ photography.image.url }}" /> </li> {{number|add:1}} {% else %} <li class="grid-item grid-item--width2"> <!--<li class="grid-item2 grid-item--width2">--> <img class="img img-fluid" src="{{ photography.image.url }}" /> </li> {{number|add:1}} {% endif %} {% endfor %} The views.py: def home(request): #añadido number = 0 photographies = Photography.objects #añadido return render(request, 'photographies/home.html', { 'photographies':photographies, 'number':number }) #añadido The biggest problem I have right now is that for some reason the variable number which on any for cycle it reset to cero so always enter into the if condition. -
Form in footer through base html not working on other pages with forms django
So I'm using LoginView for my login page for example but on the login page the newsletter signup form in my footer also turns into a login form. I tried using my own view and changing the newsletter signup for to form2 in context but it doesn't work. I guess because newsletter signup is a form it's getting passed any other form on whichever page I'm on. Any ideas? -
How to convert // to / in url address in python django and apache -- linux
At first, thank you for reading :X Problem + Description: I'm redirecting http traffic from any ip address on port 80 to 10.0.0.1:8080 (django) via linux apache and iptables. When web user issue a request to this url (hello.gggstatic.com/generate_204******), I handle path to /generate_204*** url address, via this rule: re_path('.*generate_204.*', lambda r: HttpResponseRedirect('splash/')),. Buuuuut, users are seeing `//splash/` instead of `/splash/` in browser. `http://10.0.0.1:8080//splash/` #django 404 not found users must see: `http://10.0.0.1:8080/splash/` #django can handle it and via "include('splash.urls')" Problem: How to manage/remove/handle "//" in url address bar !!?? Log: [09/May/2020 13:43:36] "GET //generate_204 HTTP/1.1" 302 0 Not Found: //captive_splash/ [09/May/2020 13:43:36] "GET //splash/ HTTP/1.1" 404 2328 my urls.py file in django-project: urlpatterns = [ re_path('/static/', serve,{'document_root': settings.STATICFILES_DIRS}), re_path('.*generate_204.*', lambda r: HttpResponseRedirect('splash/')), path('', lambda r: HttpResponseRedirect('splash/')), #path('admin/', admin.site.urls), path('splash/', include('splash.urls')), ] my urls.py file in django-application: urlpatterns = [ re_path('^$', views.start, name='start'), re_path('index/$', views.start, name='start'), path('validation', views.validation, name='validation'), path('bye', views.goodbye, name='goodbye'), ] My apache config: <VirtualHost *:80> ServerName hello.gggstatic.com ServerAdmin webmaster@localhost RewriteEngine On RewriteCond %{HTTP_HOST} ^hello.gggstatic.com$ RewriteRule ^(.*)$ http://10.0.0.1:8080 [L,NC,R=302] ErrorLog ${APACHE_LOG_DIR}/android_error.log CustomLog ${APACHE_LOG_DIR}/android_access.log combined </VirtualHost> -
Run function only if all tests passed in Django
I was looking for a way how can I run a function ONLY if all of the tests are passed. I have looked around the documentation, unfortunately, I cannot see any way how can I check are all tests passing(not all tests in each class, but all tests overall), or how to run a function after all tests(same, not TearDown in each class, just one function after all of the tests ;)). Any idea how I can achieve that? Thank you in advance ;) -
Querying the sum of fields based on the same value fields in different class model (annotate)
I got 3 different models: class Buyer(models.Model): name = models.CharField(max_length=200, blank=True) description = models.CharField(max_length=200, blank=True) class Sell(models.Model): buyer = models.ForeignKey(Buyer, related_name='sell', on_delete=models.CASCADE) total_paid = models.DecimalField(max_digits=6, decimal_places=2) class Payment(models.Model): name = models.ForeignKey(Buyer, related_name='payment', on_delete=models.CASCADE) value = models.DecimalField(max_digits=6, decimal_places=2) I'm trying to sum the fields Sell.total_paid and Payment.value based on the Sell.buyer.name, which has the same values as the Payment.name I've tried the code below in my views.py but it's not working properly: def debtor(request): debtors = Sell.objects.values('buyer__name').\ annotate(total_paid=Sum('total_paid'), other=Sum('buyer__payment__value'), debit=F('total_paid')-F('other')) context = {'debtors': debtors} return render(request, 'debtor.html', context) Thank you! -
Messages not appearing after creating an app for it in Django
I created an app called marketing app which customizes messages to be written on top of website page. My problem is that these messages are not showing when everything is configured and I don't know why is that This is the model of the Marketing App class MarketingMessage(models.Model): message = models.CharField(max_length=120) active = models.BooleanField(default=False) featured = models.BooleanField(default=False) timestamp = models.DateTimeField(auto_now_add=True, auto_now=False) updated = models.DateTimeField(auto_now_add=False, auto_now=True) start_date = models.DateTimeField( auto_now_add=False, auto_now=False, null=True, blank=True) end = models.DateTimeField( auto_now_add=False, auto_now=False, null=True, blank=True) def __str__(self): return str(self.message[:12]) this is the views for the core app from marketing.models import MarketingMessage class HomeView(ListView): model = Item paginate_by = 10 template_name = "home.html" marketing_message = MarketingMessage.objects.all()[0] this is the template {% if marketing_message %} <div class="alert alert-light alert-top-message" role="alert"style="margin-bottom: 0px; border-radius: 0px; text-align: center;padding-top:80px"> <div class="container"> <h3>{{ marketing_message.message }}</h3> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> </div> {% endif %} This is the admin.py of marketing from django.contrib import admin from .models import MarketingMessage # Register your models here. class MarketingMessageAdmin(admin.ModelAdmin): class Meta: model = MarketingMessage admin.site.register(MarketingMessage, MarketingMessageAdmin) -
Django template: Displaying parent and child from the same model
I am creating a django blog and I have a Comments model that looks like this: class Comment(models.Model): content = models.TextField('Comment', blank=False, help_text='Comment * Required', max_length=500) post = models.ForeignKey('Post', on_delete=models.CASCADE, blank=False, related_name='comments') parent = models.ForeignKey('self', null=True, on_delete=models.SET_NULL, related_name='replies') I am attempting to display the replies below the comment using the code below in the template: {% for comment in comments %} {{ comment.content }} {% for reply in comment.replies.all %} {{ reply.content }} {% endfor %} {% endfor %} However, the result of this is the replies get displayed twice. Below the comment they're related to and again by themselves. What am I doing wrong? Why are the replies getting displayed twice. Also, the replies only go one level i.e. there can't be a reply to a reply only a reply to a comment. -
IOS safari ans Chrome block my websocket django Channels
I’m having a problem developping my web app with django channels. On laptop, the websocket works perfectly: data are well received end sent. But on all iPhone, it does not work. Thanks to web inspector I caught the error: the connexion is blocked because it is not secure(ws). Same problem with IOS Chrome but Ecosia works. The app works fine on Android. How can i prevent IOS safari (and Chrome) from blocking the connexion ? Thx. -
Django server running but cant hit url
I am on windows 10. I have a django server running which said the following: python manage.py runserver Watching for file changes with StatReloader This is the DRF tutorial. When I go to http://127.0.0.1:8000/users/, I get the screen you get when your internet is down: This site can’t be reached 127.0.0.1 refused to connect. Every time I hit the URL, the server doesn't register anything. Usually a new line would print showing the request and either 200 or an error. I have never seen this happen after running a django server. I also don't usually do python on windows I prefer linux. I'm assuming this is a windows issue. Any help appreciated -
Django deleting and re-creating model instead of rename
class ModelA: pass class ModelB: model_a = ForeignKey(ModelA) If I want to rename ModelA to ModelANew here is the strategy Django Follows: Migration 1: Create ModelANew Migration 2: Remove field model_a from ModelB. Add field model_a_new to ModelB Migration 3: Delete ModelA The obvious downside of this is that the information in the table modela is lost. Can this be done with renaming the model? Django obviously did not ask if this was a rename. Is it possible to inform or make it go that route? If not, what would be a strategy to manually code the migration. -
Wrong upload path in Django
I have configured Django3.0 / Ubuntu 18 / NginX Media root in URL.py: if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) and in Nginx: server { listen 80; server_name XXXXX.com; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/user/proj; } location /media/ { root /home/user/proj; } location / { include proxy_params; proxy_pass http://unix:/run/proj_gunicorn.sock; } } and in models, I have some FileField and ImageField with 'upload_to ' attribute. When I upload something through admin, everything is okay and files will be uploaded in sub-folders (eg. media/2020/avatar/1.jpg) but when I do that through forms, files will be uploaded in right sub-directories but the image (or file) URL shows the root of media (eg. media/1.jpg) and when I click on URL, it returns 404. I can not figure out why this is happening, I've used this config in dozens of web sites and they work like a charm. Any ideas? -
Django - Chained Dropdown - Display a value based on two dropdown options
I want to display data in a dropdown based on two values selected in their respective dropdown menus. Here is the form which provides mapping between elements, number_service_location, country and did_number - class DID_Definition_Model_Form(forms.ModelForm): class Meta: model = DID_Definition_Model fields = ('did_number','country','number_service_location') labels = { 'country' : 'Country', 'number_service_location' : 'Number Service Location', } This above definition is later used for in another model and made available as dropdown class DID_Number_Assignment_Model_Form(forms.ModelForm): class Meta: model = DID_Number_Assignment_Model fields = ('country','number_service_location','did_selector', 'usage_assignment', 'employee_fullname', 'employee_email', 'subscriber_department' ) labels = { 'country' : 'Country', 'number_service_location' : 'Number Service Location', 'did_selector' : 'DID Selector' } So when both country and number_service_location are selected, corresponding did_selector value displays. To further add, country and number_service_location fields are independent. Any guidance will be helpful... -
App crashed error heroku deploying django
I deployed django app on heroku and got an error - h10 app crashed, but didn't get any info about reason of this error: