Most answered questions in Python

0 votes
1 answer

How to read an excel file (name User defined) from a path using python?

Hi @There, As the path is fixed, use ...READ MORE

Aug 13, 2020 in Python by Gitika
• 65,910 points
4,735 views
0 votes
1 answer

ValueError: too many values to unpack (expected 3)

Hello @Alisha , Do print(func(x)) and find out what's ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
5,395 views
0 votes
1 answer

How to remove all of the data in a table using Django?

Hello @kartik, Inside a manager: def delete_everything(self): ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
3,819 views
0 votes
1 answer

How can I send trace messages to the console (like print) when I'm running my Django app under manage.py runserver?

Hello @kartik, Text printed to stderr will show ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
2,633 views
0 votes
1 answer

Error:'QuerySet' object has no attribute 'remove'

Hello @kartik, You could do this: import itertools ids = ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
5,919 views
0 votes
1 answer

Error:Django connection to PostgreSQL: “Peer authentication failed”

Hello @kartik, My settings.py did not have a ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
1,845 views
0 votes
1 answer

How can I set Django Cookies?

Hello @kartik, This is a helper to set ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
525 views
+1 vote
1 answer

How to get the currently logged in user's user id in Django?

Hello @kartik, First make sure you have SessionMiddleware and AuthenticationMiddleware middlewares added ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
36,061 views
0 votes
1 answer

How to get Request.User in Django-Rest-Framework serializer?

Hello @kartik, You cannot access the request.user directly. You need ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
12,988 views
0 votes
1 answer

How do I migrate a model out of one django app and into a new one?

Hello @kartik, Try this: from south.db import db from south.v2 ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
632 views
0 votes
1 answer

How to redirect to named url pattern directly from urls.py in django?

Hello @kartik, You can try this: from django.views.generic import ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
2,389 views
0 votes
1 answer

How to manage development and production settings in django?

Hello @kartik, I usually have one settings file ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
1,143 views
0 votes
1 answer

'tuple' object is not callable

Hey, @There, This kind of error happens once ...READ MORE

Aug 13, 2020 in Python by Rajiv
• 8,910 points
2,023 views
0 votes
1 answer

While working on VIF in multiple regression I came across this problem

Hello, @Pawan, The as_matrix method is deprecated since 0.23.0, so ...READ MORE

Aug 11, 2020 in Python by Dhiman
974 views
0 votes
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi@Nilesh, You have created two empty lists. And ...READ MORE

Aug 11, 2020 in Python by MD
• 95,440 points
6,132 views
0 votes
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi@Nilesh, You created two empty lists. And in ...READ MORE

Aug 11, 2020 in Python by MD
• 95,440 points
2,973 views
+1 vote
1 answer

Web Scraping with Python:-> ModuleNotFoundError: no module named 'selenium'

Hello @shamsher, First try to check what version ...READ MORE

Aug 10, 2020 in Python by Niroj
• 82,880 points
3,871 views
0 votes
1 answer

IndentationError: expected an indented block

Hello @ nishit, Indentation means the space from margin to ...READ MORE

Aug 10, 2020 in Python by Niroj
• 82,880 points
5,498 views
0 votes
1 answer
0 votes
1 answer

How to check permission inside a template in Django?

Hello @kartik, To check for permissions in templates, ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
4,379 views
0 votes
1 answer

How can I find the union of two Django querysets?

Hello @kartik, Try this: records = query1 | query2 If ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
2,128 views
0 votes
1 answer

How to clear a database from the CLI with manage.py in Django?

Hello @kartik, To drop the database and run syncdb again. ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
2,471 views
0 votes
1 answer

How to drop all tables from the database with manage.py CLI in Django?

Hello @kartik, Python you can write your own ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
7,328 views
0 votes
1 answer

How can I generating file to download with Django?

Hello @kartik, To trigger a download you need ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
5,199 views
0 votes
1 answer

How to compare two JSON objects with the same elements in a different order equal?

Hello @kartik, If you want two objects with ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
9,325 views
0 votes
1 answer

How to change the default Django date template format?

