I've heard using default user model for creating a user system isn't always good. Instead of that, using custom AbstractUser is preferable. Any comment on that? How that can make any difference?
@@Jobin-at-CodingOutright When you starting a project, you never know if you'll need some extra fields in user class later, so in real-world projects, it's a good habit to create a custom user class. If you create a profile connected to the user, you need signals to make this connection work both directions.
at 39:01 am getting an error: FieldError at /cart/ Cannot resolve keyword 'customer' into field. Choices are: Customer, Customer_id, complete, date_ordered, id, orderitem, shippingaddress, transaction_id
@@iankemboi2015 check your models.py foreign key field. You might have added 'C' instead of 'c' while assigning foreign key relation of 'Customer' model on some other model.
Thanks man, it was very helpful. Also if someone is looking for an alternate way to handle no image case add this in your HTML template inside for loop {% if product.image %} {% else %} {% endif %}
Thanks man. Django it's been the only framework that really worked for me on the back-end; finding such a comprehensive and best-practice oriented guide it's a bless. Thanks a lot!
Thank u Dennis for this amazing tutorial, One suggestion instead of creating all the classes at once it would be even better to create one by one by rendering in templates so that it would be even easier for us to understand why we need this specific attribute as organization of models is super important.
Hi, for people still having the issue about User has no attribute customer, you have to do two things: 1- in admin page add a new customer (you as superuser) 1- add on Customer model in user object "related_name='customer" You should not have this error anymore hope it helps
@53:30 line 62 the quantity will be x{{item.quantity}}. Since you had "2" before it the checkout page showed 22 headphones and 21 Mount of Olive books.
Thank you so much Dennis for this series. I've a question that how do we know what to make model of? Like how do we know that we have to make Order, Shipping address, Customer as model and how do we know which one to be our views?
Models are persistent data that your web app need to be dynamic, that being said you can simply know when to create a model by asking this question "Is this information needed again".
Thank you for this great series :) This question is for anyone, how would you go about tracking inventory/stock? Do you make an object for inventory/stock that decreases with each processed order, and, loop through it until an item in the order makes the object equal to zero? Or would you use some other external/open-source inventory management system? Apologies if this has already been covered. I am a newbie and would appreciate any guidance or thoughts on this.
That is actually quite a good question and quite easy to implement. The way you mentioned is not the way I would implement it These are the steps I would do 1) Inside your Product model add a stock_qty field this would be the number of stock items you have for each particular product/Item 2) For each item deduct the number the customer has purchased from the product's stock belonging to that item. You can do this after a customer has successfully purchased an item or items. To view the items in your stock you can create a template called stock.html 1) Inside your stock.html template add the following fields a) Product ID b) Product title c) Product price 4) Stock qty 2) Inside your views.py file add "view_stock" no need to add a product ID because you want to view all the items 3) Write the following method inside your view file and pass it inside your context then pass it into your stock.html template products = Product.objects.all() Inside your stock.html template write the following for loop e.g {% for product in products %} {{ product.id }} {{ product.title }} {{ product.price }} {{ product.qty }} {% endfor %} 5) You can add conditions inside your home page to only display items if there are stock e.g #That will only display items that are in stock {% for product in products %} {% if product.stock_qty > 0 %} code here {% endif %} {% endfor %} or you can display the page with a disabled button, in that case, you would write. This way the customer knows that you have the item but it is currently not in stock. {% for product in products %} {% if product.stock_qty
for anyone having problem with rendering items in cart.html you can try to change the item.product to item.customer or to follow along with the series go to models and change inside Orderitem class the customer instance to product
Hey man thanks a lot for all the time and effort u put in here 🙏 I have question about your database structure if i may Why do u have customer and user? And again order and orderitem? Im kinda confused
This is the best tutorial I've ever followed. Legitimately. I bought the premium codewithsteps just to support. Thank you Dennis, please make more of these! Question though - Why don't we need to pass orderitems as context and only order for rendering totals in cart.html?
@@PrinceBubezi it is automatically set when you don't specify a name AKA "related name" ,search for "related name" and you will find answer for your question
That is extremely useful mate! I think that data structures in an e-commerce website are probably the hardest part. Would it be better to think of class-based views? They might offer more flexibility and functionalities, besides less code, which is always a good thing.
@Dennis, i have a question maybe you can solve it, in this part, you connect your customer's model to the User model from the default django model, but in this case I have my own model for the user, in this case I need to connect my own user's model to the customer in replace of the default ?
you should configure this on the setting file and since that instead user = models.OneToOneField(User,....) you should write user = models.OneToOneField(settings.AUTH_USER_MODEL,....) of course don't forget the required imports
first thank you our instructor, Mr Dennis lvy, after that, there is little bit confusion i have and that is why Order and OrderItem models/tables are needed? what is the purpose of these two models? could i finde someone or -even Mr Dennis lvy- who can explain to me this matter? thank you all of you
Hello, i'm Destiny. OrderItems keeps track of diffrent product and thier quantity that a customer want to order, then the Order keeps track of all the OrderItems that a user have added to thier card, NOTE: OrderItems is just like the products that would be in the cart. To be more explicit - [ "2 Bags, 1 Iphone, 3 pair of shoes" ] are order items then [Order 1] would not be incharge of getting all the [ "2 Bags, 1 Iphone, 3 pair of shoes"] that a customer have added to thier cart.
Sir, thanks for teaching us. please make a tutorial to customize this admin panel to some stylish bootstrap admin panel. We really hate this admin panel design. Thank You
Good morning Thanks for this video. Here I am currently encountering a problem with the management of images from the database. When the debug is true, everything goes well with all the configurations but when the debug is false the images are no longer displayed. If you could help me that would be really great
If you reference User directly (for example, by referring to it in a foreign key), your code will not work in projects where the AUTH_USER_MODEL setting has been changed to a different user model. User = get_user_model()
Greetings dear Dennis for this comprehensive video When I try to add new order through the admin panel COMPLETE icon has no dropdowwn list with: NO as it appears in your video although my setup in orders class in models.py as below: complete = models.BooleanField(default=False)
Thank you, Q: if I have users and I as admin add forms connected to each other and want to collect data from users, note: every 3 months forms different
Cannot resolve keyword 'customer' into field. Choices are: Customer, Customer_id, complete, date_ordered, id, orderitem, shippingaddress, transaction_id. I am stuck here whenever I am logged in admin, I can't go to cart. Please help with the error. Thank you
Make sure that your field that have the foreignKey is like this ``` class SomeModel(models.Model): # … field=models.ForeignKey(default=1, on_delete=models.CASCADE, to='main.Category') ```
Thanks for this tutorial. I have one question, looking at the documentation for Django it says I should add to settings Installed Apps only the name of the app. We added 'store.apps.StoreConfig', but according to doc only 'store' should be added, or am I getting it wrong? I used your method before so I am little confused why they write so.
We use 'appsname.apps.StoreConfig' to add some things to app, like change app's name on admin page or somethins like that but, if not changes are done there, with 'store' is enough
Thank you for such brilliant course. I have a doubt at 50:43 and also previously you are using item.product.imageURL, this was is not working for me I have to use item.product.image.url same as you used in store.html for rendering images. Whats the problem here why am I not able to do this?
First Thanks for the clear explanation of all the set ups. I have 1 problem when removing the attachments from products. The attachment is not removed from the static/images folder so when I want to add the picture again it gets a strange unique number with it. Is that how it should work? oOr should the picture also be removed from the static/images folder?
Hi dennis. I have been following your instructions and while creating users i have errors like django.contrib.auth.models.User.customer.RelatedObjectDoesNotExist: User has no customer. Can you help me out with it? really appreciate you
Yo Dennis, you fuckin rock man, thanks for the tut! I'm trying to switch from event design to programming and your tutorials are the best! Where's your mailing list? I'd sign up lol.
I am having a trouble, i am currently in 20:21 where the products rendered should showing on the main screen. My problem is that I am very sure i have done all the codes correctly but the boxes for me wont show unless i remove the {% for product in products %} and {% endfor %} But i need them
Hi Dennis, nice tutorial. I am following this and in 32:42 you are editing the models.py wiht @property decorator. I thought whenever the models.py is changed then it has to be done migrations (python manage.py makemigrations, python manage.py migrate) But somehow it works without the migrations. Why is that please? Thank you
00:00 - Introduction
1:40 - Build Models
17:50 - Render Products
23:25 - Product ImageField()
33:35 - Render Cart data
42:40 - Cart Total's
50:25 - Checkout page data
I've heard using default user model for creating a user system isn't always good. Instead of that, using custom AbstractUser is preferable.
Any comment on that? How that can make any difference?
@@Jobin-at-CodingOutright When you starting a project, you never know if you'll need some extra fields in user class later, so in real-world projects, it's a good habit to create a custom user class. If you create a profile connected to the user, you need signals to make this connection work both directions.
at 39:01 am getting an error:
FieldError at /cart/
Cannot resolve keyword 'customer' into field. Choices are: Customer, Customer_id, complete, date_ordered, id, orderitem, shippingaddress, transaction_id
@@iankemboi2015 check your models.py foreign key field. You might have added 'C' instead of 'c' while assigning foreign key relation of 'Customer' model on some other model.
@@clauseclause6640 thanks man
Don't forget to check out my Complete Django course: dub.sh/NvGboTI
Thanks man, it was very helpful. Also if someone is looking for an alternate way to handle no image case add this in your HTML template inside for loop
{% if product.image %}
{% else %}
{% endif %}
Also, good thing to look up is Django filters, such as default (provides specified default when the value evaluates to False)
thank you so much
Thank you Sir.
Great!
Thanks man. Django it's been the only framework that really worked for me on the back-end; finding such a comprehensive and best-practice oriented guide it's a bless. Thanks a lot!
Thank u Dennis for this amazing tutorial, One suggestion instead of creating all the classes at once it would be even better to create one by one by rendering in templates so that it would be even easier for us to understand why we need this specific attribute as organization of models is super important.
if you have followed his crash course , then there he has explained these in detail
Integrated content.
I wish you success, your explanation is the best compared to paid courses.
Really, thank you.
Thank you very much, Dennis. This course is actually the best free ecommerce website building course ever!
Great job, if anyone has error for rendering image. Try do delete all products and do it again with image
I am having issue . I did all correctly but no idea why image is not uploading.
it's working, Thank you
Definitely paying $12 for this. Totally worth it.
can u share the tutorials with me as well as i cant buy premiun module
Hi, for people still having the issue about User has no attribute customer, you have to do two things:
1- in admin page add a new customer (you as superuser)
1- add on Customer model in user object "related_name='customer"
You should not have this error anymore
hope it helps
Thanks for help, i have this issue but honestly that didn't help still gettin the same error user has no attribute customer
i could fix it, it was not releted to related_name but just typo, user.customer in Order model i wrote with capital C so should be user.Customer
Tnx man
This is brilliant Dennis. You're really helping out.
Observation at 53:24, we should remove the hardcoded x2 value there
@53:30 line 62 the quantity will be x{{item.quantity}}. Since you had "2" before it the checkout page showed 22 headphones and 21 Mount of Olive books.
I needed some course to be done in this quarantine thanks for this amazing series
Thank you so much Dennis for this series. I've a question that how do we know what to make model of? Like how do we know that we have to make Order, Shipping address, Customer as model and how do we know which one to be our views?
Models are persistent data that your web app need to be dynamic, that being said you can simply know when to create a model by asking this question "Is this information needed again".
Amazing video! I'm a beginner on Python and Django and this really helpful me, thanks a lot! regards from Argentina :)!
Thank you for this great series :)
This question is for anyone, how would you go about tracking inventory/stock? Do you make an object for inventory/stock that decreases with each processed order, and, loop through it until an item in the order makes the object equal to zero? Or would you use some other external/open-source inventory management system?
Apologies if this has already been covered. I am a newbie and would appreciate any guidance or thoughts on this.
That is actually quite a good question and quite easy to implement. The way you mentioned is not the way I would implement it
These are the steps I would do
1) Inside your Product model add a stock_qty field this would be the number of stock items you have for each particular product/Item
2) For each item deduct the number the customer has purchased from the product's stock belonging to that item. You can do this after a customer has successfully purchased an item or items.
To view the items in your stock you can create a template called stock.html
1) Inside your stock.html template add the following fields
a) Product ID
b) Product title
c) Product price
4) Stock qty
2) Inside your views.py file add "view_stock" no need to add a product ID because you want to view all the items
3) Write the following method inside your view file and pass it inside your context then pass it into your stock.html template
products = Product.objects.all()
Inside your stock.html template write the following for loop e.g
{% for product in products %}
{{ product.id }}
{{ product.title }}
{{ product.price }}
{{ product.qty }}
{% endfor %}
5) You can add conditions inside your home page to only display items if there are stock e.g
#That will only display items that are in stock
{% for product in products %}
{% if product.stock_qty > 0 %}
code here
{% endif %}
{% endfor %}
or you can display the page with a disabled button, in that case, you would write.
This way the customer knows that you have the item but it is currently not in stock.
{% for product in products %}
{% if product.stock_qty
@@abbysands9510 thank you for taking the time to write a helpful reply
@@danielanderson713
No problem
This ecommerce seris is best.. i have learned so many thigs from this..thanks buddy
for anyone having problem with rendering items in cart.html you can try to change the item.product to item.customer or to follow along with the series go to models and change inside Orderitem class the customer instance to product
Bro could you give me an example for this? I am new to Django, Thank you
Hey man
thanks a lot for all the time and effort u put in here 🙏
I have question about your database structure if i may
Why do u have customer and user?
And again order and orderitem?
Im kinda confused
thanks for this tutorial but I have a question about categories of products you didn't mention it, it would be great if you added it into the database
Yes, it would be better if it had categories, anyways I tried my own way by making different models for each category
Thanks for the great tutorials. One question though, have you coded the functionality of logging in?
This is the best tutorial I've ever followed. Legitimately. I bought the premium codewithsteps just to support. Thank you Dennis, please make more of these!
Question though - Why don't we need to pass orderitems as context and only order for rendering totals in cart.html?
can u share the tutorials with me as well as i cant buy premiun module
Thank you for your amazing work. I really did not understand where we did get orderitem_set in 45:32
Has anybody found the answer to this question?
@@PrinceBubezi it is automatically set when you don't specify a name AKA "related name" ,search for "related name" and you will find answer for your question
it is automatically set when you don't specify a name AKA "related name" ,search for "related name" and you will find answer for your question
@@mohamedalsayed2008 I still can't do it, do you have any other solution. Furthermore, did you fix it?
This is amazing
Excellently explained but i have one suggestion can you please make a video or tutorials about REST API with django..
That is extremely useful mate! I think that data structures in an e-commerce website are probably the hardest part. Would it be better to think of class-based views? They might offer more flexibility and functionalities, besides less code, which is always a good thing.
Not just in an e-commerce website, A company is as big as it database. For all software data is the life.
48:13 " hope that wasn't too confusing " hits hard
I am really grateful for this tutorial. I learnt alot from this.
Thank you, complicated process explained in a simple way!
Finally found a perfect channel for my python training..do you offer full course training on python?
Dennis have you ever thought about doing this with Class Based Views and CRUD with REST API. Front end requesting from api?
Hello, thanks for this informative tutorial but how to pay for reading all the modules?
@Dennis, i have a question maybe you can solve it, in this part, you connect your customer's model to the User model from the default django model, but in this case I have my own model for the user, in this case I need to connect my own user's model to the customer in replace of the default ?
you should configure this on the setting file and since that instead user = models.OneToOneField(User,....) you should write user = models.OneToOneField(settings.AUTH_USER_MODEL,....) of course don't forget the required imports
So thankful about this course! Thanks for your work
Thank you so much for your effort!! Clear and easy after watching your video. Save tons of time. Thank you!!!
Thanks bro you are the best and underrated❤
thank bro i speak french but your video is nice and you explain very well! please continue to share other video, im your student
This duuude is DA Best
How can I thank u for this, this is amazing
भाई आप भी ये सीख राहे हो क्या
Buy the course from his website
Hi Dennis!
I speak here from Brazil. Are there more Django courses in the same teaching format on your course platform?
first thank you our instructor, Mr Dennis lvy, after that, there is little bit confusion i have and that is why Order and OrderItem models/tables are needed? what is the purpose of these two models?
could i finde someone or -even Mr Dennis lvy- who can explain to me this matter?
thank you all of you
Hello, i'm Destiny. OrderItems keeps track of diffrent product and thier quantity that a customer want to order, then the Order keeps track of all the OrderItems that a user have added to thier card, NOTE: OrderItems is just like the products that would be in the cart. To be more explicit - [ "2 Bags, 1 Iphone, 3 pair of shoes" ] are order items then [Order 1] would not be incharge of getting all the [ "2 Bags, 1 Iphone, 3 pair of shoes"] that a customer have added to thier cart.
this tutorial is really amazing. thanks dennis!
I already put the decorator property in image for class Product but still The 'image' attribute has no file associated with it.
Thank you for this amazing tutorial I have done successfully the second part
Sir, thanks for teaching us. please make a tutorial to customize this admin panel to some stylish bootstrap admin panel. We really hate this admin panel design. Thank You
Thanks a lot Dennis Ivy 💪💥👍.
Do you have a React tutorial
your videos really helps me bro!!!
Amazing tutorial man, keep it up!
Really helpful
Thanks Dennis
Чувак, ты крут. Просто, знай, ты крут. А я счастливчик. Спасибо тебе, большое!
You are a great teacher. Thank you
Amazing lessons, thanks a lot from Ukraine!
Thank you for this video. please how can I handle the variation product like Size, color ...?
I can't thank you enough, very helpful.
wonderful tutorial dennis.
39:30 "order, created" what does that mean and how does that work? I couldn't understand this part
thank you bud , it is really helpful for me
AttributeError at /cart
'User' object has no attribute 'customer'
I have the same problem / Marcin
same problem here
You only need to change the customer to the user that you created in super user.
42:44 - You can also use custom template tagging to do the same thing.
Good morning
Thanks for this video.
Here I am currently encountering a problem with the management of images from the database. When the debug is true, everything goes well with all the configurations but when the debug is false the images are no longer displayed.
If you could help me that would be really great
Dennis,if I pay can I access the future courses that u post them in ur site?
Or it is the price for only this
Thank you !!! God bless you 🙏
If you reference User directly (for example, by referring to it in a foreign key), your code will not work in projects where the AUTH_USER_MODEL setting has been changed to a different user model.
User = get_user_model()
Greetings dear Dennis for this comprehensive
video
When I try to add new order through the admin panel COMPLETE icon has no dropdowwn list with: NO as it appears in your video
although my setup in orders class in models.py as below:
complete = models.BooleanField(default=False)
There are some problems with the sourcecode especially in the part with adding the @property and the images.
same here
No issue at all bud!
Thank you very much brother
Awesome explanation!!
do you have images in this tutotial and could you share it to me
please
proud of u sr
Superb, Thanks alot bro
Thanks and Great tutorial. Bravo!
Thank you so much! This course is amazing ;D
Thank you, Q: if I have users and I as admin add forms connected to each other and want to collect data from users, note: every 3 months forms different
Cannot resolve keyword 'customer' into field. Choices are: Customer, Customer_id, complete, date_ordered, id, orderitem, shippingaddress, transaction_id. I am stuck here whenever I am logged in admin, I can't go to cart. Please help with the error. Thank you
me too still didn't get the answer
Me too sadly
Really awesome..... Thanks mate
Thanks a lot sir, you're amazing
plz how to fix the error on_deleted must be callable ... thanks alot for the amazing vidio will keep u in my preyer i learned alot thanks again
Make sure that your field that have the foreignKey is like this
```
class SomeModel(models.Model):
# …
field=models.ForeignKey(default=1, on_delete=models.CASCADE, to='main.Category')
```
thanks you, very useful tutorial
hey Dennis ,I am great fan of your work.... can you make a project on e-learning platform with video subscription features
Yes I actually had something like that in mind but it may be a while before I make it :)
@@DennisIvy thanks dennis
Thank you men, this is awesome
Thanks for this tutorial. I have one question, looking at the documentation for Django it says I should add to settings Installed Apps only the name of the app. We added 'store.apps.StoreConfig', but according to doc only 'store' should be added, or am I getting it wrong? I used your method before so I am little confused why they write so.
We use 'appsname.apps.StoreConfig' to add some things to app, like change app's name on admin page or somethins like that but, if not changes are done there, with 'store' is enough
спасибо денис
Thank you for such brilliant course.
I have a doubt at 50:43 and also previously you are using item.product.imageURL, this was is not working for me I have to use item.product.image.url same as you used in store.html for rendering images.
Whats the problem here why am I not able to do this?
SURAJ BRANWAL ImageURL is a function in Product class
Thank you so much love from india
:)
Thank you so much for the video
Thank You for your effort!
I installed X terminal package from atom, open 2 terminals and i moved both at the bottom, is great
Amazing tutorial
Дякую!
hello , thank you for your awesome project , for order model there no id how i can fix it
First Thanks for the clear explanation of all the set ups. I have 1 problem when removing the attachments from products. The attachment is not removed from the static/images folder so when I want to add the picture again it gets a strange unique number with it. Is that how it should work? oOr should the picture also be removed from the static/images folder?
I suppose, that you should upload the pic directly from the admin panel, so you might delete the original pics from your static files.
Do u feel using these forms are better than model Forms?
PERFECT! thanks !!
Hi dennis. I have been following your instructions and while creating users i have errors like django.contrib.auth.models.User.customer.RelatedObjectDoesNotExist: User has no customer. Can you help me out with it?
really appreciate you
How did u solve this ? Plz can u tell me I got an error at this
@@gouthami_pittala have you solved this, can you please help me
Yo Dennis, you fuckin rock man, thanks for the tut! I'm trying to switch from event design to programming and your tutorials are the best! Where's your mailing list? I'd sign up lol.
Thank you, This is amazing
Thanks again man!
Sir please help...
Error occurs RelatedObjectDoesNotExist at /Cart/ ...User has no customer.
Sir please reply
I am having a trouble, i am currently in 20:21 where the products rendered should showing on the main screen.
My problem is that I am very sure i have done all the codes correctly but the boxes for me wont show unless i remove the {% for product in products %} and {% endfor %}
But i need them
Hi Dennis, nice tutorial. I am following this and in 32:42 you are editing the models.py wiht @property decorator. I thought whenever the models.py is changed then it has to be done migrations (python manage.py makemigrations, python manage.py migrate) But somehow it works without the migrations. Why is that please? Thank you
when the function inside the model is modified, then there is no need for makemigrations and migrate.
awsome and easy to learn
I am having problem with for loop in video around 30:00 my div is going invisible I think the object is not able to connect with Product class
Hello! I have the same problem . Have u managed to solve it ? please share what u have done!
I guess both of you didn't close some (img?) tag