Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
finish setting up django channel & celery to have background process async to site
I have this javascript that fires when a button is clicked $('.test-parse').unbind().click(function() { parent = $(this).parent().parent(); var x = parent.find('.x').text(); var y = parent.find('.y').text(); var area_id = parent.find('.area').text(); if (area_id != '') { var area = areas[area_id]; } else { var area = null; } var cropped = $('.zoom-in').hasClass('btn-success'); if (cropped) { var img_url = $('#main-img-src').text(); } else { var img_url = $('.img-class').attr('src'); } var data = { 'x': x, 'y': y, 'image': img_url, 'width': $('.img-class').width(), 'height': $('.img-class').height(), 'color': parent.find('#color').css('background-color'), 'variance': parent.find('.color').val(), 'switch-color': parent.find('.switch-color').prop('checked'), 'new-color': parent.find('.color-code').val(), 'keep-perspective': parent.find('.perspective').prop('checked'), 'cls-id': parent.find('.cls-id').text(), 'area-id': area, 'grayscale': $('.gl-scale input').prop('checked'), } var unique_processing_id = ''; var task_id = ''; var csrftoken = $.cookie('csrftoken'); $.ajax({ url: "/start-render-part", type: "POST", dataType: 'json', beforeSend: function(xhr, settings) { if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { // Send the token to same-origin, relative URLs only. // Send the token only if the method warrants CSRF protection // Using the CSRFToken value acquired earlier xhr.setRequestHeader("X-CSRFToken", csrftoken); } }, data: JSON.stringify(data), success: function(response){ if (response['status'] == 'ok') { if (response['unique-id']) { unique_processing_id = response['unique-id']; } if (response['task_id']) { task_id = response['task_id']; } var add_to_group_msg = JSON.stringify({ 'unique_processing_id': unique_processing_id, 'task_id': task_id, 'command': 'add_to_group', }); var socket = new WebSocket("ws://{HOST}/render-part/".replace('{HOST}', window.location.host)); socket.onopen = function() { var … -
How to differentiate cloned elements in jQuery and add events to cloned elements
I am trying to make deck builder. I want have this functionality, if I click on a card it shows in deck section, counter goes up. When I click on a card in deck section counter goes down and when it zero card disappears from deck section. My problem is how to differentiate cloned elements from original and how to add event to elements I am cloning. This is my JS script: $(".bronze").mouseup(function(e){ if (e.which === 1) { var counter = parseInt($(this).find(".bronze_counter").text(), 10) var card_name = $(this).attr("class").replace("bronze ", "") if (counter < 3) { counter += 1 $(this).find(".bronze_counter").text(counter); if (counter == 1){ $(this).clone().appendTo(".deck"); } else { $(".deck ." + card_name).find(".bronze_counter").text(counter); } } } }); And my template: <h3>Current Deck</h3> <div class="container deck"> </div> <div class="container"> {% for card in cards %} <span class="bronze {{ card.name | cut:'\'' | cut:' '}}"> <span><img src="{{ card.thumbnail_link }}" style="width:5%"> [</span> <span class="bronze_counter">0</span> <span>/3] </span> </span> {% endfor %} </div> Further I need to somehow save this deck in database. I was thinking about getting card names plus counter of each card and saving them in database. Am I digging a hole under myself? Thanks in advantage! Tomek Argasiński -
Attribute error '/posts/' 'Comment' object has no attribute '_mptt_meta'
I am following this example on how to set threaded comments with django_comments and django-mptt. I have followed most of it and the posted comments are working in admin but I am getting this error 'Comment' object has no attribute '_mptt_meta'. I have tried using a different instances to reference with and tried different objects but I am not sure what the problem might be? I have a comments app where I am running most of the code from in this example: comments/models.py: from django_comments.models import Comment from mptt.models import MPTTModel, TreeForeignKey class MPTTComment(MPTTModel, Comment): """ Threaded comments - Add support for the parent comment store and MPTT traversal""" # a link to comment that is being replied, if one exists parent = TreeForeignKey('self', null=True, blank=True, related_name='children') class MPTTMeta: # comments on one level will be ordered by date of creation order_insertion_by=['submit_date'] class Meta: ordering=['tree_id', 'lft'] comments/forms.py: from django import forms from django.contrib.admin import widgets from django_comments.forms import CommentForm from .models import MPTTComment class MPTTCommentForm(CommentForm): parent = forms.ModelChoiceField(queryset=MPTTComment.objects.all(), required=False, widget=forms.HiddenInput) def get_comment_model(self): # Use our custom comment model instead of the built-in one. return MPTTComment def get_comment_create_data(self): # Use the data of the superclass, and add in the parent field … -
Wrong hyperlinks of Django Rest Framework with complex stack using SSL, AWS Load Balancer, Nginx and Gunicorn
I can't find out how to correctly set up nginx so my hyperlinks in API build by DRF are correct. My current configuration for nginx is: upstream web { ip_hash; server web:8000; } # portal server { listen 8000; server_name localhost; location / { proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://web/; } } nginx is running inside a container exposing port 8000 and maps it into internally running gunicorn (also in a container) also on 8000. So when I spin up the whole docker machinery, I can nicely access localhost:8000/api and links are rendered OK. Even when I access it using different domain (e.g. if I set in /etc/hosts: 127.0.0.1 mytest.com), the URL and port get passed correctly to the DRF and links are rendered as expect. But this service must sit behind AWS Load Balancer with certificate using SSL. Hostname on this LB is set otherdomain.com and it redirects traffic to the machine where the above nginx is run using HTTP on port 8000. Then, when try to access it using https://otherdomain.com/api, links are rendered as http://otherdomain.com:8000/api/ <- hence wrong scheme (http instead https) and wrong port (8000 instead of 80/443). It … -
is it possible to create a rest web api with pure django?
I can't figure out if it's possible to create a django api without the django rest framework because I'm having troubles with csrf token while receiving my POST datas. Is it possible to disable this because I can't use django csrf token management in my javascript electron app ? -
How to Handle in Django - Exception Type: MultipleObjectsReturned
Here I am struggling with the handling the exception, here is the details of my data models. Routes Model- class Routes(models.Model): serial_no = models.IntegerField(primary_key=True) toll = models.CharField(max_length=1000, blank=True, null=True) cost = models.CharField(max_length=300, blank=True, null=True) t = models.ForeignKey('Tollmaster', models.DO_NOTHING, blank=True, null=True) r = models.ForeignKey(Routeinfo, models.DO_NOTHING) class Meta: managed = True db_table = 'routes' unique_together = (('serial_no', 'r'),) But in admin panel I am getting error MultipleObjectsReturned at /admin/tollm/routes/27/change/ get() returned more than one Routes -- it returned 2! Request Method: GET Request URL: http://127.0.0.1:8000/admin/tollm/routes/27/change/ Django Version: 1.11.5 Exception Type: MultipleObjectsReturned Exception Value: get() returned more than one Routes -- it returned 2! Exception Location: C:\Users\prash\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py in get, line 384 Python Executable: C:\Users\prash\AppData\Local\Programs\Python\Python36-32\python.exe Python Version: 3.6.2 I am using Postgresql database, here is the schema for this table, Table "public.routes" Column | Type | Modifiers -----------+-------------------------+----------- serial_no | integer | not null toll | character varying(1000) | cost | character varying(300) | t_id | integer | r_id | character varying(300) | not null Indexes: "sno_rid_pkey" PRIMARY KEY, btree (serial_no, r_id) Foreign-key constraints: "r_rinfo_fk" FOREIGN KEY (r_id) REFERENCES routeinfo(r_id) "t_id_fk" FOREIGN KEY (t_id) REFERENCES tollmaster1(tid) any help would be appreciated. -
Basic logics with Django views and foreignkey
I am new to Django and struggling with a basic problem, yet cannot find a solution online. I have these models: class Suggestion(models.Model): author = models.ForeignKey('auth.User') title = models.CharField(max_length=200) description = models.TextField() created_date = models.DateTimeField(default=timezone.now) def __str__(self): return self.title class Vote(models.Model): suggestion = models.ForeignKey(Suggestion) voter = models.ForeignKey('auth.User') vote_count = models.IntegerField(default=1) and I'm trying create a view that would add a Vote to a given Suggestion, capturing the User who voted. I've seen some seem to do this with a form or with a regular function, so not sure what's the best practice here? -
Case WHEN to fetch data from different model when data is not zero
I have a simple model like this: class Payments(models.Model): dt=models.DateField() payer=models.IntegerField(default=0) If a member pays for himself, payer=0. But sometimes his support group (there are many groups) can pay for him/her and when that happens, the payer holds the ID of the support group. I didn't want to implement a relationship here. Now I want to list payments made but when payer>0, to get name of the subgroup that actually paid for the member. data=Payments.objects.filter(**build_filters['filters']).annotate(support_group_name=Case(When(payer__gt=0, then=Value('support group name goes here'), default=Value(''), output_field=CharField())).values('support_group_name','id','dt') I already have a function that use from various locations which returns name of a support group provided with id. I tried: data=Payments.objects.filter(**build_filters['filters']).annotate(support_group_name=Case(When(payer__gt=0, then=Value(support_name(payer)), default=Value(''), output_field=CharField())).values('support_group_name','id','dt') But I get payer is undefined. Any idea what I can do about this? -
template.render() python subfunction in Django 1.11 not available
So, I have PyCharm 2017.2.3, and Python 3.6, and Django 1.11. while practising on the test project, I tried to render to my index.html in view.py under my app. Below is the piece of code that I am talking about: def index(request): db_Conn = Album.objects.all() template = loader.get_template('/music/index.html') context = { 'db_Conn': db_Conn, } return HttpResponse(template.re) inside "return HttpResponse", I can get until template, but when I use a period after template to use the render() subfunction, I do not get any suggestion from PyCharm for "render(), instead, I could see two other functions which not relevant to my post. Can sombody help me on this. My learning is halted due to this. -
django admin 1.11 add an attribute to the options of a select
In django 1.11 admin, I have a list field and I would add an attribute in each <option> of my <select> Currently I have <select name = "example" id = "id_example"> <option value = "" selected> --------- </ option> <option value = "480"> data1 </ option> <option value = "481"> data2 </ option> <option value = "482"> data3 </ option> </select> I would like to add a link attribute to : <select name = "example" id = "id_example"> <option value = "" selected> --------- </ option> <option value = "480" link = "1"> data1 </ option> <option value = "481" link = "1"> data2 </ option> <option value = "482" link = "2"> data3 </ option> </select> I tested the following stack Django form field choices, adding an attribute but the function render_option (self, selected_choices, option_value, option_label) is not in django 1.11 https://code.djangoproject.com/ticket/28308 Do you have any idea how to add an attribute properly? -
Import Django models from outside the project
i m working at an app which use two tables from different databases.I manage to make the connection and make the tables strutures in models.py, but now one i change the models.py file, i copy one of the table in another python script, and i put the file elsewhere for other people to use it.My question it is possible in Django to import a model from outside the project? or the package? -
Django get_absolute_url (Return user to the same page after form submission)
Learing django. I have one question. I have done feedback form and i need to redirect user to the same page after feedback form confirmation. Code look below models.py class Feedback(models.Model): title = models.CharField(max_length=255) text = models.TextField(max_length=5000) user_name = models.CharField(max_length=255) user_lastname = models.CharField(max_length=255) email = models.EmailField(max_length=255) send_time = models.DateTimeField(auto_now_add=True) update_time = models.DateTimeField(auto_now=True) def get_absolute_url(self): return views.py class FeedbackSendForm(CreateView): model = Feedback fields = [ 'title', 'text', 'user_name', 'user_lastname', 'email', ] template_name = 'feedback.html' feedback.html <form method="post"> {% csrf_token %} {% for field in form %} <span class="text-danger">{{ field.errors }}</span> <div> <label class="control-label">{{ field.label }}</label> {{ field }} </div> {% endfor %} <button type="submit">Submit</button> </form> Any ideas? Please help. Thank you in advance -
upload file to S3 using DRF
I have an issue. I want to upload a file to my S3 bucket with DRF but I'm getting an error when I try with Postman models.py class Asset(models.Model): game = models.ForeignKey(Game, related_name='assets', on_delete=models.CASCADE) file_path = models.FileField(upload_to='test', default='') created_at = models.DateTimeField(auto_now_add=True, blank=True, null=True) class Meta: db_table = 'Asset' serializers.py class AssetSerializer(serializers.ModelSerializer): class Meta: model = Asset fields = ('id', 'file_path', 'created_at', 'updated_at') views.py class AssetList(generics.ListCreateAPIView): queryset = Asset.objects.all() serializer_class = AssetSerializer permission_classes = (IsAuthenticated,) parser_classes = (MultiPartParser, ) def perform_create(self, serializer): serializer.save(game_id=self.kwargs['game_id']) I have this in my local_settings.py AWS_ACCESS_KEY_ID = "..." AWS_SECRET_ACCESS_KEY = "..." AWS_STORAGE_BUCKET_NAME = "my-bucket-name" And when I do: POST /games/1/assets/ and upload a file with POSTMAN, I'm getting this error: File ".env/lib/python2.7/site- packages/boto/s3/bucket.py", line 232, in _get_key_internal response.status, response.reason, '') S3ResponseError: S3ResponseError: 400 Bad Request Thank you for helping! -
AttributeError: 'Price' object has no attribute 'update'
I got an error,AttributeError: 'Price' object has no attribute 'update' .I wrote fourrows_transpose=list(map(list, zip(*fourrows))) val3 = sheet3.cell_value(rowx=0, colx=9) user3 = Companyransaction.objects.filter(corporation_id=val3).first() if user3: area = Area.objects.filter(name="America").first() pref = Prefecture.objects.create(name="Prefecture", area=area) city = City.objects.create(name="City", prefecture=pref) price= Price.objects.create(city=city) pref.name = fourrows_transpose[0][0] pref.save() for transpose in fourrows_transpose[2:]: if len(transpose) == 5: if "×" in transpose or "○" in transpose: city.name = "NY" city.save() price.update(upper1000="○",from500to1000="○",under500="○") In models.py I wrote class Area(models.Model): name = models.CharField(max_length=20, verbose_name='area', null=True) class User(models.Model): user_id = models.CharField(max_length=200,null=True) area = models.ForeignKey('Area',null=True, blank=True) class Prefecture(models.Model): name = models.CharField(max_length=20, verbose_name='prefecture') area = models.ForeignKey('Area', null=True, blank=True) class City(models.Model): name = models.CharField(max_length=20, verbose_name='city') prefecture = models.ForeignKey('Prefecture', null=True, blank=True) class Price(models.Model): upper1000 = models.CharField(max_length=20, verbose_name='u1000', null=True) from500to1000 = models.CharField(max_length=20, verbose_name='500~1000', null=True) under500 = models.CharField(max_length=20, verbose_name='d500', null=True) city = models.ForeignKey('City', null=True, blank=True) I wanna put "○" to upper1000&from500to1000&under500 column of Price model, but it cannot be done because of the error.What is wrong in my code?How can I fix this? -
how to add links and images in text field of django admin
I am using django to create a blog. In my model I am using a text field for my blog content. But I am unable to insert any image or a clickable link.How to add links(clickable) and insert images? -
Difficulties while using send_mail()
I have few issues regarding sending emails using Django: Why am I unable to send emails (using Gmail SMTP server ) when I am under VPN? How to configure my SMTP server in Django? (I want to use my organization's SMTP server other than Gmail's) What is the difference between: "[WinError 10054] An existing connection was forcibly closed by the remote host" and "[WinError 10061] No connection could be made because the target machine actively refused it " errors? I am stuck on this issue since two weeks. Please help me to understand things better. Thanks in advance! -
Using extra_columns in django_tables2.tables.Table
Trying to use extra_colums and get no error but the table does not show up. I've use the documentation from here. I am trying to add a column which will have checkboxes into the table. I have already predefined the table and can exclude some fields but with using the documentation I cannot figure out how to add a new column. I must be missing something The implementation can be seen below. Would appreciate any assistance. Thanks IN TABLES.PY import django_tables2 as tables from project.models import Project class ProjectTable(tables.Table): project_name = tables.TemplateColumn(""" {%if record.department == "TRACER"%} <a href=" {% url 'project_detail' record.id %}"> {{ value }} </a> {%else%} {{value}} {%endif%} """, orderable=True, accessor='name', verbose_name="Project name") project_type = tables.TemplateColumn(""" {% if value == 'Yes' %}Special{% else %}Normal{% endif %} """, orderable=True, accessor='is_special', verbose_name="Project type") project_code = tables.Column(accessor='code', verbose_name="Project code") project_status = tables.Column(accessor='status', verbose_name="Project status") department = tables.Column(accessor='department', verbose_name="Department") class Meta: model = Project attrs = {'class': 'table table-striped table-hover'} sequence = ( 'project_name', 'project_type', 'project_code', 'project_status',) IN THE VIEW from project.tables import ProjectTable from django_tables2.columns import CheckBoxColumn class AllocationChangeView(PagedFilteredTableView): display_message = "You need to be logged in to view this page" table_class = ProjectTable queryset = Project.objects.all() template_name = 'matter_allocation/change_project.html' paginate_by … -
How to filter gte,lte date on datetime field?
I'm trying to figure out how to filter QuerySet using date extracted from datetime. I use Django-filter and I can't compose such lookup without iterating over QuerySet which is very uneffective. I tried datetime__date__gte which doesn't work. class MyReservationsFilter(FilterSet): datetime__lte = DateFilter(method='datetime_filter',name='lte') class Meta: model = Reservation fields = {'status': ['exact'], # 'datetime': ['lte', 'gte'], 'destination_from': ['exact'], 'destination_to': ['exact'],} def datetime_filter(self, queryset, name, value): lookup = 'datetime__'+name return queryset.filter(**{lookup:value}) Do you know what to do? -
Create disk snapshot using google cloud python api client
I'm trying to create a disk snapshot using python api client of google cloud platform, Heres what's I have tried: From views.py if request.method == 'POST': form = forms.SnapshotForm(request.POST) if form.is_valid(): obj = snapy() obj.project = form.cleaned_data['project'] obj.instance = form.cleaned_data['instance'] obj.zone = form.cleaned_data['zone'] obj.snapshot = form.cleaned_data['snap_name'] # Google Cloud stuff for Snapshot service = discovery.build('compute', 'v1', credentials=credentials) project_id = obj.project zone = obj.zone disk = obj.instance snapshot_body = {} request = service.disks().createSnapshot(project=project_id, zone=zone, disk=disk, body=snapshot_body) response = request.execute() pprint(response) obj.save() print(obj) return HttpResponse('Good', status=200) It returns no error but snapshot not created on gcp console. Is there something wrong I have configured? help me, please! Here's the response: [10/Sep/2017 08:09:46] "GET /snap/ HTTP/1.1" 200 2740 {'id': '8462873153659819689', 'insertTime': '2017-09-13T01:11:51.025-07:00', 'kind': 'compute#operation', 'name': 'operation-1505290310763-5590db641c1f8-9be2938e-9e1b974f', 'operationType': 'createSnapshot', 'progress': 0, 'selfLink': 'https://www.googleapis.com/compute/v1/projects/istiodep/zones/asia-northeast1-c/operations/operation-1505290310763-5590db641c1f8-9be2938e-9e1b974f', 'status': 'PENDING', 'targetId': '1514253394633906452', 'targetLink': 'https://www.googleapis.com/compute/v1/projects/istiodep/zones/asia-northeast1-c/disks/instance-1', 'user': 'saqib.rasool@seecs.edu.pk', 'zone': 'https://www.googleapis.com/compute/v1/projects/istiodep/zones/asia-northeast1-c' } Snapshot object -
redirect user after update in class based view in django
I'm using Django 1.11. I'm using Class based view for update profile page, to updated auth user profile info. myapp/accounts/views.py class UpdateProfile(UpdateView): model = User fields = ['first_name', 'last_name'] template_name = 'accounts/update.html' def __init__(self, **kwargs): super().__init__(**kwargs) self.request = None def get_object(self, queryset=None): return self.request.user This works fine for updating profile. But after update, it gives error No URL to redirect to. Either provide a url or define a get_absolute_url method on the Model. I followed some YouTube tutorials here which is using method based view and form.py to generate form, There I can check for request method and call form.save() and then redirect user to profile page (probably index). 1. How can I do I check if data updated and then redirect user to index class in my class? 2. Is this method suitable for editing data using pk? I also want to generate flash message after updation for which I can use messages.success(request, "Profile updated") 3. Since class is not have request object, how to use messages in class based view? -
$ manage.py runserver /system/bin/sh: manage.py: not found
I would be away from a computer (pc) for a while but I have a project on my neck so I got qpython. I installed Django successfully but after creating a project when I $ manage.py runserver /system/bin/sh: manage.py: not found Though Django-admin runserver doesn't work... It tells something about DJANGO_SETTINGS_MODULE Or settings.configure() -
Why are wrong value put into model?
I wanna put list data to upper700&from300to700&under300 of Price model. I wrote fourrows_transpose=list(map(list, zip(*fourrows))) val3 = sheet3.cell_value(rowx=0, colx=9) user3 = Companyransaction.objects.filter(corporation_id=val3).first() if user3: area = Area.objects.filter(name="America").first() pref = Prefecture.objects.create(name="Prefecture", area=area) city = City.objects.create(name="City", prefecture=pref) price_u700 = Price.objects.create(upper700=city.name) price_u700.upper700 = city.name price_u700.save() price_300_700 = Price.objects.create(from300to700=city.name) price_300_700.from300to700 = city.name price_300_700.save() price_u300 = Price.objects.create(under300=city.name) price_u300.under300 = city.name price_u300.save() pref.name = fourrows_transpose[0][0] pref.save() for transpose in fourrows_transpose[2:]: if len(transpose) == 5: if "×" in transpose or "○" in transpose: city.name = "A" city.save() price_u700.name = "○" price_u700.save() price_300_700.name = "○" price_300_700.save() price_u300.name = "○" price_u300.save() Now in upper700&from300to700&under300's column of Price model,Null or "City" is in there.I wanna put "○" to these model. I think why Null is in there is data is put price_u700&price_300_700&price_u300 each one. But I really cannot understand why "City" is in there.How can I fix this?What is wrong?models.py is class Area(models.Model): name = models.CharField(max_length=20, verbose_name='area', null=True) class User(models.Model): user_id = models.CharField(max_length=200,null=True) area = models.ForeignKey('Area',null=True, blank=True) class Prefecture(models.Model): name = models.CharField(max_length=20, verbose_name='prefecture') area = models.ForeignKey('Area', null=True, blank=True) class City(models.Model): name = models.CharField(max_length=20, verbose_name='city') prefecture = models.ForeignKey('Prefecture', null=True, blank=True) class Price(models.Model): upper700 = models.CharField(max_length=20, verbose_name='u1000', null=True) from300to700 = models.CharField(max_length=20, verbose_name='500~1000', null=True) under300 = models.CharField(max_length=20, verbose_name='d500', null=True) city = models.ForeignKey('City', null=True, blank=True) -
How to get qery string value in client side after page upload using Django and Python
I need some help. I need to fetch the the query string value from URL in client side i.e-Javascript and that URL is passed from Django template. I am explaining my code below. base.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> {% load static %} <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> </head> <body> <header> <h1>Nuclear Reactor</h1> {% if count > 0 %} <b>Hi, {{ user.username }}</b> <a href="{% url 'home' %}?file=//cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.min.js">Home</a> <a href="{% url 'view_reactor' %}?file=//cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.min.js">View Reactor status</a> <a href="{% url 'logout' %}">logout</a> {% else %} <a href="{% url 'login' %}">login</a> / <a href="{% url 'signup' %}">signup</a> {% endif %} <hr> </header> <main> {% block content %} {% endblock %} </main> </body> </html> Here I am passing some query string value for home.html loading. home.html: {% extends 'base.html' %} {% block content %} <center><h1>Welcome</h1> <p>This App allow to control the life cycle of the Nuclear Reactor and Retrive the status report </p> <p><a href="{% url 'status' %}">Status report</a><a href="{% url 'control' %}">Control panel</a></p> </center> <script type="text/javascript"> window.onload=function(){ } </script> {% endblock %} Here I need after home page rendering that query string value should fetch using Javascript. Please help me. -
if request.method =='POST': is always failing
#Contact.html {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} <div class='row'> <div class ='col-md-4 col-md-offset-4'> <h1> {{title}} </h1> {% if confirm_message %} <p>{{ confirm_message }}</p> {% endif %} {% if form %} <form method='POST' action=''> {% csrf_token %} {{ form.errors }} {{ form.non_field_errors }} {% crispy form %} <input type='submit' value='submit form' class='btn btn-default' /> </form> {% endif %} </div> </div> {% endblock %} # froms.py from django import forms from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit, Layout, Field from crispy_forms.bootstrap import (PrependedText, PrependedAppendedText, FormActions) class contactForm(forms.Form): name = forms.CharField(required = False , max_length =100, help_text="100 characters max ") email= forms.EmailField(required = True) comment = forms.CharField(required =True, widget=forms.Textarea) Server Logs System check identified no issues (0 silenced). September 13, 2017 - 07:38:19 Django version 1.11.5, using settings 'app3.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. GET hello from not valid [13/Sep/2017 07:38:23] "GET /contact/ HTTP/1.1" 200 5413 [13/Sep/2017 07:42:20] "GET / HTTP/1.1" 200 4356 [13/Sep/2017 07:42:27] "GET /about/ HTTP/1.1" 200 3985 GET hello from not valid [13/Sep/2017 07:42:37] "GET /contact/ HTTP/1.1" 200 5413 The request never becomes post. When I hit submit on the form it never shows up as post request. … -
A FastCGI error 0x8007010b about django1.11 on IIS7
I deploy the web services,following this, www.kronoskoders.logdown.com,but there is an error about FastCGI in the end ,and I am sure that my webproject code has no error.Does anyone know how to solve this error? Thank you for your help!!! ps I use the windows service r2 2012+django 1.11+IIS7+pyhon3.6 enter image description here