Maksim
Or first_name
Денис
Not the best way, I think. Slug is a slug on purpose, it was invented for online newspapers and serves for creating unique URLs. So you should have separate first_name and slug fields. Read about SlugField in the docs
Денис
I don't care what is slug I just want to use str as not integer
then you probably need any string field with unique=true. And remember that spaces can be used in names, which can't be used in URLs and are "slugified" (replaced by hyphens) in slug fields. I can't help you now because I lack time for this. Read Django By Examle, there's a good example of slugs in their best form of usage.
Ram
How do i get the current user's username in django
Ram
How do i upload image to the folder which is named after the current user Example:- If user XYZ uploads the image,then i want the image to be uploaded to his folder(named XYZ)
Ram
Ya i what should be argument of upload_to?
Mirco
Ya i what should be argument of upload_to?
A method where you can use instance object
Ram
I want image to get uploaded at different files not same
Mirco
I want image to get uploaded at different files not same
https://simpleisbetterthancomplex.com/tutorial/2016/08/01/how-to-upload-files-with-django.html
Mirco
Read it
Ram
I used instance.username
Ram
Explain better
If i upload a image it should go to folder named "Ram" If you upload a image it should go to folder named "micro"
Ram
So that each and every user will have the folder named after him. Which will contain images uploaded by just him/her
Anonymous
How to user email authentication in django?
Mirco
If u pass a method to upload_to and create a folder with instance.username ( if it's unique ), it will work
Mirco
How to user email authentication in django?
Extend default user and then another couple of things
Mirco
Any example?
Google it 😁 it's plenty of it out there
Mirco
Its not working.
It's up to your code
Mirco
That technique works 😊
Anonymous
How go show products in home page from models like amazon
Ram
That technique works 😊
Tell me one thing Do i need to make a folder before running the project Or will it automatically create a folder
Mirco
https://docs.djangoproject.com/en/2.2/howto/static-files/
Jimmy
How go show products in home page from models like amazon
[In reply to Tanuja] create a form or a view to cycle through (loop) the models i.e """model.objects.all()"""
S
If i upload a image it should go to folder named "Ram" If you upload a image it should go to folder named "micro"
You can maintain two different folders by using django storage default_storage.open(path,filename) and can maintain sometypes of file here and there by putting condition on file's extention. filename.split[:1]
S
I used to do this when I am dealing with S3 bucket.
Ram
2 folder was just an example
Pedro
do anybody have a good tutorial of django ...? i get this one https://www.youtube.com/watch?v=F5mRW0jo-U4
Doragonsureiyā
do anybody have a good tutorial of django ...? i get this one https://www.youtube.com/watch?v=F5mRW0jo-U4
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Pedro
excelent... thanks
Anonymous
Anyone here knows how do I download unity on Ubuntu
Doragonsureiyā
Anyone here knows how do I download unity on Ubuntu
That is not a Python specific question, please move to @PythonOfftopic and ask there.
🧩
Guys, when go to http://127.0.0.1:8001/admin/ get this
🧩
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8001/admin/ Raised by: news.views.PageViews
🧩
class PageViews(ListView): template_name = 'page.html' paginate_by = 8 context_object_name = 'posts' ordering = ['-datetime'] model = Page paginate_orphans = 1 def dispatch(self, request, *args, **kwargs): slug = kwargs.get('slug') try: self.category = Category.objects.get(slug=slug) except Category.DoesNotExist: raise Http404 return super().dispatch(request, *args, **kwargs) def get_queryset(self): return Page.objects.filter(category=self.category)
🧩
What problme?
Ghorz
I m developing a Ecommerce Book selling web app using django. I m facing a problem, I tried to make the payment method same as Amazon (only for demo) so when i buy product , I enter the name , and details of user and also card details for payments and vice versa, lets say two users buy different product but when i go and check my orders page , it shows my product with my payment details and and also his product with my payment details and his name and payment details with my product and hia product. I m not able to solve this
You got a long way to go man! The mistake early developers make is rushing into developing complex systems. My advice, learn Django properly, follow a few tutorials and complete them. Start pet project, like book library, photo gallery, portfolio systems. After that, you can start diving deep. I created a shop system with live payments gateway called paystack, the paystack plugin was dev by me. It was a hell of a journey but interesting. You will process payment, get status, update shopping status, generate receipts,..... https://ghorz.com/shop/ Good luck
Ghorz
For Beginners, django girls is your best bet.
The Summer
Guys I have a problem I want to sent books objects of current page's author not all author's books So plz see and tell me how I can do it Here is pastebin https://pastebin.com/EjvZEiyR
The Summer
Can u write
The Summer
I tried but got some errors
Anonymous
Can u write
https://docs.djangoproject.com/en/2.2/topics/db/queries/
The Summer
See I get specific when I manually write Book.objects.filter(author=1)
The Summer
how to write variable instead of that 1 That 1 should be id of current page(author/1)
Anonymous
Book.objects.filter(author=user.id)
The Summer
I tried this too
The Summer
I get int() argument must be a string, a bytes-like object or a number, not 'DeferredAttribue'
Anonymous
Go through www.nseindia.com and derive the following data about the input stock-list ( mentioned at the end). Data required: Open, High, Low, Close, Volume, Delivery Data, Delivery Percentage Input stock-list: RELIANCE, HDFCBANK, ADANIPORTS, ITC, SBI, IOC, RBLBANK, SBI Use necessary libraries to present the data obtained in a user-readable format. The code must include one function which takes the stock as input and return the data required in the user-readable format
Anonymous
any one please answer this
Anonymous
..
change user.id to author.id
The Summer
Yeah I did that I don't have user model so
Anonymous
I will need to see your models file. Too lazy to think properly at the moment
Anonymous
dm
Tony
Whenever you give a view an argument apart from request you have to add that argument to the URL of that view. I want to know if there is a way I can avoid that.
Rafael
Dear guys ! Which frontend are you using ? Thank you .
Rafael
HTML/CSS/JS
do you use some js framework. ?
Rafael
thank you
cj
do you use some js framework. ?
no, I'm mainly back-end engineer, but I did some small things with VueJS
Anonymous
angular8
Rajab
Dear guys ! Which frontend are you using ? Thank you .
Vuejs is a simple for learning and reactive👍
Vachagan Muradyan
How to add multiply images to one model in django?
Vachagan Muradyan
I don't want to add multiply imagefield
cj
add an ArrayField of ImageField