Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
How to display date time like day/month/year 15:30 (24 hour time)

# Answered: { value|date:"d/m/Y G:i" }

​

Hi want it so my it show up like this: day/month/year 15:30 - with the time being 24 hour time (military time)?

I have tried this in my templates file

# dashboard.html
{ value|datetime:"SHORT_DATE_FORMAT"|time:"H:i" }

Now the date will display fine when I don't have the |time how do I add the time?

/r/django
https://redd.it/calmyn
Concepts/ideas to be known to make this Date and time selection for a django booking app.

I have here screenshots of a booking app that I like. I'll try to do it with django for learning. I'm still wondering if this functionality (see image), which is selecting date then it's respective time has something to do with django models (making time options for respective date in [models.py](https://models.py) ). I'm also thinking that this can be just done with javascript (but i don't know js).


Well i don't know what would be the best choice . Any ideas or terms that you can comment on how I could do it would be a great help for me.


I also looked for the DateTimePicker in django but i don't know if that can fit my need for this feature. I will surely appreciate your responses.

​

https://i.redd.it/bpwbzxygg3931.png

Just to show the full functionality of this app, I'll show this second screenshot. Once time and date has been selected, I'm planning to grab the employees from django models if they are free or not.


https://i.redd.it/o94awnpgh3931.png

/r/django
https://redd.it/cam82h
Help with getting currently logged in user's ID in views.py query

I am using and if else logic statement in my [views.py](https://views.py) file to return on template if is true and one template if is false.

​

Here is my code so far which is working with the user ID hard coded, I just cant figure out how to get the current users ID. When I try self.request.user i get self is undefined or request is not defined

​

class uploadNew(CreateView): # new
model = beat
fields = ['title', 'beat']

success_url = reverse_lazy('uploads')
def get_queryset():
return beat.objects.filter(producer="2")

if get_queryset().count() <= 1:
template_name = 'uploadNew.html'
else:
template_name = 'home.html'


/r/django
https://redd.it/caoo05
The opensource DeepNude is now banned from GitHub
https://github.com/deepinstruction/deepnude_official

/r/Python
https://redd.it/cakxcw
Awesome free open source software for data pipeline testing: Great Expectations

Check out this OSS for data pipeline testing with a lot of solid documentation and also has an active slack channel.

[Website](https://greatexpectations.io/?utm_source=reddit&utm_medium=post&utm_name=user-testing&utm_content=ml-v1)

[Github](https://github.com/great-expectations/great_expectations)

[Hello world blog](https://medium.com/@expectgreatdata/down-with-pipeline-debt-introducing-great-expectations-862ddc46782a)

&#x200B;

**Also---** We are looking for user testers to get some feedback. In exchange for feedback on our features beta data context, profiling, and data documentation features we want to provide you one on one video conference onboarding assistance to ensure successful integration with your project. Feel free to comment if you have any questions otherwise you can sign up here: [https://greatexpectations.typeform.com/to/mN4UdQ](https://greatexpectations.typeform.com/to/mN4UdQ)

/r/Python
https://redd.it/cao1ez
I have a csv with 50k observations and I’m trying to drop every row that contains a “.” In it.

I’ve tried df[column].str.contains(“.”) but it doesn’t seem to work a Series structure. How would I go about removing those rows?

/r/Python
https://redd.it/camd7z
Class based views or function based views?

I want to have a functionality in my django app where a user fills in a form with data, then that data is passed into a function as parameters. From there, the parameters and some other generated values based on input parameters are inserted into multiple sql tables that belong to different models.

&#x200B;

For now I want to create dummy values that I can pass as parameters and insert into separate tables to test if the function is working and storing data correctly. How should I approach this issue? ( I am a little new to Django)


Thanks in advance for all tips/suggestions!

/r/django
https://redd.it/caqo8r
Just started on Python Crash Course! Wish me luck!

/r/Python
https://redd.it/cawyv8
Brilliant

/r/Python
https://redd.it/cazntp
[Ask Flask] Anyone know the difference between using unittest.main() and using addTest(), then run(suite)?

Hi all, I am testing a flask app and have done this many times before, however this time it is different. I am using the following to run the tests:

suite = unittest.TestSuite()
player1 = dict(BasicTest.player_pairs[0]['player1']
player2 = dict(BasicTest.player_pairs[0]['player2']
suite.addTest(BasicTest('test_player1_loses_money', player1, player2)
runner = unittest.TextTestRunner(verbosity=2=3, failfast=True)
runner.run(suite)


I am doing the above because I will then call addTest() in a loop to test many pairs of players.
The problem is that requests seem to no longer work. I get timeout errors. I am getting exceptions within exceptions. EXCEPTION INCEPTION lol.

HTTPConnectionPool(host='159.89.146.74', port=7076): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f05222e9668>: Failed to establish a new connection: [Errno 110] Connection timed out',))

When I run my test regularly using unittest.main() everything works fine, but I want to run 1 test case many times with different pairs of players.

My flask app is just Restful endpoints and inside those endpoints, I make calls to external services.

Does anyone know why requests is broken when I use addTest() method? I feel like the error is very obscure, I tried looking at

/r/flask
https://redd.it/cavp4m
Heroku/Postgres database migration to Flask

I have a postgres database with a table set up on heroku and I've loaded my data into the database via a csv file. I've been trying to migrate the data from my heroku/postgres database to my flask app and query through some of it but all the tutorials I've read through have me instantiating the database and table within the flask app itself. Is there a way I can query my existing database without having to recreate it within flask itself?

/r/flask
https://redd.it/cavbf4
Built my first web app, tips for documentation?

Hi, I have built my very first blog app by following this tutorial: [Django | Corey MS](https://www.youtube.com/watch?v=UmljXZIypDc&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p). I have no prior coding experience besides a basic knowledge of Python.

The site is done, and I am very happy with what I have achieved so far. All that is left is adding a few more bells and whistles to the front end, and deployment.

This is my very first Django project, and it has been a fantastic experience. But, I feel like I am losing track of things I have learned. The concepts are still clear, but a lot of techniques that I have learned (from big things like how to create a custom model to little things like how to add django pagination or how to use libraries like pillow) are already blurry or forgotten.

I still haven't learned to use Git. That is my next target.

What is the best way to create a repository of personal documentation that I can refer back to at any time and easily understand what was going on and how things came to be? Code hosting platforms(Github)? Jupyter Notebook? Plain pen and paper? Please don't laugh.

I have a lot of small personal Django projects lined up

/r/djangolearning
https://redd.it/cawjrn
Best method to plot time of day independent of date?

I often work data that needs to be plotted by time of day with no regard for the date. Typically I'm just making simple scatter plots of values vs time of day. I have a lot of issues plotting this as actual time so I've been covering time to minutes past midnight for a smooth plot. I'm certain this isn't an affective strategy and . Do y'all have recommendations? Pandas datetime format seems to wreak havoc on any plots I make and always adds a date.

/r/pystats
https://redd.it/cb50kz
What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/cb1d1q
Jupyter Notebook Doesn't Show Files When It Loads

I start up Jupyter Notebook using the Anaconda prompt, it loads, and there are no files shown. I also can't create new files through Jupyter. I've reinstalled the program, restarted my computer, reinstalled Anaconda; nothing is working. Please help.

/r/JupyterNotebooks
https://redd.it/cb4qde
allowed_hosts behind load balancer

What value can I set allowed_hosts to if my server(s) are behind a reverse proxy or load balancer? In particular, this is an Elastic Load Balancer, so the front-end IPs are dynamic.

I have * as the current setting.

/r/django
https://redd.it/cb6tcq