Category "django"

Django HTML form: how can I only populate a field value if it exists?

My Django application has a Person model with some optional text fields, such as: nickname = models.CharField(max_length=20, null=True, blank=True, default='')

Django testing rest-framework: APIRequestFactory vs APIClient

Being new to testing i'm looking to test my API in Django (Django-rest-framework). I'm setting up tests for my views, that is my API endpoints. Now looking ov

vuejs 401 unauthorized with axios from django backend with token

im trying to fetch data from django rest backend with axios in vuejs frontend but each time i get this error. the tokens match but it is still not authorizing.

Problem with redirecting in a Django HTML file

I am building a personal website and I am getting an error whenever I click on the the redirect link and I am quite puzzled how to proceed. I am also including

Separate Datetime field to show Date and Time separate in HTML using Django

I am using Python 3.6 and Django as web framework I have to save datetime together in my database but show date and time separate field in HTML. Model Code: cl

Only homepage url is working in django app. Other urls are not working

My Django app is working on shared Linux hosting but only homepage is working. When I try to access other pages 404 error occurs. I believe urls.py is causing p

custom django-user object has no attribute 'has_module_perms'

My custom user model for login via email: class MyUser(AbstractBaseUser): id = models.AutoField(primary_key=True) # AutoField? is_superuser = models.I

How do you add primary keys in a Django URL?

I am making a blog and I want to go to a specific blog post by clicking on a button. I know I need to use a primary key in the URL, but what is the syntax? And

A Django query to find top 3 posts with maximum comments

how can i find the top 3 blogpost with the maximum comments here are my models: class BlogPost(models.Model): title = models.CharField(max_length=250)

"Expected a string value" on login using Django REST and pyjwt

So, I'm trying to build simple register and login functionalities into my API. I can register just fine, but when I insert the user details on the login API vie

Error message "`coreapi` must be installed for schema support"

I am trying to generate Swagger documentation using drf_yasg and it was working fine, but now it’s not. It’s giving me an error and I can not find a

Tweeter Oauth:You are authenticated as XXX, but are not authorized to access this page. Would you like to login to a different account?

I have created just a simple django app to login using tweeter, but when i try to login from my app I get this message "You are authenticated as xxx, but are no

Celery No hostname was supplied. Reverting to default 'localhost'

I have this in my /var/log/celery/w1.log I'm following the steps for Celery here. I have this in my celery.py from __future__ import absolute_import, unicode_l

How to add data to ManyToMany field using Django Rest Framework?

I'm relatively new to DJango and I am looking to add data to a many-to-many field using serializers from rest framework. My Model: class IngFamily(models.Mode

How to debug Django custom management command using VS Code

I am trying to debug a custom management command using Visual Studio Code. For this I have gone through the official VS Code tutorials for working with Python

How do I use django rest framework to send a file in response?

I need to send a pdf file and some other parameters in response to a get API call using django rest framework. How can I do it? I tried this but it gives an er

OperationalError in Django app: models.py

There's an OperationalError in my models.py code. Can anyone pinpoint the problem? I have tried deleting the cache (along with previous migrations) and doing th

How can I make a Django REST framework /me/ call?

Suppose I have a ViewSet: class ProfileViewSet(viewsets.ModelViewSet): """ API endpoint that allows a user's profile to be viewed or edited. """

AssertionError: database connection isn't set to UTC

I have done server setup multiple times with the same settings but this time, I am seeing the error message. It is not even allowing to migrate the database. Sy

Django ModelTranslation

Hello guys i need a help for translating models values. I use django-modeltranslation package. I have managed to register my models. class Institution(models.Mo