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
HELP - CV/Gridsearch with a custom formula?

I am trying to optimize some weights for a factor model. I have a function where I can input the weights, and then it applies it to three streams after several transformations etc. It then outputs a final stream that is the combination, and compares it to a benchmark where I can calculate a R-squared.

Is there a way I can do this for a variety of weights to find the maximum R-squared? I don't want to use a basic linear regression, because I'm not just simply applying the weights to my streams. I have some other things going on before it spits out the final stream. Any help is appreciated.

/r/pystats
https://redd.it/8r1ye9
flask.cli.NoAppException: Could not import "C"?

I'm going through the mega tutorial and I want to find out how to run pycharm's automatic launcher so I don't have to exit and restart my site each time in the command line when I make a change. However when I use the launcher I got the error in the title. Any idea how to fix this? When I run via the command line it works fine though

/r/flask
https://redd.it/8r6rsy
How do I modify and delete uploaded images via Django admin?

I already have a model set up with an ImageField and am able to upload images just fine and name them whatever I want. Through the admin, I can also edit and delete rows in the database through the admin, but this does nothing to their respective files.

Looking around, I've found a few posts and read some of the official documentation, but I couldn't understand how to use any of the options I was presented. Supposedly there are some methods I can use to do this, but I don't know how to do this from my model. How do I do this, or is there a better way to go about it?

/r/django
https://redd.it/8r8st5
ModelForm.save() not creating a new row in the DB

For some reason, using the command in the title overwrites the same row instead of creating a new one and increment the id.

I've posted the code on [Stack Overflow](https://stackoverflow.com/questions/50841225/form-save-populates-lates-row-instead-of-creating-a-new-django)

Since I do not get any error message, searching for solutions has been hard.

Thanks in advance.

/r/djangolearning
https://redd.it/8r9uwd
Adding a search option for the Mezzanine page tree

Could anybody give me some guidance on how to add a search option for the Messanine page tree (in admin section). I'm looking in to converting a wordpress app in to Mezzanine/Django which has \~2000+ hierarchical articles in it. So to make it usable I need to provide a search option.

I looked at the related template file (mezzanine/pages/templates/admin/pages/page/change\_list.html) and it just have following code block.

`{% block content %}`
`<div id="content-main">`
`{% if has_add_permission %}`
`{% include "admin/includes/content_typed_change_list.html" %}`
`{% endif %}`


`{% if cl.result_count == 0 %}`
`<p class="paginator">0 {{ cl.opts.verbose_name_plural }}</p>`
`{% else %}`
`<div id="tree">{% page_menu "pages/menus/admin.html" %}</div>`
`{% endif %}`


`</div>`
`{% endblock %}`

/r/django
https://redd.it/8rc06h
Using jQuery to Auto refesh blog on update.

I need to use jQuery to check if my blog was updated and then to refresh the page if it has.

I see plenty of tutorials on how to do this using a php back end.
but I don't know jQuery well enough to make it work with Django.

/r/django
https://redd.it/8rdxqr
Why do you need to check if user entered an email when creating their account? (Custom User)

I'm creating a custom user, mostly because I want the email to be used for logging in instead of a username. As I understand, `USERNAME_FIELD = 'EMAIL_FIELD'` already makes the email required. So, why do the docs say you should write in the Custom User Manager inside of the create\_user method:

if not email:
raise ValueError("Users must have an email address")

Isn't it redundant to do that check when it's already required because the email is used by USERNAME\_FIELD?

I would also like to quickly confirm that there are no is\_admin, last\_login, etc properties that comes with AbstractBaseUser? You have to create all these properties by yourself and then create methods for them as well which for example update last\_login every time user logs in.

/r/djangolearning
https://redd.it/8rd3r2
Which javascript to use on the front end?

I've come a grudging acceptance that I will have to learn and add some javascript to a little personal project that I've been using to learn a few things as I go along. And I'm sure this comes up a lot, I'm just having trouble finding something relevant.

If I wanted to add a little bit of interactivity on pages, what is the best route to go down. Vanilla Javascript? JQuery? Can Vue be used for just scripts or does it have to be used as a full on framework? Something I'm not aware of?

/r/flask
https://redd.it/8rcjof
Django Or Rails

Hi currently I am using Rails to develop web apps, I want to know more what makes Django better than Rails
the first time I tried Django I feel like there is a lot magic syntax that I never know when using rails
Can someone give me a suggestion what make Django the best and what do people usually use Django for?
m

/r/django
https://redd.it/8rhy19
Converting an exe back to .py

hi guys,

I got discord bot created in python by someone few months ago, coder at that time just converted that to an exe file so its easy for me to run it. Now my coder has disappeared and i can not find him and i need to make small adjustments to script.

Is there a way to convert that .exe back to .py ?

Thanks,

/r/Python
https://redd.it/8rh2x2
Will the mega tutorial help me learn how to build more interactive apps than something like a blog?

I'm finished about a quarter of the mega tutorial and while it's very good, it also seems to be primarily focused on creating kind of a barebones blog style app without lots of user interactivity going on. My end goal is to make a speed reading app that can take text from an outside source (probably going to start with just taking wikipedia articles) and spacing the words into chunks of words you can read one at a time


ex: so instead of reading this word for word


[you would] [read it like] [this and] [read faster]

and maybe having every block highlighted with a different color.


 

Do you guys think the mega tutorial could help satisfy this?

/r/flask
https://redd.it/8rcebx
Django Graphene tutorial question

I went through the graphene tutorial and using relays. But I have am a bit confused on one thing

If you go through the normal tutorial when you do single queries the query part is defined by


class Query(object):
category = graphene.Field(CategoryType,
id=graphene.Int(),
name=graphene.String())
If you do the one with relay the query part is defined as

class Query(object):
category = relay.Node.Field(CategoryNode)

If I want both features (single queries and filters from relays) does that mean I have to define a new variable for one to have both features? or do I just used relays and somehow the typings for the fields are inherited. I am just kind of confused by the ambiguous way the tutorials are written.

/r/djangolearning
https://redd.it/8rhl1p