How to change the passwords error messages
How do you customize the password error messages? More precisely, is there an error name for "password too common" or "password too short" like "unique" is an error name? Can I do some
self.fields["password1"].error_message = {"password_too_short": "password too short"}
kind of magic?
/r/django
https://redd.it/zym5ud
How do you customize the password error messages? More precisely, is there an error name for "password too common" or "password too short" like "unique" is an error name? Can I do some
self.fields["password1"].error_message = {"password_too_short": "password too short"}
kind of magic?
/r/django
https://redd.it/zym5ud
reddit
How to change the passwords error messages
How do you customize the password error messages? More precisely, is there an error name for "password too common" or "password too short" like...
How to prevent access to a route ?
How to prevent access to a route unless it has been called from another route. I have created a login page that accepts only one user ( username and password of admin) and after the user credentials is correct, it redirects to another route called /display. But this /display route can be accessed just by typing inside the search bar of the browser. I want to prevent the access, unless it is redirected from the login page. I felt using flask_admin and flask_login was too complex. If there is another method please suggest thanks.
/r/flask
https://redd.it/zyd1nl
How to prevent access to a route unless it has been called from another route. I have created a login page that accepts only one user ( username and password of admin) and after the user credentials is correct, it redirects to another route called /display. But this /display route can be accessed just by typing inside the search bar of the browser. I want to prevent the access, unless it is redirected from the login page. I felt using flask_admin and flask_login was too complex. If there is another method please suggest thanks.
/r/flask
https://redd.it/zyd1nl
reddit
How to prevent access to a route ?
How to prevent access to a route unless it has been called from another route. I have created a login page that accepts only one user ( username...
I want to add unit tests to my Django project but don't know where do i even start
Hey everyone,
I developped an app at my workplace (i'm not a developper officially) using Django, it allows users to login, view data, make comments on data X.
Since it is a quite simple CRUD app, i managed to make it work without any unit testing. I never did any unit tests in my small developper life (5 years).
Now they're asking me to add the option to send out emails containing data X.
I thought this feature would be a good use case for learning unit tests.
Where do i even start? Probably would have to start by something very simple to first get the hang of what unit testing is. Any roadmap to suggest?
I'm quite good at coding and getting stuff done using google (or OpenAI now...), but would like to become more of a real software developper and i know it starts with writing testable code.
Thanks guys.
/r/djangolearning
https://redd.it/zynykr
Hey everyone,
I developped an app at my workplace (i'm not a developper officially) using Django, it allows users to login, view data, make comments on data X.
Since it is a quite simple CRUD app, i managed to make it work without any unit testing. I never did any unit tests in my small developper life (5 years).
Now they're asking me to add the option to send out emails containing data X.
I thought this feature would be a good use case for learning unit tests.
Where do i even start? Probably would have to start by something very simple to first get the hang of what unit testing is. Any roadmap to suggest?
I'm quite good at coding and getting stuff done using google (or OpenAI now...), but would like to become more of a real software developper and i know it starts with writing testable code.
Thanks guys.
/r/djangolearning
https://redd.it/zynykr
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
How to save a list inside my a SQL Database model ?
How can I save a list inside a database model ?
testlist = ["name1". "name2", "name3"]
class Listing(models.Model):
listingprice = models.CharField(maxlength=100)
listingtype = models.CharField(maxlength=100)
listinglist = models.?????
/r/djangolearning
https://redd.it/zyio95
How can I save a list inside a database model ?
testlist = ["name1". "name2", "name3"]
class Listing(models.Model):
listingprice = models.CharField(maxlength=100)
listingtype = models.CharField(maxlength=100)
listinglist = models.?????
/r/djangolearning
https://redd.it/zyio95
reddit
How to save a list inside my a SQL Database model ?
How can I save a list inside a database model ? test_list = ["name1". "name2", "name3"] class Listing(models.Model): ...
Where am i going wrong
So im following [https://www.youtube.com/watch?v=sm1mokevMWk](https://www.youtube.com/watch?v=sm1mokevMWk) this tutorial and at 49:20 he heads towards the admin dashboard.
When i try the same thing i get a
main.models.ToDoList.DoesNotExist: ToDoList matching query does not exist.
On my cmd
Just to clarify this is my code in [views.py](https://views.py)
from django.shortcuts import render
from django.http import HttpResponse
from .models import ToDoList,Items
def index(response,id):
ls=ToDoList.objects.get(id=id)
item=ls.item_set.get(id=1)
return HttpResponse("<h1>%s</h1><br></br><p>%s</p>"%(ls.name,str(item.text)))
​
/r/djangolearning
https://redd.it/zy0x35
So im following [https://www.youtube.com/watch?v=sm1mokevMWk](https://www.youtube.com/watch?v=sm1mokevMWk) this tutorial and at 49:20 he heads towards the admin dashboard.
When i try the same thing i get a
main.models.ToDoList.DoesNotExist: ToDoList matching query does not exist.
On my cmd
Just to clarify this is my code in [views.py](https://views.py)
from django.shortcuts import render
from django.http import HttpResponse
from .models import ToDoList,Items
def index(response,id):
ls=ToDoList.objects.get(id=id)
item=ls.item_set.get(id=1)
return HttpResponse("<h1>%s</h1><br></br><p>%s</p>"%(ls.name,str(item.text)))
​
/r/djangolearning
https://redd.it/zy0x35
YouTube
Django For Beginners - Full Tutorial
Welcome to this Django complete course. In this video, I'll be covering all the important aspects of Django that as a beginner you need to know. We'll cover setting up a simple Django application, creating a database, allowing users to sign up, sign in, and…
OpenAI just rick rolled me...
https://imgur.com/a/cDLSnHw
Was tinkering around with how to write a python file to download a youtube video and was very interested to see what video it had suggested as a placeholder...
/r/Python
https://redd.it/zyyv9z
https://imgur.com/a/cDLSnHw
Was tinkering around with how to write a python file to download a youtube video and was very interested to see what video it had suggested as a placeholder...
/r/Python
https://redd.it/zyyv9z
Imgur
Post with 1 views.
Handling relations using Django REST Framework ModelSerializer
Hi there, I have been working with DRF for a few years. I currently work as a lead developer at a small Canadian company with a very complex piece of Django stack that is responsible for a relatively large cashflow (we were recently acquire by a very large company). I often see developers jumping into Python/Django world and get very confused about how to use DRF ModelSerializer, and sometimes devs get scared away by the amount of unknown abstraction behind ModelSerializer, they choose to use Serializer instead and implement a lot of the functionality that is already provided by ModelSerializer. So I finally sat down over Christmas break here and wrote this tutorial over the last couple of days, I hope that it helps to explain how to use ModelSerializer to handle model relationships:
https://github.com/oscarychen/deep-dive-drf-model-serializer-relations
It is kind of a difficult read as it touches a lot of nitty gritty implementation details, any suggestion is welcome.
/r/django
https://redd.it/zyuskh
Hi there, I have been working with DRF for a few years. I currently work as a lead developer at a small Canadian company with a very complex piece of Django stack that is responsible for a relatively large cashflow (we were recently acquire by a very large company). I often see developers jumping into Python/Django world and get very confused about how to use DRF ModelSerializer, and sometimes devs get scared away by the amount of unknown abstraction behind ModelSerializer, they choose to use Serializer instead and implement a lot of the functionality that is already provided by ModelSerializer. So I finally sat down over Christmas break here and wrote this tutorial over the last couple of days, I hope that it helps to explain how to use ModelSerializer to handle model relationships:
https://github.com/oscarychen/deep-dive-drf-model-serializer-relations
It is kind of a difficult read as it touches a lot of nitty gritty implementation details, any suggestion is welcome.
/r/django
https://redd.it/zyuskh
GitHub
GitHub - oscarychen/deep-dive-drf-model-serializer-relations: Deep dive the nuances of using Django REST Framework ModelSerializer…
Deep dive the nuances of using Django REST Framework ModelSerializer to read, create and update model relations - GitHub - oscarychen/deep-dive-drf-model-serializer-relations: Deep dive the nuances...
I learnt all the basics about python and had interest in learning about "AI development with python". and now I'm stuck cuz I don't know where to start. Can anyone give some advice to me ?
/r/Python
https://redd.it/zz1h3i
/r/Python
https://redd.it/zz1h3i
reddit
I learnt all the basics about python and had interest in learning...
Posted in r/Python by u/Livid_Platypus9512 • 23 points and 49 comments
Hi, I have a problem. The thing is that I´m new using Django, and I tried to make a quiz. So far, I can show in the server the question, but not the options. I need to be able to show the options and I need something else: receive the answers and send feedback to the user. Here's my code.
https://redd.it/zzcncy
@pythondaily
https://redd.it/zzcncy
@pythondaily
reddit
Hi, I have a problem. The thing is that I´m new using Django, and...
Posted in r/django by u/Cricketmathgenius • 1 point and 3 comments
How do I give path to a static image url from dictionary?
Lets suppose my dictionary has a key value as ‘pic’: ‘imagesTwo/pic1.jpg’
How to render images in a static img tag? Cause the dictionary value may change.
/r/django
https://redd.it/zzay90
Lets suppose my dictionary has a key value as ‘pic’: ‘imagesTwo/pic1.jpg’
How to render images in a static img tag? Cause the dictionary value may change.
/r/django
https://redd.it/zzay90
reddit
How do I give path to a static image url from dictionary?
Lets suppose my dictionary has a key value as ‘pic’: ‘imagesTwo/pic1.jpg’ How to render images in a static img tag? Cause the dictionary value...
DRF reset password
Best way to reset password with Django Rest Framework?
1 django-rest-passwordreset library
2 djoser library
3 django-rest-registration library
4 implement my own (if you have an advice/hint is appreciated)
/r/djangolearning
https://redd.it/zywskv
Best way to reset password with Django Rest Framework?
1 django-rest-passwordreset library
2 djoser library
3 django-rest-registration library
4 implement my own (if you have an advice/hint is appreciated)
/r/djangolearning
https://redd.it/zywskv
reddit
DRF reset password
Best way to reset password with Django Rest Framework? 1 django-rest-passwordreset library 2 djoser library 3 django-rest-registration...
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources!
/r/Python
https://redd.it/zzfo96
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources!
/r/Python
https://redd.it/zzfo96
reddit
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic? Use this thread to chat about and...
[DRF] What's you preferred way of serializing FK as an object when reading but using PK when writing?
The title says pretty much everything.
I want to know the most common (or most comfortable) way of serializing related object when performing **READ** operations but having to specify PK of the related object when **writing**.
Let's say I have two models **File** and **FileType**:
class File(..):
type = ForeignKey('FileType'...)
What I'm used to do is to add another field called **type\_detail:**
class FileSerializer(..):
type_detail = FileTypeSerializer(read_only=True, source='type')
That way I can **WRITE** like this:
{type:45...}
But when I **READ** I get:
{type_detail: {OBJECT}, type:45}
Do you do it differently? If yes, how?
I don't like that I have two fields. I'd like to use one for both operations.
/r/djangolearning
https://redd.it/zz7rj8
The title says pretty much everything.
I want to know the most common (or most comfortable) way of serializing related object when performing **READ** operations but having to specify PK of the related object when **writing**.
Let's say I have two models **File** and **FileType**:
class File(..):
type = ForeignKey('FileType'...)
What I'm used to do is to add another field called **type\_detail:**
class FileSerializer(..):
type_detail = FileTypeSerializer(read_only=True, source='type')
That way I can **WRITE** like this:
{type:45...}
But when I **READ** I get:
{type_detail: {OBJECT}, type:45}
Do you do it differently? If yes, how?
I don't like that I have two fields. I'd like to use one for both operations.
/r/djangolearning
https://redd.it/zz7rj8
reddit
[DRF] What's you preferred way of serializing FK as an object when...
The title says pretty much everything. I want to know the most common (or most comfortable) way of serializing related object when performing...
Django generate thumbnail with MoviePy, problem with Path
How to get the absolute path to a video, that works in development (Windows) and production (Ubuntu), ive tried almost everything, here is the closest I've gotten to a solution, I am trying to generate a thumbnail for a video when its posted.
from pathlib import Path
BASEDIR = Path(file).resolve().parent.parent
def generatethumbnail(instance):
filename = Path.joinpath(BASEDIR, 'media/videofiles')
print(filename)
thumbnail = VideoFileClip(str(filename)+instance.video.url)
name = instance.video.url + '.png'
time = random.randrange(60)
thumbnail.saveframe('media/uploads/thumbnail' + name, t=time,withmask=True)
instance.thumbnail = name
It never gives me a good path, its ether with '/' or with \\ .
MoviePy error: the file C:\Users\User 1\Desktop\django\lumen\media\videofiles/media/uploads/videofiles/22/29/Elvis-IfICanDreamOfficialLivePerformancefcw0WKp.mp4 could not be found! Please check that you entered the correct path.
/r/django
https://redd.it/zzk4ow
How to get the absolute path to a video, that works in development (Windows) and production (Ubuntu), ive tried almost everything, here is the closest I've gotten to a solution, I am trying to generate a thumbnail for a video when its posted.
from pathlib import Path
BASEDIR = Path(file).resolve().parent.parent
def generatethumbnail(instance):
filename = Path.joinpath(BASEDIR, 'media/videofiles')
print(filename)
thumbnail = VideoFileClip(str(filename)+instance.video.url)
name = instance.video.url + '.png'
time = random.randrange(60)
thumbnail.saveframe('media/uploads/thumbnail' + name, t=time,withmask=True)
instance.thumbnail = name
It never gives me a good path, its ether with '/' or with \\ .
MoviePy error: the file C:\Users\User 1\Desktop\django\lumen\media\videofiles/media/uploads/videofiles/22/29/Elvis-IfICanDreamOfficialLivePerformancefcw0WKp.mp4 could not be found! Please check that you entered the correct path.
/r/django
https://redd.it/zzk4ow
reddit
Django generate thumbnail with MoviePy, problem with Path
How to get the absolute path to a video, that works in development (Windows) and production (Ubuntu), ive tried almost everything, here is the...