Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django admin show fields from json object
I have a user watch history model which store the movie id from the TMDB database. In the django's admin page I want to show the name of that movie and some other information which will be fetch from TMDB's api in a json from. Something like this. { "backdrop_path": "/yzouMVR7udoScaPDIERkYW5a3vI.jpg", "genres": [ { "id": 12, "name": "Adventure" }, { "id": 35, "name": "Comedy" }, { "id": 18, "name": "Drama" }, { "id": 14, "name": "Fantasy" } ], "id": 116745, "imdb_id": "tt0359950", "original_language": "en", "original_title": "The Secret Life of Walter Mitty", "overview": "A timid magazine photo manager who lives life vicariously through daydreams embarks on a true-life adventure when a negative goes missing.", "popularity": 16.09, "poster_path": "/tY6ypjKOOtujhxiSwTmvA4OZ5IE.jpg", "release_date": "2013-12-18", "runtime": 114, "status": "Released", "title": "The Secret Life of Walter Mitty", "vote_average": 7.1, "vote_count": 5793 } and I am currently showing it like this. @admin.register(History) class HistoryAdmin(admin.ModelAdmin): def movie_details(self, obj): tmdb_obj = TMDB() movie_json = tmdb_obj.fetchMovieById(obj.tmdb_id) return movie_json list_display = ['user', 'tmdb_id', 'created_at'] model = History ordering = ("created_at",) fieldsets = ( ("Data", {"fields": ("user", "tmdb_id", "seedr_folder_id")}), ("Important dates", {"fields": ("created_at", "modified_at")}), ("Movie details", {"fields": ("movie_details",)}), ) readonly_fields = ("created_at", "modified_at", "movie_details") Is there a way by which I can take … -
Pagiantor on a search function
I tried to add a Paginator of 5 posts to the current function but I always have developed with the ListView functions, in which is way easier to implement a pagiantor. Any suggestion? def search(request): query = request.GET.get("q", None) qs = DeathAd.objects.all() if query is not None: qs = qs.annotate( full_name = Concat('nome', Value(' '), 'cognome'), full_cognome = Concat('cognome', Value(' '), 'nome') ).filter( Q(nome__icontains=query) | Q(cognome__icontains=query) | Q(full_name__icontains=query) | Q(full_cognome__icontains=query) ) context = { "object_list": qs, } template = "search.html" return render(request, template, context) -
How do I use placeholders with Class-based password reset views?
There are four such view : PasswordResetView sends the mail # - PasswordResetDoneView shows a success message for the above # - PasswordResetConfirmView checks the link the user clicked and # prompts for a new password # - PasswordResetCompleteView shows a success message for the above. I want to use placeholders for them but there doesn't seem to be an option. Overwriting the class seems kinda overkill. -
Django - login with facebook fails
I'm currently building a website and i'm trying to implement Login with Facebook functionality to users. I have configured social-auth-app-django the following way: seetings.py file: INSTALLED_APPS = [ 'social_django', TEMPLATES = [ 'social_django.context_processors.backends', 'social_django.context_processors.login_redirect', AUTHENTICATION_BACKENDS = [ 'social_core.backends.facebook.FacebookOAuth2', 'django.contrib.auth.backends.ModelBackend', ] SOCIAL_AUTH_FACEBOOK_KEY = '******************' SOCIAL_AUTH_FACEBOOK_SECRET = '***************************' Template login: <div class="col-lg"> <a href="{% url 'social:begin' 'facebook' %}"><button type="submit" class="btn btn-block color-white bgc-fb mb0"<i class="fa fa-facebook float-left mt5"></i> Facebook</button></a> </div> I have uploaded project to Heroku, when i click Facebook button i get error Username OR password is incorrect from views.py. def loginPage(request): if request.user.is_authenticated: return redirect('index') else: if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') remember_me = request.POST.get('remember_me') user = authenticate(request, username=username, password=password) if user is not None: login(request, user) if not remember_me: request.session.set_expiry(0) return redirect('index') else: messages.info(request, 'Username OR password is incorrect') context = {} return render(request, 'members/login.html', context) However when i inspect the page and click on the link <a href="/members/social-auth/login/facebook/"> inside the template it works meaning Facebook requests to use my Facebook profile. I suppose the problem is on my view but how can i configure it to not have this problem? Thank you for your effort! -
Creating model instance in django
please help me with the Django question. I am new here, have searched Stackoverflow and documentation, but still can't understand how to solve the following problem. The general task: there is a list of the events which are displayed in a table view, the user clicks on the event and gets redirected to a single event page, which displays extra information about an event. There is a button on this template that should give functionality to record some data of the Event in the user-selected events list. And I really don't get how to pass the event data into the form to create the user_event... of maybe I chose the wrong way to create the instance of the model? Models.py class Event(models.Model): LANGUAGE_CHOICES = [ ('EN', 'English'), ('IT', 'Italian'), ('FR', 'French'), ('DE', 'German'), ('RU', 'Russian'), ] STATUS_CHOICES = [('draft', 'Draft'), ('confirmed', 'Confirmed'), ] FORMAT_CHOICES = [('live', 'Live'), ('online', 'Online'), ] TOPIC_CHOICES = [('cataract', 'Cataract'), ('vitreo', 'Vitreoretinal'), ('optometry', 'Optometry'), ('multi', 'Multidisciplinary'), ('plastic', 'Plastic and Reconstructive surgery'), ('onco', 'Ocular oncology'), ('glaucoma', 'Glaucoma'), ('pediatrics', 'Pediatrics'), ] title = models.CharField( max_length=250, verbose_name='Event', db_index=True, default="Event") slug = models.SlugField(max_length=250, unique_for_date='publish') kol = models.ManyToManyField( Kol, verbose_name='Presenter', db_index=True, blank=True) body = models.TextField(verbose_name='Description', blank=True) publish = models.DateTimeField(default=timezone.now) created = … -
My site shows menus based on a users privs. I have a function that returns the privs as a dictionary as below:
i need to show my sidebar dynamically by using 6 privilages which giving by admin to users. this is my views.py which i set in my django function.i used checkbox to select 6 privilages here.privilages are ecom,service,career,course,blog.offline def SIDEMENU(request): # ii=request.session['sid'] a=db_coslogin.objects.all().filter(ecom=1,status=2) b=db_coslogin.objects.all().filter(blog=1,status=2) c=db_coslogin.objects.all().filter(servive=1,status=2) d=db_coslogin.objects.all().filter(offline=1,status=2) e=db_coslogin.objects.all().filter(career=1,status=2) f=db_coslogin.objects.all().filter(course=1,status=2) return render(request, "sidebar.html",{'ecomr':a,'blog':b,'servive':c,'offline':d,'career':e,'course':f}) -
How do I display my products by certain category
So I am making an ecom site, and I am using Django. I am quite new and I am using a tutorial but have stepped off touch with it as I want to have 2 categories and maybe more on my website in the future. I want to be able to display them by their category, and I asked for help around my discord server and some people have tried to help and it does go through all my products however I have an if statement and that if statement gets ignored So can anyone show me a way to display products with their category set as Specials only? Or hatbox only? Store.Html {% extends 'store/main.html' %} {% load static %} {% block content %} <title>Store</title> <h2>Our Stylish Hat Boxes - from the smallest to the largest.</h2> <div class="row" style="padding-bottom: 5%;"> {% if products.category == Hatbox %} {% for product in products %} <div class="col-sm-4-fluid" style="margin-right: 5%;"> <div class="card" style="width:300px;"> <img class="card-img-top" src="{{product.imageURL}}" alt="Card image"> <div class="card-body"> <h5 style="display: inline-block; float:right;"><strong> £ {{product.price|floatformat:2}}</strong></h5> <h6 class="card-title">{{product.name}}</h6> <a href="#" class="btn btn-primary">View</a> </div> </div> </div> {% endfor %} {% endif %} </div> <h2>Something Special...</h2> <div class="row" style="padding-bottom: 5%;"> {% for product in products … -
The easiest way for Latin -> Cyrilic transliteration in Django
I need to allow user to freely choose whether he/she wants to display Latin or Cyrilic version of website. So, my question is - what is the easiest way to transliterate every single character in a Django web site? I do not need translation nor localization, just simple character replacement, let's say "Bravo" should be rendered as "Браво" Issue is that this need to be done for each static html page and data in database as well. Is there some package for python or django that makes this possible like in Wordpress? Ideally, this should be done somehow in Template (Model -> View -> Template) context. Duplicating templates (and adding new urls for each) would solve problem for static html pages but it would be time consuming and I want to avoid it, and besides it would left text from database unsolved. -
Can I use Mysql for building a video streaming site like Youtube?
I want to build a video streaming site like youtube. and I'll be using Django to build the site. So i was wondering which DB will be more suited for streaming videos? Is Mysql and Amazon S3 a good choice? -
Im trying to deploy my django/python app to heroku but my status is crashing
when i bring up the logs for heroku i get this message 2020-11-26T07:32:19.145443+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-plains-05024.herokuapp.com request_id=7a6628ea-1d1d-49fa-bade-209878fd54f4 fwd="73.229.185.56" dyno= connect= service= status=503 bytes= protocol=https if i try > heroku ps I get this message: (ll_env) C:\Users\kenne\learning_log>heroku ps Free dyno hours quota remaining this month: 550h 0m (100%) Free dyno usage for this app: 0h 0m (0%) For more information on dyno sleeping and how to upgrade, see: https://devcenter.heroku.com/articles/dyno-sleeping === web (Free): gunicorn learning_log.wsgi --log-file - (1) web.1: crashed 2020/11/26 00:28:42 -0700 (~ 8m ago) -
How I create a cookie in Django to keep a view of a list using vanilla Javascript?
I have a Django view, where the user can choose between 2 different "views" of a list through a toggle button. The map view where a map is displayed with markers and some information and a list view where a list is displayed with the same information but with a list view. When the user clicks the toggle button between one or another option, there is no problem, because I implemented an onClick Javascript function where I change the style display, and that works perfect, the problem is when the user reloads the page. supposes that I put by default the map view, but the user change to the list view by clicking the toggle button, now if he/she reload the page, the view will have to be the list view, I know that I can accomplish this using a cookie but I don't know how to implement the update of the cookie every time the user clicks one of the toggle buttons with vanilla Javascript or in my python view. I know that one solution may be creating 2 Django views one "mapView" and another "listView" so when you click the buttons take to another URL, but I want … -
TypeError at /check-out getting dict value but i want both dict and also specified value
When i checkout an order i got this error.I am passing a dict in customer object but whenever i remove dict function i cant login anymore. i cant also fetch customer details. Here is my views.py(i think my problems are in these views only): class Login(View): def get(self, request): return render(request, 'signupsignin/signin.html') def post(self, request): phone_number = request.POST.get('phone_number') password = request.POST.get('password') customer = Customer.get_customer(phone_number) error_message = None if customer: match = check_password(password, customer.password) if match: customer.__dict__.pop('_state') request.session['customer'] = customer.__dict__ #request.session['csutomer'] = customer.id return redirect('Home') else: error_message = 'Phone number or Password didnt match on our record' else: error_message = 'No Customer Found! Please Registrer First!' print(phone_number, password) context = {'error_message': error_message} return render(request, 'signupsignin/signin.html', context) class Checkout(View): def post(self, request): fname = request.POST.get('fname') phone = request.POST.get('phone') address = request.POST.get('address') cart = request.session.get('cart') customer = request.session.get('customer') products = Product.get_products_id(list(cart.keys())) print(fname, phone, address, products, cart, customer) for product in products: order = Order(customer=Customer(id=customer), product=product, fname=fname, price=product.price, phone=phone, address=address, quantity=cart.get(str(product.id))) order.save() request.session['cart'] = {} return redirect('cart') Here is my urls.py for these function: path('login', Login.as_view(), name='login'), path('check-out', Checkout.as_view(), name="check-out"), I am getting this error: TypeError at /check-out Field 'id' expected a number but got {'id': 3, 'phone_number': '01622153196', 'email': 'sakibovi@gmail.com', 'password': 'pbkdf2_sha256$216000$H2o5Do81kxI0$2tmMwSnSJHBVBTU9tQ8/tkN7h1ZQpRKrTAKkax1xp2Y=', 'coin': … -
change the serialized data
I know question title is not clear and sorry for that. my question is how can I change the way response looks right now # serializers.py class UserCommentSerializer(serializers.ModelSerializer): slug = serializers.SerializerMethodField(read_only=True) class Meta: model = Comment fields = '__all__' def get_slug(self, obj): id = obj.object_id return BlogPost.objects.values('slug').get(id=id) The response looks something like this "results": [ { "id": 49, "slug": { "slug": "ghfj-jkbkj-kjkjk" }, }] I want it to look "results": [ { "id": 49, "slug": "ghfj-jkbkj-kjkjk" }, }] See, if you can help -
when creating a user in Django Admin it does not hash the password?
I am trying to Create a user from my Django Admin (the project is a rest api) using the Django REST framework. admin.py class UserFrame(UserAdmin): list_display = ["name", "email", "date_of_creation", "is_active"] list_editable = ["is_active"] admin.site.register(models.AccountProfile, UserFrame) The error I am getting : Unknown field(s) (date_joined, last_name, first_name) specified for AccountProfile AccountProfile is my custom user model which inherits from AbstractBaseUser and has a BaseUserManager. please help! thank you! -
Testing Django project from outside, is it good approach?
We have a big monolithic Django project (A) with a lot of RESTFUL API endpoints. We're planning to move some of its features into smaller service (B). Before doing that we're going to write tests for these endpoints. We want to a separate testing project that will capable of testing project A and B. When I do an Internet search there are not many resources about that approach. Does anyone try something like this? -
nginx webserver with zscaler as reverse proxy
I have a website running on Django with Nginx as a webserver and Redhat8 OS. The site works fine until now. Now we are trying to put a reverse proxy in front of our Nginx web server. But my authentication fails with an error message. Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties. If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for “same-origin” requests. What I understand is, when the request is passed through the reverse proxy the CSRF cookies are not set properly. But the same URL has a cookie when accessed without a reverse proxy. Below is my nginx.config file for your reference. upstream app_server { server unix:/run/gunicorn.sock fail_timeout=0; } server { listen 443 ssl default_server; ssl on; ssl_certificate /etc/httpd/ssl/portal_com.pem; ssl_certificate_key /etc/httpd/ssl/portal_com.key; server_name portal.company.com; # <- insert here the ip address/domain name ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; keepalive_timeout 5; client_max_body_size 4G; access_log /home/Project/logs/nginx-access.log; error_log /home/Project/logs/nginx-error.log; proxy_connect_timeout 20; proxy_send_timeout 20; proxy_read_timeout 20; send_timeout 20; client_body_timeout 20; location … -
Bulk create on related models using csv
I'm trying to use bulk_create in order to add objects to related models. Here i'm fetching the csv file through post request which contains required fields. As of now I can add items to models which is unrelated using the csv file and bulk_create and it's working. class BulkAPI(APIView): def post(self, request): paramFile = io.TextIOWrapper(request.FILES['requirementfile'].file) dict1 = csv.DictReader(paramFile) list_of_dict = list(dict1) objs = [ ManpowerRequirement( project=row['project'], position=row['position'], quantity=row['quantity'], project_location=row['project_location'], requested_date=row['requested_date'], required_date=row['required_date'], employment_type=row['employment_type'], duration=row['duration'], visa_type=row['visa_type'], remarks=row['remarks'], ) for row in list_of_dict ] try: msg = ManpowerRequirement.objects.bulk_create(objs) returnmsg = {"status_code": 200} print('imported successfully') except Exception as e: print('Error While Importing Data: ', e) returnmsg = {"status_code": 500} return JsonResponse(returnmsg) My models are: class ManpowerRequirement(models.Model): project = models.CharField(max_length=60) position = models.CharField(max_length=60) quantity = models.IntegerField() project_location = models.CharField(max_length=60) requested_date = models.DateField() required_date = models.DateField() employment_type = models.CharField(max_length=60,choices = EMPLOYMENT_TYPE_CHOICES, default = 'Permanent') duration = models.CharField(max_length=60) visa_type = models.CharField(max_length=60) remarks = models.TextField(blank = True , null=True) def __str__(self): return self.project class Meta: verbose_name_plural = "Manpower_Requirement" class Fulfillment(models.Model): candidate_name = models.CharField(max_length=60) manpower_requirement = models.ForeignKey(ManpowerRequirement, on_delete=models.CASCADE) passport_number = models.CharField(blank = True, max_length=60) subcontract_vendors = models.CharField(max_length=200,blank = True , null=True ,default='') joined_date = models.DateField(blank = True, null = True, default = '') remarks = models.TextField( blank = True,null … -
Django Server not running on Wifi
Django Server not running on Wifi I am having trouble in running Django Server on my Wifi so that other devices can see my project. My IPv4 Address : 192.168.10.84 My Allowed Hosts Looks like this - ALLOWED HOSTS = ['192.168.10.84', '127.0.0.1'] when I run the below command, python manage.py runserver 0.0.0.0:8000 and I check from other device by going to the address http://192.168.10.84:8000, it shows THIS SITE CAN'T BE REACHED ANy idea why it's not working?? -
Django compared to Microservices
I've been learning what microservices are and heard something like this: when you use microservices, if one part of your system fails (say the card processing part of an online store platform), you can still use others (like browsing products in the store). However, I have experience with Django and I know that if you mess up a function for card processing, you CAN still use the rest of the platform, it will just fail when you use that function. So, is Django then automatically microservices? Thanks! -
How do I target the Django setting module in an environmental variable on PythonAnywhere?
I want to run my stand-alone script csvImp.py, which interacts with the database used by my Django site BilliClub. I'm running the script from the project root (~/BilliClub) on my virtual environment django2. I've followed the instructions here but for DJANGO_SETTINGS_MODULE rather than the secret key. The part that trips me up is what value to assign to the environmental variable. Every iteration I've tried has yielded an error like ModuleNotFoundError: No module named 'BilliClub' after running (django2) 04:02 ~/BilliClub $ python ./pigs/csvImp.py. I am reloading the shell every time I try to change the variable in .env so the postactivate script runs each time and I'm making sure to re-enter my virtualenv. The problem just seems to be my inability to figure out how to path to the settings module. The .env file: # /home/username/BilliClub/.env # DJANGO_SETTINGS_MODULE="[what goes here???]" Full path of my settings.py is /home/username/BilliClub/BilliClub/settings.py. Abridged results from running tree: (django2) 04:33 ~ $ tree . ├── BilliClub │ ├── BilliClub │ │ ├── __init__.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── manage.py │ ├── media │ ├── pigs │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py … -
Other user's profile is not showing, It is showing only current user name . How to display other user's profile?
I am creating a web app and I want this to display other user's profile through the user's post. I mean when a user click on other user's profile for see the other user's information then it will show the other user's profile. I've tried everything but it is showing the name of the current user information after click on the post. Please Help me in this. Thank you very Much. I will really apppreciate your Help. Here is my Code:- views.py def post_profile(request,username): poste = Profile.objects.get(user=request.user) context = {'poste':poste} return render(request, 'mains/post_profile.html', context) models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE,default='',unique=True) full_name = models.CharField(max_length=100,default='') date_added = models.DateTimeField(auto_now_add=True) post_profile.html - ( This is the template of, which will show the other user's profile . ) {% extends "mains/base.html" %} {% block content %} {% for topic in current_user %} <a>{{ topic.username }}</a><br> {% empty %} <li>No informtion.</li> {% endfor %} </ul> {% endblock content %} Please help me in this, I don't know where is the problem -
Django Rest Framework: foreign key field is required in viewset or serializer
I am very new to Django Rest Framework (DRF). I have read that viewsets are very good, because it reduces the amount of code, but I found it more complex. Description: Imagine that I want to implement a phonebook API, in which we have some users and each of them has it own contacts and each contact can have several phone number. So, I have three models here. User (Default Django model) Contact class Contact(models.Model): owner = models.ForeignKey( User, on_delete=models.CASCADE, related_name='contacts' ) name = models.CharField( max_length=70 ) description = models.TextField() Phone Number class Phones(models.Model): person = models.ForeignKey( Contact, related_name="phones", on_delete=models.CASCADE, ) phone_no = models.CharField( max_length=11, ) Problem Definition What I want is to create new contact with the current request.user. So I should have my contact.serializers like the following: class ContactSerializer(serializers.ModelSerializer): owner = serializers.PrimaryKeyRelatedField( queryset=User.objects.all(), ) class Meta: model = Contact fields = ['id', 'owner', 'name', 'description'] read_only_fields = ['owner'] and my views is like: class ContactViewSet(viewsets.ModelViewSet): queryset = Contact.objects.all() serializer_class = ContactSerializer permission_classes = [IsCreator] def get_permissions(self): if self.request.method == "GET": self.permission_classes = [IsCreator, permissions.IsAdminUser,] if self.request.method == "POST": self.permission_classes = [permissions.IsAuthenticated,] if self.request.method == "PUT": self.permission_classes = [IsCreator] if self.request.method == "DELETE": self.permission_classes = [] return super(ContactViewSet, self).get_permissions() … -
error with migration when i deploy my project
i have troble when migrate my module by django on cpanel i use phpPgAdmin 5.6 django 2.2.6 i got following error when migrare but when i use migrate fake , the error disapear but the site can't be lunch this is following error Running migrations: Applying authtoken.0002_auto_20160226_1747...Traceback (most recent call last): File "/home/aeraeg/virtualenv/python/3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.SyntaxError: syntax error at or near "WITH ORDINALITY" LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co... -
Django, Why is only the'view' permission authenticated, and the rest of the permissions are not? (DjangoModelPermissions)
First of all, I can't speak English well. test1 account permissions.py (DjangoModelPermissions) class CustomPermissions(permissions.BasePermission): perms_map = { 'GET': ['%(app_label)s.view_%(model_name)s'], 'OPTIONS': [], 'HEAD': [], 'POST': ['%(app_label)s.add_%(model_name)s'], 'PUT': ['%(app_label)s.change_%(model_name)s'], 'PATCH': ['%(app_label)s.change_%(model_name)s'], 'DELETE': ['%(app_label)s.delete_%(model_name)s'], } authenticated_users_only = True def get_required_permissions(self, method, model_cls): kwargs = { 'app_label': model_cls._meta.app_label, 'model_name': model_cls._meta.model_name } if method not in self.perms_map: raise exceptions.MethodNotAllowed(method) return [perm % kwargs for perm in self.perms_map[method]] def _queryset(self, view): assert hasattr(view, 'get_queryset') \ or getattr(view, 'queryset', None) is not None, ( 'Cannot apply {} on a view that does not set ' '`.queryset` or have a `.get_queryset()` method.' ).format(self.__class__.__name__) if hasattr(view, 'get_queryset'): queryset = view.get_queryset() assert queryset is not None, ( '{}.get_queryset() returned None'.format(view.__class__.__name__) ) return queryset return view.queryset def has_permission(self, request, view): if getattr(view, '_ignore_model_permissions', False): return True if not request.user or ( not request.user.is_authenticated and self.authenticated_users_only): return False queryset = self._queryset(view) perms = self.get_required_permissions(request.method, queryset.model) return request.user.has_perms(perms) view.py from rest_framework import viewsets, permissions, generics from .serializers import PlayerListSerializer from .models import PlayerList from .permission import CustomPermissions class ListPlayer(generics.ListCreateAPIView): permission_classes = [CustomPermissions, ] queryset = PlayerList.objects.all().filter(del_yn='no').order_by('-key') serializer_class = PlayerListSerializer class AddListPlayer(generics.ListCreateAPIView): permission_classes = [CustomPermissions, ] queryset = PlayerList.objects.all().filter(del_yn='no').order_by('-key') serializer_class = PlayerListSerializer class DetailPlayer(generics.RetrieveUpdateDestroyAPIView): permission_classes = [CustomPermissions, ] queryset = PlayerList.objects.all() serializer_class = PlayerListSerializer … -
How can i convert from IntgerField(Timestamp) to python datetime
unban_date = models.IntegerField() This Output = All the timestamps from the database I need it to convert to DateTime I came up with this but it does not work as it does not take IntegarField intToParser = datetime.datetime.fromtimestamp(unban_date) parserToDate = intToParser.strftime('%Y-%b-%d %H:%M:%S') print(parserToDate) This is dJango Models