Charly
Slicing can be the easiest way
entropy
Anonymous
Ok i will try it
Anonymous
entropy
from datetime import datetime
a = '2019-03-26 08:00 AM - 2019-03-31 04:00 PM'
in_str = a.split(' - ')[0]
out_str = a.split(' - ')[1]
in_dt_obj = datetime.strptime(in_str, '%Y-%m-%d %H:%M %p')
out_dt_obj = datetime.strptime(out_str, '%Y-%m-%d %H:%M %p')
print(in_dt_obj.date())
print(in_dt_obj.time())
entropy
hope this helps
Anonymous
Anonymous
Ok Mel thank u
entropy
welcome
Ricardo D
Ricardo D
dateutil - powerful extensions to datetime — dateutil 2.8.0 documentation
https://dateutil.readthedocs.io/en/stable/
Arun
Guys I am making changes in Model that has pk before. I have removed it now. Since while making migration its asking for default value for "id" if i gave one it is reporting "2 primary keys for one" for the model.
Code9
Arun
https://i.imgur.com/xCZPTbn.png
Arun
But since it is asking for default i cant skip it
Arun
For multi account and data I have removed Primary key in "pmp_id" and added owner column.
Arun
https://i.imgur.com/PAsmkye.png
Code9
change the schema in the db directly
Code9
then fake a commit
Arun
let me check
entropy
or you can make it nullable? if applicable
Arun
its the id (default / non editable) so i need flush all i guess
Anonymous
Arun
Jadav
Hi
Jadav
How can I set background image in django
Arun
i think you mean static image loading
Arun
https://docs.djangoproject.com/en/2.1/howto/static-files/
Anonymous
yes, but you need to make sure that the split token you're going to use is consistent
How can i achieve comparison of two dates
2019-03-21 - 2019-03-28
i split above string using split('-') method
now i have two separate dates in two variables
in = '2019-03-21'
out = '2019-03-28'
below are my django object datefileds output
Booking.checkIn = [datetime.date(2019, 3, 21)]
Booking.checkOut = [datetime.date(2019, 3, 28)]
but how can i compare above dates with each other like
if in == Booking.checkIn
but this is not working why....
entropy
entropy
Date comparison should work
hik
hi everyone
Anonymous
You need to make sure they are both of datetime.date obj
Ok then how can i convert that in variable to date object
Why i am asking u is because on ur previous suggest i tried to convert it but it also adding time including hours and seconds so to get rid of that i removed time option. I confused that how can i convert '2019-03-21' only to date object.
I even tried to convert with your suggest as
a = '2019-03-21'
in_dt_obj = datetime.strptime(a, '%Y-%m-%d')
print(in_dt_obj.date())
But i displaying as '2019-03-21' and not converting as date object
entropy
Print will display ‘2019-03-21’ but in_dt_obj.date() is okay
entropy
in_dt_obj.date() == checkIn -> maybe you're using this?
entropy
this will be False because your checkIn variable is a list. Try in_dt_obj.date() == checkIn[0]
Aakash
Happy Holi To All My Indian Friends!
Fill your life with colors and happiness. 😊
syedj
Hi in django im not able to print the logging format for log messages
syedj
If i run the same code outside its printing the log format
Mirco
It's useful to not hardcode urls and avoid typo issues
Mirco
What don't you understand ?
Mirco
name of url
Akash
Does wagtail provides any othee benefit except that you can make new pages easily?
I am new tp django and trying to understand to use wagtail or not...
My app won't be a basic Blog things.
What I am making is a web app interface for my existing telegram bot.
inchidi
Anders (izzno / gooood) 🇳🇴
One things for sure, you should not use Wagtail unless your confertable with Django.
Anders (izzno / gooood) 🇳🇴
You could allways add it later
inchidi
btw, afaik wagtail is not django package right? means you should clone and update the project? cmiiw
X
Need Help Guys.
X
TemplateSyntaxError at /products/
Invalid block tag on line 16: 'endblock'. Did you forget to register or load this tag?
cj
Guillermo
X
{ % block content %}
{% endblock %}
Anders (izzno / gooood) 🇳🇴
X
Anders (izzno / gooood) 🇳🇴
You have a space between { and %
Guillermo
Yep
X
Haider
How to kill a port for Django server
Mine Mac is giving error:kill (760):operation not permitted
Help me out guys..thanks
inchidi
Haider
My Django server is running on port 8000
Haider
I want to kill that
inchidi
Haider
Sudo lsof -t -i tcp:8000 | xargs kill -9
Haider
It's from stack overflow
inchidi
cj
Haider
Python mange.py runserver
Haider
I am a beginner
Haider
In Python and django
inchidi
Doug
exit the terminal window and it might kill it for you
Doug
I find that's what does it for me
Haider
I did
Haider
It said it is closed
Haider
But when I have deleted all of my projects and started a new one it is saying port already in use
Haider
What should I do now