Latest questions in Python

0 votes
1 answer

How to debug Django commands in PyCharm?

Hello @kartik, You can debug a custom Django ...READ MORE

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

How to create a user in Django?

Hello @kartik, The correct way to create a ...READ MORE

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

How to configure where to redirect after a log out in Django?

Hello @kartik, You don't need to overwrite or ...READ MORE

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

How to reverse a string in Python using slicing operator?

Hi@akhtar, Strings can be reversed using slicing. To ...READ MORE

Aug 17, 2020 in Python by MD
• 95,440 points
3,348 views
0 votes
1 answer

How to load python script in Jupyter Notebook?

Hi@akhtar, Starting from IPython 3 (now Jupyter project), ...READ MORE

Aug 17, 2020 in Python by MD
• 95,440 points
14,481 views
0 votes
1 answer

How to import a folder in Jupyter Notebook?

Hi@akhtar, There is no simple way to import ...READ MORE

Aug 17, 2020 in Python by MD
• 95,440 points
22,382 views
0 votes
0 answers

How to draw nested squares to create pursuit curves?

Draw nested squares to create pursuit curves. ...READ MORE

Aug 16, 2020 in Python by Andwela
• 120 points
1,527 views
0 votes
1 answer

Error:“CSRF token missing or incorrect” while post parameter via AJAX in Django

Hello @kartik, The simplest way to include the {{csrf_token}} value ...READ MORE

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

In Django Admin how do I disable the Delete link?

Hello @kartik, Simple you can use this code: class ...READ MORE

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

How to filter my model on the basis of text length in django?

Hello @kartik, For Django >= 1.8 you can ...READ MORE

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

How do I use the built in password reset/change views with my own templates?

Hello @kartik, You'll notice that password_reset takes a named parameter ...READ MORE

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

How to expire session due to inactivity in Django?

Hello @kartik, Expire the session on browser close ...READ MORE

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

How can I have Multiple Models in a single django ModelForm?

Hello @kartik, You can just show both forms ...READ MORE

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

How to inject errors into already validated form?

Hello @kartik, For Django 1.7+, you should use form.add_error() instead ...READ MORE

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

How to send a correct authorization header for basic authentication

Hello @kartik, Here is how to do Basic ...READ MORE

Aug 13, 2020 in Python by Niroj
• 82,880 points
8,153 views
0 votes
0 answers

How can I add indexes of similar values from two .csv to each of them?

So I have two csv files: csv1.csv: 2010-12-10, Steve, ...READ MORE

Aug 13, 2020 in Python by Alex
• 120 points
479 views
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,393 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,918 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,058 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
631 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,388 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
973 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,131 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,378 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,126 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,469 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,323 views
0 votes
0 answers

Python Online Training

learn python at H2K Infosys and master ...READ MORE

Aug 7, 2020 in Python by swapna
• 120 points
1 flag 347 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,198 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,324 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,135 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,772 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,497 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