Hello @kartik, Within your template, you can use ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
4,137 views
0 votes
1 answer

ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

Hello @kartik, The following code works: >>> from django.template ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
881 views
0 votes
1 answer

Error:AttributeError: 'module' object has no attribute 'tests'

Hello @kartik, The problem was that test couldn't find ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
11,705 views
0 votes
1 answer

Django object is not JSON serializable

Hello @kartik, simplejson and json don't work with django objects well. Django's ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
26,773 views
–1 vote
1 answer

How to get the current URL within a Django template?

Hello @kartik, You can fetch the URL in ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
8,075 views
0 votes
1 answer

Why does DEBUG=False setting make my django Static Files Access fail?

Hello @kartik, If you still need to server ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
5,498 views
0 votes
1 answer

Where can I find the error logs of nginx, using FastCGI and Django?

Hello @kartik, Errors are stored in the nginx ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
1,002 views
0 votes
1 answer

How can I get the absolute URL (with domain) in Django?

Hello @kartik, Use handy request.build_absolute_uri() method on request, pass it ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
9,851 views
0 votes
1 answer

How do I make a field readonly (or disabled) so that it cannot be edited in Django form?

Hello @kartik, Setting readonly on a widget only makes the ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
15,993 views
0 votes
1 answer

How to Creat a JSON response using Django and Python?

Hello @kartik, I usually use a dictionary, not ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
2,946 views
0 votes
1 answer

How to reset Django admin password?

Hello @kartik, Just try this: python manage.py changepassword <user_name> Hope ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
3,619 views
0 votes
1 answer

How to Filter for empty or NULL names in a queryset?

Hello @kartik, You could do this: Name.objects.exclude(alias__isnull=True) If you need ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
4,730 views
0 votes
1 answer

How to debug in Django code?

Hello @kartik, There are a bunch of ways ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
817 views
0 votes
1 answer

How can I upgrade specific packages using pip and a requirements file?

Hello @kartik, According to pip documentation example 3: pip install --upgrade ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
936 views
0 votes
1 answer

How to capture URL parameters in request.GET

Hello @kartik, When a URL is like domain/search/?q=haha, you ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
2,004 views
0 votes
1 answer

Error:Traceback (most recent call last): File "< stdin >", line 1, in ImportError: cannot import name 'path'

Hello @kartik, You need Django version 2 pip install ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
6,433 views
0 votes
1 answer

How to parse `request.body` from POST in Django?

Hello @kartik, In Python 3.0 to Python 3.5.x, json.loads() will ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
27,729 views
0 votes
1 answer

Error:“Unknown command syncdb” running “python manage.py syncdb”

Hello @kartik, $python manage.py syncdb is deprecated and not ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
3,875 views
0 votes
1 answer

ImportError: cannot import name 'six' from 'django.utils' (/path-to-project/project/niroj/lib/python3.7/site-packages/django/utils/init.py)

Hello @kartik, Upgrading the packages will resolve the ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
11,557 views
0 votes
1 answer

How to create a generic serializer with a dynamic model in Meta?

Hello @kartik, You can do that by following: serializers.py class ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
3,169 views
0 votes
1 answer

ImportError: cannot import name find_spec” when I start a new Django project?

Hello @kartik, find_spec isn't available in Python 3.2.3; it ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
2,081 views
0 votes
1 answer

Error: No module named 'django.core.urlresolvers'

Hello @kartik, If you want to import reverse, ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
8,848 views
0 votes
1 answer

How to extract specific tags in multiple html .txt files using python.

Hello, @Pooja, Even I got the same issue, ...READ MORE

Aug 5, 2020 in Python by Kedaar Thomas
4,667 views
0 votes
1 answer

I tried to install this pip cryptography in Pycharm but I'm getting an error

Hello @Dilpreet , Have you tried updating pip version? ...READ MORE

Aug 4, 2020 in Python by Niroj
• 82,880 points
2,990 views
0 votes
1 answer

How to concatenate strings in django templates?

Hello @kartik, Don't use add for strings, you should define ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,880 points
10,909 views