These are chat archives for django/django

21st
Feb 2017
kpagcha
@kpagcha
Feb 21 2017 08:55
I'm looking for a package to humanize amounts of time, i.e. you give the number of seconds/minutes and you get any of these depending on the value: "10 minutes", "1 hour and 30 minutes", "1 day and 12 hours". I tried using humanize.naturaldelta but it says "a" instead of "1" and it cuts off the second part (i.e. it just returns "1 day" instead of "1 day and 12 hours")
Cyber Xucyc
@Cyber-host
Feb 21 2017 10:26
hi, all. I'm new in python. which IDE do you use? thx.
akilesh
@akileshv
Feb 21 2017 10:50
i am new to python what is equivalent console.log() in python
Gourav Chawla
@Gouravchawla
Feb 21 2017 11:24
@Cyber-host PyCharm is a good IDE and python comes with an IDE called IDLE.
@akhileshv It's print statements. Look for it.
Theofanis Despoudis
@theodesp
Feb 21 2017 11:26
I like vscode but pycharm is more of a heavy horse
Gourav Chawla
@Gouravchawla
Feb 21 2017 11:27
@theodesp Does vscode support django programming?
Just out of curosity.
Theofanis Despoudis
@theodesp
Feb 21 2017 11:31
Sure if you use the python plugin you can do it
Gourav Chawla
@Gouravchawla
Feb 21 2017 11:36
Okay. That's cool then.
prashante114
@prashante114
Feb 21 2017 13:52
I am new to Django, I am trying to develop an ecommerce project in django.
I want to use Add to cart functionality like every ecommerce website has it, but I am facing some problems due to unapropriate guidence.
Could anyone tell me, to build "Add to cart" functionality, is there any proper documentation in django which tells the complete flow of it?
Or, Any third party plug in available which I can integrate it with my project by PIP Install command? Or, any tutorial available which would help me?
Gourav Chawla
@Gouravchawla
Feb 21 2017 14:01
@prashante114 Look for tutorial by coding for entrepreneurs. He did a project on ecommerce.
Miracle Ayodele
@iammiracle
Feb 21 2017 14:34
hi guys
i have three fields
one shows name, the second is a selection of ids
i want the third to change value based on the selection made on the second selection
any idea on how to go about this?
Fabian
@fabiand93
Feb 21 2017 14:37
you can make a chain of strings plus a secuence or a random numer @koderNeptune
the third field it's for what?
Miracle Ayodele
@iammiracle
Feb 21 2017 14:38
@fabiand93 is to show the amount of the product_id
Fabian
@fabiand93
Feb 21 2017 14:41
so it's a product[2]
where product[0]= names
product[1]=id
product[2]=amount
like that
you create the object product and you can save it on a db or in a file and then consult that @koderNeptune
Kaushal Kumar
@kaushal087
Feb 21 2017 14:42
hi, I want to use https://github.com/makinacorpus/django-screamshot , but it is giving me error
AttributeError: 'module' object has no attribute 'SubfieldBase'
Fabian
@fabiand93
Feb 21 2017 14:45
hi @kaushal087 I already checked the github and there was an issue that it's already closed:
makinacorpus/django-screamshot#43
Miracle Ayodele
@iammiracle
Feb 21 2017 14:46
its already in the database @fabiand93
but i need the amount to change based on the selected id
the filter that shows the name and the product_id is based on request.user
so the id is displayed based on the current login user
if anoda user login, anoda id will populate on the id field
but i need the amount of the ids to change based the id selected
i hop u understand my point @fabiand93
Kaushal Kumar
@kaushal087
Feb 21 2017 14:49
@fabiand93 thanks
Fabian
@fabiand93
Feb 21 2017 14:54
@koderNeptune Not sure if I'm getting it but if you create a separate object? why if they make a request, why the id of the product changes?
the id of the product shouldn't change for a client request. Are you treating them as separate objects?
Miracle Ayodele
@iammiracle
Feb 21 2017 14:55
noo, the id is not changing
i want the amount to change
based on the id
d id is in a selection form
so if i click on id 2de34 i should have 2000 in the amount form
if i select id 1wef34 the amount also should show on the amount form
Sopan
@sopanshewale
Feb 21 2017 15:01
@flyboy1565 - i missed your comment! I was away for long time.
Miracle Ayodele
@iammiracle
Feb 21 2017 15:02
@fabiand93 hop u got me
John
@flyboy1565
Feb 21 2017 15:13
@sopanshewale , np I was reading light weight django at the time which just happened to come to me by way of a PDF
Sopan
@sopanshewale
Feb 21 2017 16:31
oh - ok!
Vittoria
@svikvik_twitter
Feb 21 2017 17:57
hello
Fabian
@fabiand93
Feb 21 2017 19:30
@koderNeptune how are you connecting the different ids to the request? can you show me a snip of the code that makes this?
ahf90
@ahf90
Feb 21 2017 22:07
Hi
ahf90
@ahf90
Feb 21 2017 22:13
I'm new to Django and I'm having trouble understanding where the behind-the-scenes code goes. Like where are the "Controllers" (if it were MVC). e.g. I want my app to scrape twitter's homepage and store something from it daily (I plan on using Celery at some point, but I want to start off doing it manually). Where does that code go?
Cyber Xucyc
@Cyber-host
Feb 21 2017 22:14
MTV not MVC
all logic in views
ahf90
@ahf90
Feb 21 2017 22:15
Okay that makes sense.
Kinda what I thought but I was afraid that'd be wrong in some way
I guess that explains why we separate things into apps
tulpn
@tulpn
Feb 21 2017 22:16
you could also put helper functions and stuff like that in a utils.py or similar, to keep the views.py a bit less messed up
ahf90
@ahf90
Feb 21 2017 22:16
good to know, thanks
Where do I put static content? Like if I had a local JSON file I wanted to call
Cyber Xucyc
@Cyber-host
Feb 21 2017 22:21
in the folder static with css, js
ahf90
@ahf90
Feb 21 2017 22:21
would each app have a static folder or just the overall project or does it not matter
Cyber Xucyc
@Cyber-host
Feb 21 2017 22:22
did you try to read documentation? today I first try python but with documentation
I've gotten through testing
tulpn
@tulpn
Feb 21 2017 22:31
https://docs.djangoproject.com/en/1.10/howto/static-files/ tells you all about the static files
ahf90
@ahf90
Feb 21 2017 22:38
yeah just saw it was the next page
I think I understand that views are more like MVC's controllers
and templates would be the V in MVC
not exactly, obviously, but it helps me understand