▶️ Watch Entire Django Blog Playlist ✅ Subscribe To My KZbin Channel: bit.ly/3bWN6wj bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
@juanbilly13643 жыл бұрын
i know it's kinda off topic but do anyone know of a good website to stream newly released movies online?
@jasiahaugustus18643 жыл бұрын
@Juan Billy Lately I have been using FlixZone. You can find it by googling =)
@westongenesis70073 жыл бұрын
@Jasiah Augustus Definitely, I've been using FlixZone for months myself :D
@juanbilly13643 жыл бұрын
@Jasiah Augustus Thank you, signed up and it seems like they got a lot of movies there :) I really appreciate it!!
@jasiahaugustus18643 жыл бұрын
@Juan Billy Glad I could help :D
@smishra63783 жыл бұрын
Also, if you want to fix 'Categorys', add this meta class in your model: class Meta: verbose_name_plural = "Categories"
@bibekjoshi342 жыл бұрын
thanks it is helpful
@pedrocampoy774026 күн бұрын
Hey guys, I'm a novice coder, so take my advice with a grain of salt. But for me it worked better to use the category attribute on Post(models.Model) as a relation instead of a CharField. I used 'models.ManyToManyField(to=Category)' because i wanted posts to have many categories assigned to them. Feel free to correct me if I am incorrect in what i said. I'm happy to learn! And thak you so much for this series of videos John ! It has helped me a lot!
@ibrahimhennihaouas92593 жыл бұрын
the best method you can create: category= models.ForeignKey(Caterory ,max_length=60, on_delete=models.CASCADE, related_name= 'catego')
@sayori39392 жыл бұрын
Yes, if a category is a part of a post then why not make it a foreign key referencing Category table?
@sayori39392 жыл бұрын
But if you set on delete CASCADE and we delete some category form the Category table EVERY post with that category will be deleted as well :/ maybe you wanna set to SET_DEFAULT with a default value like "misc" so every post with deleted category will have its category set to "misc"
@Morimove Жыл бұрын
on_delete is not required because category can be multiple and blogs can be zero at a time. On category delete or blog delete their should be no effect on other records.
@MrMurdox4 ай бұрын
@sayori3939 Unless you want the post to only have one category, then you use a many-to-many relationship. A post can have many categories, and a category can belong to many posts. With a foreign key, you are creating a many-to-one relationship, where a category can belong to many posts, but a post can only have one category.
@EzekielCarvalho3 жыл бұрын
Excellent channel, I've been learning quite a bit from you on Django. You've got yourself another subscriber.
@Codemycom3 жыл бұрын
Thanks!!
@andrenevares75434 жыл бұрын
I think you are the only one that gives attention to the default property. Other vids over KZbin do not mention that. A lot of students delete db.sqlite3 and migrations (not the __init__) and then do a migration of all Data Base. Of course, with this, you do not have errors when migrating the database. But, for me, it´s so much better to understand the default property and do not lose data on the future... Great Material.
@unchart_d4 жыл бұрын
Am no longer rushing, am staying this helps to master the content.
@Codemycom4 жыл бұрын
Sure, take your time
@akshitkushwaha9479 Жыл бұрын
Sir, your videos are a great great help to someone like me who struggles with django
@Codemycom Жыл бұрын
Happy to hear it!
@romanbuchta2484 жыл бұрын
A great tutorial about Python Django! Thanks a lot! Best regards from Austria (Vienna)! - Your tutorial about Python's Tkinter will be my next stop!
@Codemycom4 жыл бұрын
Glad you're enjoying them!
@Han_Zubon3 жыл бұрын
Like the Bob Ross of Django. Great stuff
@Codemycom3 жыл бұрын
Ha Nice!
@justasnom2472 жыл бұрын
great tutorial. any ideas how to skip restarting the server? I've noticed that the category appears after some time even without restrating the server, but are there any ways to make it instant, just like adding posts?
@СвятославЛитвин-л9й3 жыл бұрын
I from Ukraine and my english so bad, but you so good in explanation and it`s great, thank you so much
@Codemycom3 жыл бұрын
Thanks for watching!
@sayori39392 жыл бұрын
Wouldn't it be easeir to make category a foreign key with "on_delete=SET_DEFAULT" set to something like "misc" so the post wouldn't be deleted if you deleted certain category and you wouldn't have to do a query on forms.py?
@Morimove Жыл бұрын
i am suprized the you are covering every aspect of a website. Now I know why there are so many videos in the playlist
@danieldiaz8554 жыл бұрын
Hi, Jhon, Thanks for this Django Series. As a feedback I think that it's better to create a Foreign key in Post.category field instead of the query you did.😄
@mryaz97673 жыл бұрын
Actually, this is more applicable and easyer!!
@Morimove Жыл бұрын
yes you are right because user can manipulate the HTML and can save any other category which is not in the category table
@Morimove Жыл бұрын
@@mryaz9767 but not secure
@aygunbayir3 жыл бұрын
why we do not use category as foreign key ???
@smishra63783 жыл бұрын
Great tutorial! Here are my 2 cents to make the `choices` code a bit more pythonic- choices = Category.objects.all().values_list('name', 'name') choice_list = [choice for choice in choices]
@felipevelasquez45873 жыл бұрын
Para mi es mejor así ya que el formulario valida la categoría... si alguien tiene una solución mejor que la dé categoria_bd = Categoria.objects.all().values_list('pk','nombre') categoria_selected = [('','')] for item in categoria_bd: categoria_selected.append(item)
@n.i.g.e.l2 жыл бұрын
choices = list(Category.objects.all().values_list('name', 'name')) Why the for loop if I may ask?
by calling {{post.category}} on the home.html page, doesn't that imply there is a a one to many relationship between our two models? I don't remember putting in a foreign key for this tutorial.
@roppique2 жыл бұрын
Thank you very much for this video. but i have question -- how i can hide posts of any category from main page? but show in category list?
@Codemycom2 жыл бұрын
Use an if statement on the main page to filter posts any way you like :-)
@TungNguyen-fm3bt4 жыл бұрын
should i use like this ? categories = models.ManyToManyField('category.Category',help_text='Categorize this item.')
@milliondollarmotivation62604 жыл бұрын
I'm enjoying this series
@Codemycom4 жыл бұрын
Glad to hear it!
@erby6464 Жыл бұрын
in this tutorial you set up just one to one article to category how can i change it to be able to have one article in multiple categories
@antorzuck3 жыл бұрын
i want to select multiple category. how can i do this?
@Morimove Жыл бұрын
sir you are not using foreign key why? if any user manipulated the HTML and saved any other category which is not in the database then?
@shirishpatel71843 жыл бұрын
Excellent tutorial sir, one question - how can we order items alphabetically in category select option
@mediumshrimp96963 жыл бұрын
Is there a way to add in 2 different Categories to a Post? I'm coding a clothing store and have the categories for tops, pants, shoes, etc. but I also want to add Male or Female in a different dropdown. Is there a way to do this?
@universitystudio7424 жыл бұрын
i hope we can see more projects in the near future .ps : love your vids. keep up the good work and your chanel will grow evantually .
@Codemycom4 жыл бұрын
That's the plan!
@hariharanbalasubramanianpr42434 жыл бұрын
Sir, I have 4 Questions sir.. 1) When we deploy this blog suppose if I add another category is there a possibility that it might not show up in main Webpage(add category page)?? 2) Is it a good practice to do like restarting the server again after adding a category? 3) Is there a way to avoid this restarting the server?? Thanks,
@padybeats3 жыл бұрын
that's 3 questions ;-;
@HammadJilani-z3p4 ай бұрын
Can we not make category a foreign key just like we did for author field in Post class
@Codemycom4 ай бұрын
you can do anything you like, it's coding...
@som54883 жыл бұрын
If you are wondering how to add the category option to the edit form: Open up your forms.py. Under Meta>fields, include "category' Then under widgets, include the following code where you want your categories to show up: 'category': forms.Select (choices= choice_list, attrs= {'class': 'form-control'}), Save and then refresh your work.
@andrewwebberley22944 жыл бұрын
Love the video, had a few suggestions for videos (don't feel pressure), comments, like button, slugs (choose the url), and author pages!
@Codemycom4 жыл бұрын
Yep, going to try to hit most of those
@007rahulb4 жыл бұрын
Sir, I've created a category with name "JS". and also created a post with the same category. On my home page the post is showing up and in the dropdown too but when I click on the dropdown "JS" it says "404 error-no post available". I've noticed that "{{cats}}" which is supposed to be "JS", has become "Js'... How can I fix this?
@mhood823 жыл бұрын
I've been enjoying this series so far, but can't seem to get my category field to work properly. It insists on displaying as a text input instead of a select dropdown. My author field works fine, I've rewatched the video a couple times, scoured for typos, made sure to migrate, and even tried restarting my server several times. The choices also never displayed anything even when testing as a placeholder in title. Not sure what I'm missing...
@mhood823 жыл бұрын
Narrowed this down to my 'widgets = { ... }' not working at all. Fixed the main issue by defining the choices inside the Post model class Post(models.Model): categories = Category.objects.all().values_list('name', 'name') title = models.CharField(max_length=255) author = models.ForeignKey(User, on_delete=models.CASCADE) category = models.CharField(max_length=255, choices=categories) This seems to have the desired effect, but I need to figure out how to pass class names still.
@TheHeroesSquare2 жыл бұрын
@@mhood82 It helped me a lot as I had no idea what was wrong w the code. Thanks!
@elizabethkimberly80832 жыл бұрын
@@mhood82 Thank you sooooo much!!!!!!
@tawhidshaheed1454 жыл бұрын
When I want to submit any post find an error like ''Reverse for 'article-detail' with arguments '( '2', '3' )' not found . 1 pattern (s) tried: ['article/(?[0-9]+$']........... Please help me out...Sir
@angusgane484 жыл бұрын
Pause the video at 2:01. The get_absolute_url method has been changed to redirect to the home page instead of the article detail. I think your method might still be trying to get to 'article-detail'. I'm not clear why this needs to change though.
@adelcherfaoui50114 жыл бұрын
i ran through the same error before i noticed that the error start occuring when i try post the 10th post, and the get_absolute_url function find trouble redirecting to a detail page with an id with 2 digit number. so in the models.py instead of using parenthesis after the args in the get_absolute_url function. use brackets, otherwise it will cause a NoReverseMatch error, after ID = 10 (for two digits numbers id ) Example: return reverse('article_detail', args=[str(self.id)])
@ShadowStrikingNinjas4 жыл бұрын
Before creating the for loop for choice_list, when I simply set choices=choices in my select box, it worked as it was intended. It didn't return the "query set" jumbo. I guess maybe django has updated since this video was made? Nevertheless, excellent tutorial.
@euriperez95864 жыл бұрын
Is there a way to not have to restart the server everytime a category is created?
@tomiwaibrahim8514 жыл бұрын
Check out ModelMultipleCoiceField.
@bibekjoshi342 жыл бұрын
Hello sir! can't we make that ( to add category and append it right there in Add post page) like In WordPress we do... please help me out
@Codemycom2 жыл бұрын
I don't have any videos like that
@khachimicheal31923 ай бұрын
Hi john after adding the category, my username wont appear again what could be the problem
@Codemycom2 ай бұрын
you mistyped something somewhere
@invalidsb4 жыл бұрын
I was waiting for this... Video.. Sir
@Codemycom4 жыл бұрын
Glad you liked it
@selvijay26783 жыл бұрын
How do I sort the posts by months.
@baslaleandro2 жыл бұрын
If you use the output of Category.objects.all().values_list('name', 'name') directly into choices you get the same behavior without having to restart the server.
@chethanmgowda87184 жыл бұрын
Thank you and waiting for next video😎
@Codemycom4 жыл бұрын
Thanks for watching!
@kykurniawan4 жыл бұрын
sorry, i am new in python django, i have a question about this video, why you not using table relation to create post category feature ? ,
@viswamberprasad94183 жыл бұрын
he's using a Class Based View,and in that he has imported the Create View,which handles all the creation stuff for you,its basically like a function based view,but easier to code and manage. hope that helped!
@datakhukhua48894 жыл бұрын
Why u don't make relationships between post and category tables ? it will be better if we want to filter posts by category .
@animalcompilations8324 жыл бұрын
In forms.py file, choices = Category.objects... my vscode says "Category class has no objects", despite of that the code works... regards from Brazil
@vamsiKRISHNA-io1yi3 жыл бұрын
Its a problem with pylint. Just install pylint. I had the similar issue.
@animalcompilations8323 жыл бұрын
@@vamsiKRISHNA-io1yi thx
@Alfakhri993 жыл бұрын
Is there any way to add an image to category like having a category name and an image? anyone has suggestions please share tutorials , article or anything. Thank you
@duttybwoy5562 жыл бұрын
wouldn't it be much better quicker and easier to make a relationship? a foreign Key..... from the Post model category field to the category model... so the drop down menu is directly coming from the Category model and so you rid of all the parafernalia of for loops and lists and querying in the forms.py file.... I think... am I right? am I wrong??? 🤔 i think I'm right
@Nessa-u5l3 жыл бұрын
Great tutorial ! Thanks alot.
@Codemycom3 жыл бұрын
Thanks for watching!
@techieca-sreeharshabv31594 жыл бұрын
Hi Sir, If we need to add a particular article for more than one category, how can we do that sir?
@Codemycom4 жыл бұрын
Not possible as the code is currently written...would need to change it.
@rajkumarnepal3 жыл бұрын
@@Codemycom Please make another tutorial for this one. It would help for most of us.
@Codemycom3 жыл бұрын
@@rajkumarnepal sorry, I’m done with this one…
@prahladthelord46684 жыл бұрын
Sir .. How to render categories in django admin panel itself ?
@Codemycom4 жыл бұрын
Rewatch the video, I cover that exactly
@prahladthelord46684 жыл бұрын
@@Codemycom I mean dropdown in django admin panel ... not it our custom post page
@KunalVerma-gi3pq Жыл бұрын
if you put script to get choices inside the funtion, you will not need to restart server every time to add a new category.
@WingsDesign2 жыл бұрын
Hello good morning, I'm really enjoying your videos classes, congratulations, I wanted to know if there's a way to put just a few categories, without having to appear in the menu Exe: I have the category listed in the menu Police, education, politics, sports only I didn't want to show the sports category in the menu, But if I need to make a div with the sports category, it would appear, would it be possible? could you show me how to do it? Thanks in advance! And keep up your perfect work!
@dilipspk4 жыл бұрын
Without refreshing server category is not updating Is it good approach sir?
@Codemycom4 жыл бұрын
yes
@dilipspk4 жыл бұрын
I would appriciate if this issue resekved by anyone Sir, I applied it on my production level project but without restarting server object is not displaying in the front end But object is saving What would be the issue and what has to be done for that?
@euriperez95864 жыл бұрын
@@dilipspk stackoverflow.com/questions/3419997/creating-a-dynamic-choice-field this helped me to correct the issue, so you don't need to restart server
@khodok96364 жыл бұрын
@@euriperez9586 which answer to be exact ? the first one ? can you tell exactly what you did ?
@euriperez95864 жыл бұрын
@@khodok9636 create a new model called Category and then in your other model use a ForeignKey field that points to the model Category, so now you can even add categorys trought admin panel.
@rajkumarnepal3 жыл бұрын
Can you please add the tutorial for blog category with multi-check fields like in WordPress. Regards
@towhidurrahman89612 жыл бұрын
hey! Your tutorials are awesome. can you make a video on "Auto Posting on Facebook, Twitter, Instagram, LinkedIn & All Social Media platform" for us? we want our blog post to go viral on social media platforms without any extra work. Is it possible with django? Please let me know. thanks again.
@Codemycom2 жыл бұрын
No sorry
@ogananfe2 жыл бұрын
I think the problem with the categories has to do with the fact that the forms.py file is only read once when the server is initially started and the forms are originally imported so the choice_list is only declared when the file is initially read. You need to retrieve the categories from the database ever single time the forms are retrieved not just when the forms are originally imported to ensure the most recent data are used. Am not sure tho cos i haven't tried it out yet😂 i just used a foreign key to link to my categories model
@sayori39392 жыл бұрын
Yeah it seems a foreign key is much more suitable but be aware of the on_delete option, we don't wanna delete every single post with a certain category if we ever delete said category
@akkutabussova61094 жыл бұрын
Good video! But why didn't you use a foreign key like the author?
@shezikhan59344 жыл бұрын
Sir how to hide author field from form.
@invalidsb4 жыл бұрын
Ya 1 week... Sir.. Looking handsome. 😋😊
@Codemycom4 жыл бұрын
ha
@rezarezaee77393 жыл бұрын
how can i create category field like author field with ForeignKey?! ty for nice tutorial!
@Codemycom3 жыл бұрын
In the same way
@fareedyarkhan84623 жыл бұрын
The best way you can use catagoreys as foreign key in post model
@bibekjoshi342 жыл бұрын
can you please Guide to create category System Like WordPress
@madusan14 жыл бұрын
Why would you not have used category as a 1 to many table. Sand markup tables appropriately. Your method does not protect against duplicates
@Codemycom4 жыл бұрын
We're working up to more advanced topics like relationships
@roguepanda20324 жыл бұрын
thanks man !!!!
@Codemycom4 жыл бұрын
No problem!
@davishek73 жыл бұрын
Thank you.
@Codemycom3 жыл бұрын
Welcome
@brettgastelum53304 жыл бұрын
I got an error saying that the class 'Category' has no objects member.
@Codemycom4 жыл бұрын
Check your code for typos
@brettgastelum53304 жыл бұрын
@@Codemycom copy pasta'ed all the 'Category' text to make sure it was uniform across the board and reread what was on the screen multiple times. Everything looks correct. This has happened to me once before though... I was trying to make the Polls app directly off the Django website and this exact same problem came up. I can see that there are indeed objects in the Categories class, for whatever reason they're not being read by the code here.
@brettgastelum53304 жыл бұрын
@@Codemycom =.=....... Had to add this to my settings.json: "python.linting.pylintArgs": [ "--load-plugins=pylint_django" ], Now I'm not getting the error. I've been feeling like I need to switch to something other than VS Code lately, I just like the way literally everything else is laid out. Just seems like this one in particular takes a LOT to get it to work properly, it's definitely not an "out-of-the-box" vibe.
@Codemycom4 жыл бұрын
@@brettgastelum5330 I'd never paste code...python requires correct indentation that often gets lost when you copy/paste
@anirbanraha334 жыл бұрын
I'm getting the same error . What should I do ?
@miraccan004 жыл бұрын
we can add slug field I think :D
@miraccan004 жыл бұрын
why we don't use relation one to many ? because one post has many categories ?
@Codemycom4 жыл бұрын
because I haven't gotten to that...right now our blog posts have one category
@vukspasojevic23963 жыл бұрын
No need for restarting the server if you use the ForeignKey field to Category model. Also, it would be a good example to show in this case what to do with the database and migration files and how to reset everything.
@jenilchudgar3 жыл бұрын
Categories: Knitting😆😆
@Codemycom3 жыл бұрын
lol
@jenilchudgar3 жыл бұрын
Is this series over?
@Codemycom3 жыл бұрын
@@jenilchudgar Yes, for like over a year I think. There are 36 videos in the playlist.