Well done, and an excellent intro to Django. Happy to see more of my African brothers doing programming! AI and software is the future, and Africa is the next frontier.
Nicely done! Thank you for explaining things the way you do. I like how you run the code with it not working first, then explain why it wasn't working. Gives the video a great pace and helps debug our own issues.
Thanks MAN. Everything worked perfectly just my chatgpt quota is finished without even showing any reply. but if i get paid version and connect with this. hope so it will reply me . again Thanku.
Is there a relatively simple way to receive data back as a stream and forward to the client? I know django isn't built for this... but I'm stuck with it for my project. Thanks for the video.
i am stucked on this turorial with this isuee pls help me if you know raise self.handle_error_response( openai.error.InvalidRequestError: The model: `gpt-4` does not exist [01/Jun/2023 14:03:12] "POST / HTTP/1.1" 500 91452
Tomi, can you please make a tutorial on how we can convert our Django projects into .exe or .apk and iOS. This will come helpful, thanks bro, thumbs up
Django is for back end .. you can use other framework for front end and you can serve that into exe or APK which will still connect to a server ( backend )
When I went to refresh the page, it says template does not exist at chatbot.html, but I copied the provided code and saved my file as chatbot.html. What could be wrong?
I learned frames in HTML before I was 17, and had a free page that hosted my website with frames, complete with message boards on every page and it lasted almost ten years. That is the best time to learn and teach code.
Like? Just making remarks without qualifying it with observations is neither useful nor does it make you sound like someone who is serious about learning.
@vishnuhunnithan3086 You're right, I should have elaborated. The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project. The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself. There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings. The templates aren't namespaced to the app. The Django tutorial explains very well why this is important. The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell. The templates define the style directly. This should be in a specialized css file that is imported in the base html. The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates. The register and login templates can probably be simplified, but it's not a big problem. The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base html shouldn't use the jquery cdn. The chat template uses vanilla js in a script tag, it should be in another file specialized js file. The js code is fine, altough I would have personally used htmx instead of json. Now, the biggest problems are in views py: This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application. Leaving that aside, there are other problems in views py: ask_openapi shouldn't be in views py. It's not a view, it should be in utils py or services py or anywhere else. The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View. login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates. The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this. The view that returns the Json should be in another one, not the same. And preferably in another application. The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used. The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API. This same pattern is used in the login and registering. The project is also missing tests, but most tutorials don't usually include those. There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
@@vishnuhunnithan3086 You're right, I should have elaborated. The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project. The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself. There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings. The templates aren't namespaced to the app. The Django tutorial explains very well why this is important. The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell. The templates define the style directly. This should be in a specialized css file that is imported in the base html. The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates. The register and login templates can probably be simplified, but it's not a big problem. The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base html shouldn't use the jquery cdn. The chat template uses vanilla js in a script tag, it should be in another file specialized js file. The js code is fine, altough I would have personally used htmx instead of json. Now, the biggest problems are in views py: This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application. Leaving that aside, there are other problems in views py: ask_openapi shouldn't be in views py. It's not a view, it should be in utils py or services py or anywhere else. The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View. login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates. The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this. The view that returns the Json should be in another one, not the same. And preferably in another application. The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used. The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API. This same pattern is used in the login and registering. The project is also missing tests, but most tutorials don't usually include those. There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
@@vishnuhunnithan3086 You're right, I should have elaborated. The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project. The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself. There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings. The templates aren't namespaced to the app. The Django tutorial explains very well why this is important. The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell. The templates define the style directly. This should be in a specialized css file that is imported in the base html. The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates. The register and login templates can probably be simplified, but it's not a big problem. The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base.html shouldn't use the jquery cdn. The chat template uses vanilla js in a script tag, it should be in another file specialized .js file. The js code is fine, altough I would have personally used htmx instead of json. Now, the biggest problems are in views py: This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application. Leaving that aside, there are other problems in views py: ask_openapi shouldn't be in views py. It's not a view, it should be in utils.py or services.py or anywhere else. The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View. login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates. The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this. The view that returns the Json should be in another one, not the same. And preferably in another application. The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used. The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API. This same pattern is used in the login and registering. The project is also missing tests, but most tutorials don't usually include those. There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
@@vishnuhunnithan3086 You're right, I should have elaborated. The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project. The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself. There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings. The templates aren't namespaced to the app. The Django tutorial explains very well why this is important. The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell. The templates define the style directly. This should be in a specialized css file that is imported in the base html. The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates. The register and login templates can probably be simplified, but it's not a big problem. The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base.html shouldn't use the jquery cdn. The chat template uses vanilla js in a script tag, it should be in another file specialized .js file. The js code is fine, altough I would have personally used htmx instead of json. Now, the biggest problems are in views py: This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application. Leaving that aside, there are other problems in views py: ask_openapi shouldn't be in views py. It's not a view, it should be in utils.py or services.py or anywhere else. The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View. login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates. The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this. The view that returns the Json should be in another one, not the same. And preferably in another application. The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used. The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API. This same pattern is used in the login and registering. The project is also missing tests, but most tutorials don't usually include those. There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
can any one tell me how to open the db.sqlite3 file it says ( file is not displayed in the text editor because it is either binary or uses an unsupported text encoding)
Well done, and an excellent intro to Django. Happy to see more of my African brothers doing programming! AI and software is the future, and Africa is the next frontier.
Nicely done! Thank you for explaining things the way you do. I like how you run the code with it not working first, then explain why it wasn't working. Gives the video a great pace and helps debug our own issues.
thats the best front end professor ive ever seen, OH MY GOD I LOVE YOU
Thank you freecodecamp for publishing this tutorial. I hope it’s helpful
This young brother wants me to not give up on django, well done bro👏👏👏
This is great!! I really appreciate the detail and explanations! You have the heart of a teacher, mon ami !
I can not thank you enough :) I am new in Django and your video realy helped me ... Thank you so much :)
crazy tutorial man loved it! well explained
Oh Oh, going for next level now.
this chap is so good, thanks so much man
Very well explained! Great job!
Thanks Tomi! Amazing tutorial😊
Thanks for the tutorial! I've learned a lot and even more
Nice work!keep going🎉🎉 3:33
Great job, Tomi!
Your work is impressive my friend.
One question... How can I change the language of the AI, for example in Spanish?
there must be a api for that?
Thank you guys for helped me a lot ❤
The tutorial is understandable !
Why y'all put "Django" so large next to this man? Y'all tryna say he's unchained?!?
Caught me so off guard💀
Lol..nice one😂
Great work!!!!🎉🎉 Love your content
Thanks for the tutorial Boss Tomi.
Thank you very muss, that was very good
Bukayo saka doing side quests 😂
Niceeeee video!!!
Doesn’t work again for me now I get an error saying the OpenAI is not supported again bla bla and I am using gpt 4 api
Thanks MAN. Everything worked perfectly just my chatgpt quota is finished without even showing any reply. but if i get paid version and connect with this. hope so it will reply me . again Thanku.
Thanks bro.
Thanks free code camp
Can you also share to add a voice button ?
Is there a relatively simple way to receive data back as a stream and forward to the client? I know django isn't built for this... but I'm stuck with it for my project. Thanks for the video.
i am stucked on this turorial with this isuee pls help me if you know
raise self.handle_error_response(
openai.error.InvalidRequestError: The model: `gpt-4` does not exist
[01/Jun/2023 14:03:12] "POST / HTTP/1.1" 500 91452
You want django-channels for that
can you do one with llama instead?
can we add our own ui and if yes then how to do it and wher to do it
this one couldn't respond me? what can i do?? if i put input , it couldnt respnd me..tell me a solution
I don't understand the need of gpt-4 integration
Can someone explain
where can i get js code ?
Tomi, can you please make a tutorial on how we can convert our Django projects into .exe or .apk and iOS. This will come helpful, thanks bro, thumbs up
Django is for back end .. you can use other framework for front end and you can serve that into exe or APK which will still connect to a server ( backend )
guess this project is restricted to those who have paid access to the openAI huh
Sir make tutorials on document tracking system web based in MERN Stack with source code
Thanks free code camp... We truly appreciate
If you remove the message-list class from chatbot.html the chats do not render. Can someone explain how that works
The OpenAI api key that generates its free of cost
i can not get answers by api key why, please help me??
Same bro may be model id not working
When I went to refresh the page, it says template does not exist at chatbot.html, but I copied the provided code and saved my file as chatbot.html. What could be wrong?
same here
make sure your templates folder is in the correct directory
Hi do i need a paid openai account?
yes and to pay
18$ for paid account
Yhs do we need to pay?
I think so 😢
How you open the finder plzz help me
My aiohttp is not downloading 😢
could had added a link to the original video to get the templates!
YEAH , WITHOUT THAT THE PROJECT IS MEANINGLESS; I HAVE SEARCHED IT EVERYWHERE
i am getting error : Uncaught SyntaxError: Unexpected token '
Same here
How did you resolve it?
is it still working?
Thank's
Yo where are the html files?
thanksss buddy
Missed to add GitHub url
right i was about to say the same thing
GitHub link is now in the description.
Thank you
i keep getting a "Uncaught (in promise) SyntaxError: Unexpected token '
❤❤❤ first
43:00
18:31
is this api paid ?
Nope
@@lewisndungu7239 Is this api paid now
wow how old is this kid??
He's 18. One of the brightest, most ambitious devs I know.
This accent looks Nigerian
Yes he is a Nigerian
@@Lil-Undercoverreally
WOW he's a child 🤯
I learned frames in HTML before I was 17, and had a free page that hosted my website with frames, complete with message boards on every page and it lasted almost ten years. That is the best time to learn and teach code.
Hey! I am first.
This project is filled with bad practices. Be warned.
Like? Just making remarks without qualifying it with observations is neither useful nor does it make you sound like someone who is serious about learning.
@vishnuhunnithan3086
You're right, I should have elaborated.
The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project.
The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself.
There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings.
The templates aren't namespaced to the app. The Django tutorial explains very well why this is important.
The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell.
The templates define the style directly. This should be in a specialized css file that is imported in the base html.
The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates.
The register and login templates can probably be simplified, but it's not a big problem.
The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base html shouldn't use the jquery cdn.
The chat template uses vanilla js in a script tag, it should be in another file specialized js file.
The js code is fine, altough I would have personally used htmx instead of json.
Now, the biggest problems are in views py:
This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application.
Leaving that aside, there are other problems in views py:
ask_openapi shouldn't be in views py. It's not a view, it should be in utils py or services py or anywhere else.
The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View.
login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates.
The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this.
The view that returns the Json should be in another one, not the same. And preferably in another application.
The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used.
The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API.
This same pattern is used in the login and registering.
The project is also missing tests, but most tutorials don't usually include those.
There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
@@vishnuhunnithan3086
You're right, I should have elaborated.
The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project.
The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself.
There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings.
The templates aren't namespaced to the app. The Django tutorial explains very well why this is important.
The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell.
The templates define the style directly. This should be in a specialized css file that is imported in the base html.
The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates.
The register and login templates can probably be simplified, but it's not a big problem.
The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base html shouldn't use the jquery cdn.
The chat template uses vanilla js in a script tag, it should be in another file specialized js file.
The js code is fine, altough I would have personally used htmx instead of json.
Now, the biggest problems are in views py:
This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application.
Leaving that aside, there are other problems in views py:
ask_openapi shouldn't be in views py. It's not a view, it should be in utils py or services py or anywhere else.
The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View.
login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates.
The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this.
The view that returns the Json should be in another one, not the same. And preferably in another application.
The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used.
The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API.
This same pattern is used in the login and registering.
The project is also missing tests, but most tutorials don't usually include those.
There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
@@vishnuhunnithan3086
You're right, I should have elaborated.
The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project.
The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself.
There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings.
The templates aren't namespaced to the app. The Django tutorial explains very well why this is important.
The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell.
The templates define the style directly. This should be in a specialized css file that is imported in the base html.
The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates.
The register and login templates can probably be simplified, but it's not a big problem.
The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base.html shouldn't use the jquery cdn.
The chat template uses vanilla js in a script tag, it should be in another file specialized .js file.
The js code is fine, altough I would have personally used htmx instead of json.
Now, the biggest problems are in views py:
This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application.
Leaving that aside, there are other problems in views py:
ask_openapi shouldn't be in views py. It's not a view, it should be in utils.py or services.py or anywhere else.
The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View.
login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates.
The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this.
The view that returns the Json should be in another one, not the same. And preferably in another application.
The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used.
The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API.
This same pattern is used in the login and registering.
The project is also missing tests, but most tutorials don't usually include those.
There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
@@vishnuhunnithan3086
You're right, I should have elaborated.
The project doesn't have a gitignore, requirements txt or a pyproject toml file. It wasn't made with dependency or package management in mind, or from a project template. This is why the sqlite3 database and pycache files were committed to the project.
The production secrets are hardcoded in the code instead of being imported from enviroment variables with something like python-dotenv or better yet, from the system itself.
There are only development settings. In a real application you would either have another settings file for production or another branch with all the production settings.
The templates aren't namespaced to the app. The Django tutorial explains very well why this is important.
The chat model uses the User model directly. You should never do this, and instead create a new User model from the AbstractUser class. The Djando docs explain why aswell.
The templates define the style directly. This should be in a specialized css file that is imported in the base html.
The base html template uses cdns, you shouldn't use cdns in production unless you're the owner of them. It also imports bootstrap, so I wonder why even have custom styles in the templates.
The register and login templates can probably be simplified, but it's not a big problem.
The chat template uses vanilla js when jquery was imported in the base. The code should either be using jquery or base.html shouldn't use the jquery cdn.
The chat template uses vanilla js in a script tag, it should be in another file specialized .js file.
The js code is fine, altough I would have personally used htmx instead of json.
Now, the biggest problems are in views py:
This project should have used websockets with django-channels instead of doing rest-like ajax requests. Chat applications need to be responsive to requests and don't follow the REST pattern very well, this is why if you use any chat application like discord, whatsapp, telegram, etc and switch to the network tab, you'll see that they use websockets. For a simple demonstration project it's fine, but it should have been done with websockets. The django-channels tutorial teaches you how to make a chat application.
Leaving that aside, there are other problems in views py:
ask_openapi shouldn't be in views py. It's not a view, it should be in utils.py or services.py or anywhere else.
The project only uses functional views. These don't scale, and will only bring problems down the road if you don't refactor them into class-based-views. The project should have overriden one of the generic views from django with the additional needed functionality or written one from scratch by inheriting from View.
login and register shouldn't exist. Django comes with pre-defined, customizable class-based-views for login, logout and changing password. registering can be done using the default UserCreationForm and a CreateView. The only thing that isn't done for you are the templates.
The project shouldn't have a a view returning Json data, this should be handled with a serializer, with either django-rest or django-ninja. The view isn't the place to be doing this.
The view that returns the Json should be in another one, not the same. And preferably in another application.
The filtering shouldn't be done from filter() directly, a custom manager or queryset should have been defined and a custom method like "by_user()" should have been used.
The project uses the Chat model directly to create new objects. This is VERY VERY WRONG AND DANGEROUS. You should ALWAYS sanitize data coming from the frontend. Django has a forms framework that helps you do this ultra easy. Worse, this same data is used for a call to chatgpt's API.
This same pattern is used in the login and registering.
The project is also missing tests, but most tutorials don't usually include those.
There's probably more stuff that I've missed, but the conclusion is that the person that made this tutorial isn't experienced enough with web development nor django. This is fine, we all start from 0 and learn. The problem is that this is a tutorial in a programming learning channel with 9.3 million subscribers. People will learn from here and use this code for real applications, and by doing so make stuff filled with bad practices and vulnerabilities.
Django ? This sh*t is still alive ?
but why not django??
Yea, way better than your MERN sh*t.
Unchained
Django is doing just fine, thank you very much.
Not everyone uses JavaScript and React for everything.
Not well explained
Would love to see how you'd 3x0lain it better.
رررع
hi right now ghat gpt doesnt offer any free api we should buy chatgpt4
can any one tell me how to open the db.sqlite3 file it says ( file is not displayed in the text editor because it is either binary or uses an unsupported text encoding)
use this extension SQLite Viewer
I keep getting this error. openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.
same i don't know how to make it right
you need to sign up for a new account since your api free trial expired, this happened to me too and i made a new account
Your api token is deprecated. Add card info and try again with new token