Charly
Slicing can be the easiest way
Anonymous
Ok i will try it
Anonymous
make them as datetime object. then you can access them by date and time
But it will return only one date how can i get both in and out dates
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
entropy
Thank u mel it means by string index we need to use split right... I will do it
yes, but you need to make sure that the split token you're going to use is consistent
Anonymous
Ok Mel thank u
entropy
welcome
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.
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
change the schema in the db directly
https://pastebin.com/raw/iUP6V4sx
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
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.
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
Akash
you should do your own research imo, since everyone have their own "easy to use" definition and you are the one who really understand your project requirements
Thanks For reply. I am trying to understand the benefit I get from wagtail... watched some videos, read articles, and some reddit posts All said its a great CMS and all... I got a feel to use it and not Repeat things already built. Not I created some demo hello world stuffs with wagtail and all I see is a easy page builder. Don't know if it has any other benefit, so asked here. Finally I think I will not use it for now, as I guess it will become hard to debig things when I get some issues and if wagtail handles it differently than core django
inchidi
btw, afaik wagtail is not django package right? means you should clone and update the project? cmiiw
Akash
One things for sure, you should not use Wagtail unless your confertable with Django.
I have had went through some basic django tuts... Made some simple apps and home page... Heard about wagtail and felt I am missing something big or may be investing much time in things that can be done in much less time and effort...
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
btw, afaik wagtail is not django package right? means you should clone and update the project? cmiiw
you can use it as a django package too if you don't need to do big customizations
X
{ % block content %} {% endblock %}
Anders (izzno / gooood) 🇳🇴
You have a space between { and %
Guillermo
Yep
Haider
How to kill a port for Django server Mine Mac is giving error:kill (760):operation not permitted Help me out guys..thanks
Haider
My Django server is running on port 8000
Haider
I want to kill that
Haider
Sudo lsof -t -i tcp:8000 | xargs kill -9
Haider
It's from stack overflow
inchidi
Sudo lsof -t -i tcp:8000 | xargs kill -9
try kill $(lsof -t -i :8000)
cj
My Django server is running on port 8000
how did you run it at first?
Haider
Python mange.py runserver
Haider
I am a beginner
Haider
In Python and django
inchidi
Python mange.py runserver
ctrl+c there then
cj
Python mange.py runserver
then just press Cmd+C in that terminal window 🤷🏻‍♂️
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