Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
TypeError at /app/^detail/(?P1[0-9]+)/$ detail() got an unexpected keyword argument 'pk'
I got an error, TypeError at /app/^detail/(?P1[0-9]+)/$ detail() got an unexpected keyword argument 'pk' . I wrote urls.py urlpatterns = [ path('top/', views.top, name='top'), path(r'^detail/(?P<pk>[0-9]+)/$',views.detail , name='detail'), ] in views.py def top(request): content = POST.objects.order_by('-created_at') page = _get_page(blog_content, request.GET.get('page')) return render(request, 'top.html',{'content':content,"page":page}) def detail(request): content = POST.objects.order_by('-created_at') return render(request, 'detail.html',{'content':content}) in top.html <div> {% for content in page %} <div> <h2>{{ content.title }}</h2> </div> {% endfor %} </div> <div> {% for content in page %} <h2>{{ content.title }}</h2> <p><a href="{% url 'detail' content.pk %}">SHOW DETAIL</a></p> {% endfor %} </div> When I put "SHOW DETAIL" button, this error happens.I really cannot understand why I can't access pk. pk is default value, so I think I can access it from everywhere.I wanna make a system when I put "SHOW DETAIL button",content's detail is shown.What is wrong in my code?How should I fix this?Am I wrong to write url?Or is this error's meaning I should write pk in detail method? -
Unable to use '#' as broker url in celery django
app = Celery('myapp', broker='amqp://user:pass#1@localhost:5672//', backend='rpc://', include=['myapp.tasks']) I get this error ValueError: invalid literal for int() with base 10: 'pass' This code doesn't work, I'm new to python and Django is there an escape sequence for it? Iv tried u"", r"" ,'#' , '##' and '#' , hoping it will escape it but it doesnt. -
How to prefill admin form items (from many-to-many relationship) in Django
I'm looking for a way to prefill items in an admin form (or form view). I took a look on get_changeform_initial_data but if I can prefill simple values, I didn't find any way to send multiple items correctly (I mean with many-to-many relationship). I know that you cannot link object if you don't already have primary key of the parent one but I want to have partial data and send them (like Django admin form does). The aim is to prefill usual sold items in an invoice (but still allow to check and update them before creation). I'm open if you have any idea. I will perhaps try to achieve this in Javascript but want to know there is a correct way in Django. -
module 'txaio' has no attribute 'make_batched_timer'
I am folowing this tutorial enter link description here But I am getting "C:\Program Files\JetBrains\PyCharm 2017.3.1\bin\runnerw.exe" C:\Users\srawa\AppData\Local\Programs\Python\Python36\python.exe C:/Users/srawa/OneDrive/django-practice/example_channel/manage.py runserver 8000 Performing system checks... System check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. January 01, 2018 - 20:07:53 Django version 1.9.3, using settings 'example_channel.settings' Starting Channels development server at http://127.0.0.1:8000/ Channel layer default (asgi_redis.RedisChannelLayer) Quit the server with CTRL-BREAK. Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000221817F76A8> Traceback (most recent call last): File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\channels\management\commands\runserver.py", line 81, in inner_run action_logger=self.log_action, File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\daphne\server.py", line 19, in run self.factory = HTTPFactory(self.channel_layer, self.action_logger) File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\daphne\http_protocol.py", line 188, in __init__ self.ws_factory = WebSocketFactory(self) File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\daphne\ws_protocol.py", line 123, in __init__ WebSocketServerFactory.__init__(self, *args, **kwargs) File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\autobahn\twisted\websocket.py", line 255, in __init__ protocol.WebSocketServerFactory.__init__(self, *args, **kwargs) File "C:\Users\srawa\AppData\Local\Programs\Python\Python36\lib\site-packages\autobahn\websocket\protocol.py", line 3096, in __init__ self._batched_timer = txaio.make_batched_timer( AttributeError: module 'txaio' has no attribute 'make_batched_timer' What is the problem? -
how to post multiple model data through one serializer in django rest api
I have a two model contact and user class Contact(models.Model): name = models.CharField(max_length=50, blank=True) status = models.BooleanField(default=False) class User(models.Model): username = models.CharField(max_length=50, blank=True) password = models.CharField(max_length=50, blank=True) contact_id = models.ForeignKey(Contact, on_delete=models.CASCADE, blank=True, null=True) For these two model I have two serializer class class ContactSerializerModel(serializers.ModelSerializer): class Meta: model = Contact fields = ('name', 'status') class UserSerializerModel(serializers.ModelSerializer): class Meta: model = User fields = ('username', 'password','contact_id') Now I want to design a serializer class which take name, username, password, status field. I want to post as key value pair. First name and status value save in the Contact model then with contact model id save username and password in user table. How to design the serializer class in Django rest API? -
How to serve angular and django ? Seperately or from django server?
I'm new to angular. I just created api using django rest framework. Now, I want angular to use as frontend. Created angular components and stuff, but I got stuck in whether serving different server or from django. Researched and got me to serve from django itself. But how to handle the angular routes with django? Also should I use django view context data (django templates) with angular or use all the api data only using angular? -
what is difference between {{}} and {% %} in django templates
I am very new to django and working on it.. I visited a html file and dont know the difference between {{}} and {% %} in html files used as here {% load static %} Thanks a lot -
Identify ImageField through introspection
OK, I understand that ImageField cannot be identified using get_internal_type() (see here). Applied on a field of type ImageField returns FileField which is the superclass of ImageField. How can I then distinguish ImageField from FileField through introspection? I need such a solution in order to apply a generic functionality to arbitrary models. -
NoReverseMatch at /<url> When rendering form
I am relatively new to Django and am trying to insert data into a table using Django form but am stuck at this error: NoReverseMatch at /vinesF/NewVid Reverse for 'NewVid' not found. 'NewVid' is not a valid view function or pattern name. Here are my view, url and html, any help is appreciated def NewVid(request): if request.POST: form= AddVidForm(request.POST) if form.is_valid(): primaryName= form.cleaned_data['primaryName'] Origin= form.cleaned_data['Origin'] PreferredAudience= form.cleaned_data['PreferredAudience'] Date= form.cleaned_data['Date'] Link= form.cleaned_data['Link'] VPath= form.cleaned_data['VPath'] AddPath= form.cleaned_data['AddPath'] FreshVid= video(primaryName=primaryName, Origin=Origin, PreferredAudience=PreferredAudience, Date=Date,Link=Link, VPath=VPath, AddPath=AddPath) FreshVid.save() return HttpResponse("New Video added") else: return render(request,'vine/Newvid.html', {form:'form'}) else: form= AddVidForm() return render(request,'vine/Newvid.html', {form:'form'}) HTML Code <form method="post" action="{% url 'NewVid' %}" > {% csrf_token %} <!-- This line inserts a CSRF token. --> <table> {{ form.as_table }} <!-- This line displays lines of the form.--> </table> <p><input type="submit" value="Create" /></p> </form> {% endblock %} Here's the url handler: app_name ='vinesF' urlpatterns = [ url(r'^NewVid$',views.NewVid, name='NewVid'), ] -
Images cannot be shown in html
Images cannot be shown in html.I wrote codes in models.py class POST(models.Model): title = models.CharField(max_length=100) image = models.ImageField(upload_to='images/', blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) in views.py def top(request): content = POST.objects.order_by('-created_at')[:5] return render(request, 'top.html',{'content':content}) in top.html <div> {% for item in content %} <div> <h2>{{ item.title }}</h2> <img src="{{ item.image }}"/> </div> {% endfor %} </div> When I access in browser, html is shown.<h2>{{ item.title }}</h2> is shown but <img src="{{ item.image }}"/> is not there.When I see page source in GoogleChrome,<img src="/images/photo.jpg"/> is shown. But when I click the url,404 error happens.My application has image/images folder, in images folder surely my uploaded picture is in there.I really cannot understand why this happens.I wrote MEDIA_ROOT&MEDIA_URL in settings.py so I think image is shown in browser. How should I fix this? -
Django UserCreationForm custom fields
I am trying to create form for user registration and add some custom fields. For doing that, I've subclassed UserCretionForm and added fields as shown in django documentation. Then I've created function-based view and template based on this form. Now, I can successfully create user and this user is added to admin panel as expected. Problem is that, I can't add class and style for this form's fields. Widgets are not working except for username field. I'm adding my scripts here for illustrating my problem more accurately: forms.py from django import forms from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from django.contrib.auth.models import User class SignUpForm(UserCreationForm): first_name = forms.CharField(max_length=32, help_text='First name') last_name = forms.CharField(max_length=32, help_text='Last name') email = forms.EmailField(max_length=64, help_text='Enter a valid email address') class Meta(UserCreationForm.Meta): model = User # I've tried both of these 'fields' declaration, result is the same # fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2', ) fields = UserCreationForm.Meta.fields + ('first_name', 'last_name', 'email',) widgets = { 'username': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Username'}), 'first_name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'First Name'}), 'last_name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Last Name'}), 'email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': 'Email'}), 'password1': forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Password'}), 'password2': forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Password Again'}), } views.py from django.contrib.auth import login, authenticate from django.contrib.auth.views … -
perform raw SQL in django
In our project I am going to create a page with a textbox where we type raw SQL code and I want this code run and returns result to me and show it below the code. As I do not have much experience I would be grateful if someone tells me how to do that exactly. -
Django - PostgresSql and Sequences
We are using Python 3.5, Django 1.10 and PostgreSql 9.6 DB We needed some Auto-increment field for one of the object (Item), and couldn't achieve that using DB auto increment, since there is another dependency for the incrementation. The field should be incremented for Item per Project (each Project can contain multiple items). We decided to use django-sequences package that basically creates another table (we're using the same DB as our models), and increments the field whenever asked to by locking the DB and increment the highest value according to relevant parameter (in our case the Project id). Seems like it works. The problem occurs when there are multiple requests in parallel. Seems like the DB gets locked and we're starting to get 504 after few requests. Any idea on why it happens and what could solve that? This is the django-sequences use: if instance.identifier < 0: with transaction.atomic(): instance.identifier = get_next_value( 'project__' + str(instance.project.id) + '__item__identifier', initial_value=1, nowait=False ) -
Django puts my password in browser url field
I have the following view class: class LoginView(View): form_class = LoginForm template_name = 'workoutcal/login.html' def post(self, request): form = self.form_class(request.POST) if form.is_valid(): email = form.cleaned_data['email'] password = form.cleaned_data['password'] user = authenticate(email = email, password = password) if user is not None: if user.is_active: login(request, user) return calendar(request) else: return render(request, self.template_name, {'form':form}) else: form['custom_error_message'] = 'Invalid user' return render(request, self.template_name, {'form':form}) def get(self, request): form = self.form_class(None) return render(request, self.template_name, {'form':form}) And this template: login.html {% extends "workout/base.html" %} {% block logoutwidget %}{% endblock %} {% block content %} <form action="/workoutcal/login/"> {% include "workoutcal/form_disp_errors.html" %} <input type="submit" value="Log in"> </form> {% endblock %} form_disp_errors.html {% csrf_token %} {{ form.custom_error_message }} {{ form.non_field_errors }} {% for field in form.visible_fields %} <div class="row"> <div class="col-xs-2"> {{ field.label_tag }} </div> <div class="col-xs-2"> {{ field }} </div> <div class="col-xs-3"> {{ field.errors }} </div> </div> {% endfor %} When I go to workoutcal/login, type in an incorrect username and password (user doesn't exist), the page goes to workoutcal/login again, but with this url: http://localhost:8000/workoutcal/login/?csrfmiddlewaretoken=ZywQUh7gnNfaHi8FcA3be4ynLB7SpGgwdJ0UxGzUuRYp0G0Y9LQ9e24Jx8Q1OD3Y&email=myemail%40hotmail.com&password=MYPASSWORD As you can see in the end of the link, the password is displayed. This is obviously not good. However, I can't understand why it happens. Any ideas? -
Django Facebook APP
I am a newbie in Django .I wish to develop a Django application that can post an app result to Facebook. I want to get the likes and shares that the post get. I am developing the app in Django Version 1.11, using Python 3.4 and database MySQL(mysqlclient). Please share some document that is not outdated or guide me with steps. Thanks -
Django Wagtail Menus not showing all menu items
I am using wagtail cms for making my blog. So I have installed wagtail menus inside my django project. I followed the official documentation for creating a top level menu but it showing the single item which I created in wagtail admin. Settings.py INSTALLED_APPS = [ 'bootstrap3', 'blog', 'home', 'search', 'wagtail.wagtailforms', 'wagtail.wagtailredirects', 'wagtail.wagtailembeds', 'wagtail.wagtailsites', 'wagtail.wagtailusers', 'wagtail.wagtailsnippets', 'wagtail.wagtaildocs', 'wagtail.wagtailimages', 'wagtail.wagtailsearch', 'wagtail.wagtailadmin', 'wagtail.wagtailcore', 'wagtail.contrib.modeladmin', # Don't repeat if it's there already 'wagtailmenus', 'modelcluster', 'taggit', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] Middleware: MIDDLEWARE = [ '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', 'django.middleware.security.SecurityMiddleware', 'wagtail.wagtailcore.middleware.SiteMiddleware', 'wagtail.wagtailredirects.middleware.RedirectMiddleware', ] contextprocessors: 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'wagtail.contrib.settings.context_processors.settings', 'wagtailmenus.context_processors.wagtailmenus', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.tz', ], I included this code in base.html to include the mainmenu. {% wagtailuserbar %} {% load menu_tags %} {% main_menu max_levels=3 show_multiple_levels=True apply_active_classes=True %} Then I created 3 pages in admin and tried to link the menus.The main and the flat menu option is there for creating the menu.I used main menu and created some menu items using the pages I created but I am getting only Home menu which I created the first.The other menu items are not visible. -
Django default model field value
suppose I have a Django object of this type: class Some(Model): some_value = CharField(max_length=20) and after a while (and a few objects later) I understood I'd like to save the created time for each new object, so I add the following field: created = FloatField(default=time.time) Let's suppose now I have a few old object which were created without the "created" field. When I query them, they receive the default time.time, even though it's suppose to be None. How can I get a different value for all the old objects? I only want new objects to be created with this default, and say all old objects without this field to be None, or some other known value. Setting null=True doesn't make a difference. Thanks! -
I tried in different ways to update row through Django views but it's not working
I want to assign a variable from outside query to password in update query. Is it possible to assign otpgen to password? otpgen="123221" conn=sqlite3.connect(path) cursor=conn.cursor() cursor.execute("UPDATE user SET password=12 WHERE email = %s", [email]) -
Call post_save after many to many fields are saved in database
I have model class UserPermission(models.Model): user = models.OneToOneField(User) user_type = models.ManyToManyField(UserType) persona = models.ManyToManyField(Persona) And post save signal @receiver(post_save, sender=UserPermission) def post_save_user_permissions(sender, instance, **kwargs) """ Depending on selected UserType and Persona for a user, Update some other model """ pass I want all updated values of both the m2m fields in post save signal. but issue here is post save signal is getting called before m2m fields saved into db. I could have used m2m_changed signal, but there are two m2m fields and I can't associate or link these two signals Is there anyway to call post_save once all m2m fields in model are saved into db. -
Paginator does not work
Paginator does not work.I wrote views.py from .models import POST from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.shortcuts import render def top(request): item = POST.objects.order_by('-created_at') page = _get_page(item, request.GET.get('page')) return render(request, 'top.html',{'item':item,"page":page}) def _get_page(list_, page_no, count=1): paginator = Paginator(list_, count) try: page = paginator.page(page_no) except (EmptyPage, PageNotAnInteger): page = paginator.page(1) return page in top.html <div> {% for i in item %} <div> <h2>{{ i.title }}</h2> <p>{{ i.index }}</p> </div> {% endfor %} </div> <div> {% if page.has_previous %} <a href="?page={{ page.previous_page_number }}">Previous</a> {% endif %} {% for num in page.paginator.page_range %} {% if page.number == num %} <span>{{ num }}</span> {% else %} <a href="?page={{ num }}">{{ num }}</a> {% endif %} {% endfor %} {% if page.has_next %} <a href="?page={{ page.next_page_number }}">Next</a> {% endif %} </div> When I access top.html,all item is shown in browser.I think I wrote one item was shown in one page(browser) in this part page = paginator.page(page_no) ,but no error happens so I really cannot understand what is wrong.How should I fix this? -
extending a url to another in django
I have a django application where by I can create a category and from the category I can select a subcategory before selecting a post. I have also created slugs for both the category , subcategory and the post and this works fine. what I now want to do but could not achieve is to make the subcategory slug continous on d product that is if the slug is http://127.0.0.1:8000/house/ before clicking on a post, I want the url to look like this after clicking on a post under house http://127.0.0.1:8000/house/duplex. below is my model for my sub category Models.py class SubCategory(models.Model): category = models.ForeignKey(Category, related_name='property', on_delete=models.CASCADE) name = models.CharField(max_length=400,db_index=True) slug = models.SlugField(max_length=400,db_index=True, unique=True) class Meta: ordering = ('name',) verbose_name = 'subcategory' verbose_name_plural = 'subcategories' def __str__(self): return self.name def get_absolute_url(self): return reverse('subcategory:property_list_by_subcategory', args=[self.slug]) View def index(request, subcategory_slug=None, category_slug=None): subcategory = None subcategories = SubCategory.objects.all() properties = Property.objects.filter(available=True) if subcategory_slug: subcategory = get_object_or_404(SubCategory, slug=subcategory_slug) properties = properties.filter(subcategory=subcategory)HttpResponseRedirect(reverse('category:property_list_by_category')) context = { 'subcategory': subcategory, 'subcategories': subcategories, 'properties': properties } template = 'subcategory/index.html' return render(request, template, context) additional codes would be supplied on request. -
Django-rest-framework multiple url arguments
How do i map the "example object" to the url: website.com/api/<user>/<slug>. I'm getting this invalid literal for int() with base 10: 'username' error. so i understand that i need to use the user id in-order to map to the object, this is because I am able to map to the object if i use the user_id (integer) (url: website.com/api/<user_id>/<slug>) instead of just the user/username (string). Is there a way to override the default when mapping to the object from user_id (integer) to another field like user (string)? Also i don't understand why passing the user instead of user_id in the def get_object in (Api View) does not fix this problem. Url urlpatterns = [ url(r'^api/(?P<user>\w+)/(?P<slug>[\w-]+)/$', ExampleDetailAPIView.as_view(), name='example'), ] Api View class ExampleDetailAPIView(RetrieveAPIView): queryset = Example.objects.all() serializer_class = ExampleDetailSerializer def get_object(self): user = self.kwargs.get('user') slug = self.kwargs.get('slug') return Example.objects.get(user=user, slug=slug) def get_serilizer_context(self, *args, **kwargs): return {'request': self.request} Serializer class ExampleDetailSerializer(HyperlinkedModelSerializer): url = serializers.SerializerMethodField() class Meta: model = Example fields = [ 'url', ] def get_url(self, obj): request = self.context.get('request') return obj.get_api_url(request=request) Model class Example(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1) example_name = models.CharField(max_length=100) slug = models.SlugField(max_length=100, blank=True) class Meta: unique_together = ('user', 'slug') def get_api_url(self, request=None): return api_reverse('example-api:example', kwargs={'user': self.user.username, 'slug': self.slug}, request=request) … -
Use email to login in Django 1.11, I use cookiecutter-django with allauth
I started using cookiecutter-django because it seems so much advanced than just django-admin to start my project. So I created an eCommerce website and it requires only email to log in not the username. So, I tried to follow the docs and changes my settings.py like this: ACCOUNT_USER_MODEL_USERNAME_FIELD = None ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_VERIFICATION = 'mandatory' AUTH_USER_MODEL = 'accounts.User' LOGIN_REDIRECT_URL = 'users:redirect' LOGIN_URL = 'account_login' Here is my accounts.User model: from django.db import models from django.contrib.auth.models import ( AbstractBaseUser, BaseUserManager ) class UserManager(BaseUserManager): def create_user(self, email, full_name, password=None, is_active=True, is_staff=False, is_admin=False): if not email: raise ValueError("Users must have an email address") if not password: raise ValueError("Users must have a password") if not full_name: raise ValueError("Users must have a fullname") user_obj = self.model( email = self.normalize_email(email), full_name = full_name ) user_obj.set_password(password) user_obj.staff = is_staff user_obj.admin = is_admin user_obj.active = is_active user_obj.save(using=self._db) return user_obj def create_staffuser(self, email, full_name, password=None): user = self.create_user( email, full_name, password=password, is_staff=True ) return user def create_superuser(self, email, full_name, password=None): user = self.create_user( email, full_name, password=password, is_staff=True, is_admin=True ) return user class User(AbstractBaseUser): email = models.EmailField(max_length=255, unique=True) full_name = models.CharField(max_length=255, blank=True, null=True) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) USERNAME_FIELD … -
Nginx requested headers are not getting set in django response headers
project environment details are - angular2 :frontend - django :webservice api - Proxy webserver: Nginx 1.12.2 - application server : gunicorn My application is deployed in ubuntu vm over azure platform. I am facing problem to get response headers which are being set in request headers. My nginx project config under sites-available is as- server { listen 80; listen [::]:80; listen 443 ssl default_server; listen [::]:443; server_name test-api.mydjangoapp.net www.test-api.mydjangoapp.net; underscores_in_headers on; location = /favicon.ico { access_log off; log_not_found off; } location / { proxy_set_header Host $http_host; proxy_buffering off; 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://unix:/home/puser//run/gunicorn.sock; proxy_redirect off; } } In django settings I have configured 'corsheaders' and allowed headers, CORS_REPLACE_HTTPS_REFERER = True CORS_ALLOW_HEADERS = ( 'accept', 'accept-encoding', 'authorization', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with', 'X-Content-Type-Options', 'X-Frame-Options', 'Access-Control-Allow-Methods', 'Content-Type', 'Access-Control-Allow-Origin', 'Access-Control-Allow-Credentials', 'supports_credentials', 'Access-Control-Allow-Headers', 'nosniff', 'Cache-control', 'no-cache', 'no-store', 'Pragma', 'Expires', 'Set-Cookie', 'X-XSS-Protection', ) CORS_ALLOW_METHODS = ( 'DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT', ) Earlier when I used Azure app service where [webserver- IIS 10 and application server: ufastcgi] all headers were used to set in response. But On nginx it is not working. Current Request and response details are as- Response Headers for POST: Access-Control-Allow-Credentials:true Access-Control-Allow-Origin:http://test-webapp.myangularapp.net Connection:keep-alive Content-Type:application/json Date:Mon, … -
Why google has so many urls in just for search bar page?
While making django bookmark app, I realize that google searchbar page has so many urls. Like, no https://www.google.co.kr, https://www.google.co.kr/?gfe_rd=cr&dcr=0&ei=et5JWq2NNoz02QS3vKH4DA, https://www.google.co.kr/?gfe_rd=cr&dcr=0&ei=jd5JWrCTI4z02QS3vKH4DA It's different at ?gfe_rd=cr&dcr=0&ei=et5JWq2NNoz02QS3vKH4DA and ?gfe_rd=cr&dcr=0&ei=jd5JWrCTI4z02QS3vKH4DA. Questions: Why these are different? Is there good way to determine that 2 urls are pointing the same pages on django server? or using other python packages?