Checkbox in the admin that changes search_fields in real time
I would like to have a checkbox/toggle/etc under the search_fields box. When the checkbox is/isn't checked, it will change the get_search_results() function. I'd prefer for this to be done using JavaScript (no JQuery if possible!) so that the search results still change after the "Search" button is pressed, but without the page needing to reload.
Please let me know of any insights you might have. Thank you!
/r/django
https://redd.it/6b0mvh
I would like to have a checkbox/toggle/etc under the search_fields box. When the checkbox is/isn't checked, it will change the get_search_results() function. I'd prefer for this to be done using JavaScript (no JQuery if possible!) so that the search results still change after the "Search" button is pressed, but without the page needing to reload.
Please let me know of any insights you might have. Thank you!
/r/django
https://redd.it/6b0mvh
reddit
Checkbox in the admin that changes search_fields in... • r/django
I would like to have a checkbox/toggle/etc under the search_fields box. When the checkbox is/isn't checked, it will change the...
How many people are around? Monitor wifi signals to count the number of cellphones around you
https://github.com/schollz/howmanypeoplearearound
/r/Python
https://redd.it/6aytne
https://github.com/schollz/howmanypeoplearearound
/r/Python
https://redd.it/6aytne
GitHub
GitHub - schollz/howmanypeoplearearound: Count the number of people around you by monitoring wifi signals :satellite:
Count the number of people around you :family_man_man_boy: by monitoring wifi signals :satellite: - GitHub - schollz/howmanypeoplearearound: Count the number of people around you by monitoring wifi...
Example API to query Google Places, Yelp and FourSquare at the same time, with Bayesian Rankings
https://github.com/octohedron/TouristFriend
/r/flask
https://redd.it/6az5ee
https://github.com/octohedron/TouristFriend
/r/flask
https://redd.it/6az5ee
GitHub
octohedron/TouristFriend
🌆 TouristFriend API lets you query Google Places, Yelp and FourSquare at the same time, with bayesian rankings!
Django limit the choices of a many to many relationship
https://stackoverflow.com/questions/43960840/django-limit-the-choices-of-a-many-to-many-relationship
/r/django
https://redd.it/6b2ooy
https://stackoverflow.com/questions/43960840/django-limit-the-choices-of-a-many-to-many-relationship
/r/django
https://redd.it/6b2ooy
Stackoverflow
Django limit the choices of a many to many relationship
I know the title says the question has been asked before but the situation is different.
I have something called Agent:
class Agent(models.Model):
user = models.ForeignKey(settings.AUTH_USER_...
I have something called Agent:
class Agent(models.Model):
user = models.ForeignKey(settings.AUTH_USER_...
Django REST framework 3.6.3 now released.
http://www.django-rest-framework.org/topics/release-notes/#363
/r/django
https://redd.it/6asat4
http://www.django-rest-framework.org/topics/release-notes/#363
/r/django
https://redd.it/6asat4
sanitizing code for an exec command
I have a script that runs code provided by the user via an exec command. I know this can be considered a security hazard. As a precaution, before compiling I look for the term "import" anywhere in the code and if I find it the code is rejected. When code is executed, it's only given access to the builtins and a specific locals dictionary of functions and classes that it is meant to be able to interact with. The program is running on a remote server so the user cannot see any output to stdout.
Can anyone tell me if/how this is still unsafe? Is there something I'm not considering that would allow a user to run malicious code?
Thanks for any input.
/r/Python
https://redd.it/6b3zzy
I have a script that runs code provided by the user via an exec command. I know this can be considered a security hazard. As a precaution, before compiling I look for the term "import" anywhere in the code and if I find it the code is rejected. When code is executed, it's only given access to the builtins and a specific locals dictionary of functions and classes that it is meant to be able to interact with. The program is running on a remote server so the user cannot see any output to stdout.
Can anyone tell me if/how this is still unsafe? Is there something I'm not considering that would allow a user to run malicious code?
Thanks for any input.
/r/Python
https://redd.it/6b3zzy
reddit
sanitizing code for an exec command • r/Python
I have a script that runs code provided by the user via an exec command. I know this can be considered a security hazard. As a precaution,...
Help with
class Place(models.Model):
address = models.CharField()
class Restaurant(Place):
unique_to_restaurant = models.CharField()
competitors = models.ManyToManyField(Place)
class Stadium(Place):
unique_to_stadium = models.TextField()
class Favorites(models.Model):
description = models.TextField()
favorites = models.ManyToManyField(Place)
I'm not great with databases and this is really giving me headaches. What is the best way to do this database? This is the gist of what I have currently, which functionally does exactly what I need. However the amount of queries are out of control. The children of Place share a lot of the same fields as Place but have some unique ones. I need to query place and favorites often. Favorites must be able to access the children of Place and the children of Place sometimes access the children of Place as well. Generic Foreign keys don't work (I don't think?) because the instance will be used more than once, so I would need to clone an instance. If anybody could help me out that would be absolutely amazing.
Edit: Sorry about the title! I was worried so much about the formatting of the code that I forgot to complete it and now I'm stuck with it :(
/r/django
https://redd.it/6b4cbe
class Place(models.Model):
address = models.CharField()
class Restaurant(Place):
unique_to_restaurant = models.CharField()
competitors = models.ManyToManyField(Place)
class Stadium(Place):
unique_to_stadium = models.TextField()
class Favorites(models.Model):
description = models.TextField()
favorites = models.ManyToManyField(Place)
I'm not great with databases and this is really giving me headaches. What is the best way to do this database? This is the gist of what I have currently, which functionally does exactly what I need. However the amount of queries are out of control. The children of Place share a lot of the same fields as Place but have some unique ones. I need to query place and favorites often. Favorites must be able to access the children of Place and the children of Place sometimes access the children of Place as well. Generic Foreign keys don't work (I don't think?) because the instance will be used more than once, so I would need to clone an instance. If anybody could help me out that would be absolutely amazing.
Edit: Sorry about the title! I was worried so much about the formatting of the code that I forgot to complete it and now I'm stuck with it :(
/r/django
https://redd.it/6b4cbe
reddit
Help with • r/django
class Place(models.Model): address = models.CharField() class Restaurant(Place): unique_to_restaurant = models.CharField() ...
Need help with making a Python Numpy function for calculating distance of line in grid cells
So the situation is basically that there is a unit square (with corners (0,0),(1,0),(0,1) and (1,1)) which is made up by n*n (so n-squared) square 'grid cells'.
I need to define a function F(n,a,b) that takes as input 2 points a and b in the square, for example a=[0.3,0.4] and b=[0.6,0.8], and n (the amount of grid cells per side), and that function should give me (in very good approximation) the total distance that a straight line between those points covers in each grid cell.
So it should return an ordered list of n*n length, each element of the list representing the distance that the straight line covers in that grid cell. The order should be so that the top left grid cell is the 0th element (first element) and then the grid cell to the right of it should be the second element, so row by row.
EXAMPLE:
Suppose we take the very simple and trivial situation n=2, so 4 grid cells, and the coordinates [0,0] and [1,1].
Then the function F(2,[0,0],[1,1]) should return [0, sqrt(2)/2, sqrt(2)/2, 0] (as a numpy array preferably, and of course sqrt(2)/2 as a numerical approximation).
The function should be reasonably well optimised for like 100*100 grid cells and should be very fast (<0.5 sec)
I really hope anyone can help me with this because I've been struggling with the problem for like 10 hours or more already.
/r/Python
https://redd.it/6b4cd2
So the situation is basically that there is a unit square (with corners (0,0),(1,0),(0,1) and (1,1)) which is made up by n*n (so n-squared) square 'grid cells'.
I need to define a function F(n,a,b) that takes as input 2 points a and b in the square, for example a=[0.3,0.4] and b=[0.6,0.8], and n (the amount of grid cells per side), and that function should give me (in very good approximation) the total distance that a straight line between those points covers in each grid cell.
So it should return an ordered list of n*n length, each element of the list representing the distance that the straight line covers in that grid cell. The order should be so that the top left grid cell is the 0th element (first element) and then the grid cell to the right of it should be the second element, so row by row.
EXAMPLE:
Suppose we take the very simple and trivial situation n=2, so 4 grid cells, and the coordinates [0,0] and [1,1].
Then the function F(2,[0,0],[1,1]) should return [0, sqrt(2)/2, sqrt(2)/2, 0] (as a numpy array preferably, and of course sqrt(2)/2 as a numerical approximation).
The function should be reasonably well optimised for like 100*100 grid cells and should be very fast (<0.5 sec)
I really hope anyone can help me with this because I've been struggling with the problem for like 10 hours or more already.
/r/Python
https://redd.it/6b4cd2
reddit
Need help with making a Python Numpy function for... • r/Python
So the situation is basically that there is a unit square (with corners (0,0),(1,0),(0,1) and (1,1)) which is made up by n*n (so n-squared) square...
Can anybody think of a way to do this with less variables?
def approxPi( error ):
num = 4
denom = 1
curr = num/denom
prev = 0
while abs(curr-prev)>error:
num *= -1
denom += 2
prev = curr
curr += num/denom
return curr
/r/Python
https://redd.it/6b56tn
def approxPi( error ):
num = 4
denom = 1
curr = num/denom
prev = 0
while abs(curr-prev)>error:
num *= -1
denom += 2
prev = curr
curr += num/denom
return curr
/r/Python
https://redd.it/6b56tn
reddit
Can anybody think of a way to do this with less variables? • r/Python
def approxPi( error ): num = 4 denom = 1 curr = num/denom prev = 0 while abs(curr-prev)>error: ...
[D] /r/MachineLearning should do an unconference
Reject, Accept or In Submission? Why not post your paper here?
This field is moving too fast to wait 6 months to see the great research that's happening (and that's assuming the review process isn't noisy).
/r/MachineLearning has already been an unofficial mini-conference for the papers submitted here. I find the best discussion happens when the authors show up to answer questions and address comments. It seems like this is happening mostly by coincidence. Someone will post a paper they like and the authors will happen to notice and engage in the discussion.
It stands to reason that if this happens so often by chance, there's enough critical mass of users here to create something more official. Let's get authors posting their work and discussing it on /r/MachineLearning, sort of like a virtual poster session.
/r/MachineLearning
https://redd.it/6ay2ac
Reject, Accept or In Submission? Why not post your paper here?
This field is moving too fast to wait 6 months to see the great research that's happening (and that's assuming the review process isn't noisy).
/r/MachineLearning has already been an unofficial mini-conference for the papers submitted here. I find the best discussion happens when the authors show up to answer questions and address comments. It seems like this is happening mostly by coincidence. Someone will post a paper they like and the authors will happen to notice and engage in the discussion.
It stands to reason that if this happens so often by chance, there's enough critical mass of users here to create something more official. Let's get authors posting their work and discussing it on /r/MachineLearning, sort of like a virtual poster session.
/r/MachineLearning
https://redd.it/6ay2ac
reddit
[D] /r/MachineLearning should do an unconference • r/MachineLearning
Reject, Accept or In Submission? Why not post your paper here? This field is moving too fast to wait 6 months to see the great research that's...
Ordering of Fields using WTForms-Alchemy and Flask-Bootstrap quickform
I'm trying to use `WTForms-Alchemy` and the `Flask-Bootstrap` quickform. I am adding some fields and a submit button as described in the [WTForms-Alchemy Docs](https://wtforms-alchemy.readthedocs.io/en/latest/column_conversion.html#adding-overriding-fields) to the form created with `WTForms-Alchemy`.
Unfortunately the quickform function then renders the added fields before the automatically added by `WTForms-Alchemy` resulting the submit button to be in the middle of the form instead of the end.
Is there some fix to influence this ordering?
/r/flask
https://redd.it/6b5clt
I'm trying to use `WTForms-Alchemy` and the `Flask-Bootstrap` quickform. I am adding some fields and a submit button as described in the [WTForms-Alchemy Docs](https://wtforms-alchemy.readthedocs.io/en/latest/column_conversion.html#adding-overriding-fields) to the form created with `WTForms-Alchemy`.
Unfortunately the quickform function then renders the added fields before the automatically added by `WTForms-Alchemy` resulting the submit button to be in the middle of the form instead of the end.
Is there some fix to influence this ordering?
/r/flask
https://redd.it/6b5clt
I made a style-checking script in python for an introductory programming class and would love feedback!
https://github.com/IllyaStarikov
/r/Python
https://redd.it/6b6bmo
https://github.com/IllyaStarikov
/r/Python
https://redd.it/6b6bmo
GitHub
IllyaStarikov (Illya Starikov)
IllyaStarikov has 12 repositories available. Follow their code on GitHub.
dealing with blanket try/excepts
I'm jumping on a new codebase that where the previous developer was aggressively solving problems by try/excepting throughout every code path. I'm slowly removing these but there're hundreds if not thousands of try/except/pass.
One thing I'd like to do to help me out as I go is to actually get these excepts to at least log. ideally I'd love it if I could define a python logging object that is logged to with a traceback every time an exception is raised *anywhere*. this needs to be automatic, as I dont want to manually go through it all right now.
any ideas?
/r/Python
https://redd.it/6b77cl
I'm jumping on a new codebase that where the previous developer was aggressively solving problems by try/excepting throughout every code path. I'm slowly removing these but there're hundreds if not thousands of try/except/pass.
One thing I'd like to do to help me out as I go is to actually get these excepts to at least log. ideally I'd love it if I could define a python logging object that is logged to with a traceback every time an exception is raised *anywhere*. this needs to be automatic, as I dont want to manually go through it all right now.
any ideas?
/r/Python
https://redd.it/6b77cl
reddit
dealing with blanket try/excepts • r/Python
I'm jumping on a new codebase that where the previous developer was aggressively solving problems by try/excepting throughout every code path. I'm...
Need help dynamically creating buttons with different images and commands for each button.
Okay, I'll jump right into it. I need to dynamically create buttons that have different images and commands. I'm making a loot logging program for an MMO. You select an NPC from a list and the buttons populate with images associated with the loot the NPC can drop. When clicked, they add the text name (name of item dropped) to a list which is displayed in a label.
I have these buttons working properly (image changes when NPC changes, text added to list/label changes as well). But, I don't want to create these buttons statically for two reasons.
1. Different NPC's have different amounts of items they can drop so I want the number of buttons to depend on the length of the loot table.
2. I don't want my code to include dozens of manually written buttons, it seems sloppy and inefficient.
I have tried this code below
def create_loot_buttons():
global lootImages
buttons = len(currentDropTable)
for i in range(0, buttons):
itemPhoto.config(file="ItemSprites/" + itemIDs[currentDropTable[i]] + ".png")
lootImages.append(itemPhoto)
button = Button(dropTableButtons, image = lootImages[i])
button.pack()
Basically all of the buttons have the same image. I thought if I stored images in a list (see lootImages[]), it would save them to an index and I could create the buttons referencing the index number in this list, but it doesn't work).
If you need more info about my program, let me know. This is my first Python project, so the solution may be easy or staring me in the face but I've worked on it for awhile and searched to no avail.
Thank you.
/r/Python
https://redd.it/6b7aak
Okay, I'll jump right into it. I need to dynamically create buttons that have different images and commands. I'm making a loot logging program for an MMO. You select an NPC from a list and the buttons populate with images associated with the loot the NPC can drop. When clicked, they add the text name (name of item dropped) to a list which is displayed in a label.
I have these buttons working properly (image changes when NPC changes, text added to list/label changes as well). But, I don't want to create these buttons statically for two reasons.
1. Different NPC's have different amounts of items they can drop so I want the number of buttons to depend on the length of the loot table.
2. I don't want my code to include dozens of manually written buttons, it seems sloppy and inefficient.
I have tried this code below
def create_loot_buttons():
global lootImages
buttons = len(currentDropTable)
for i in range(0, buttons):
itemPhoto.config(file="ItemSprites/" + itemIDs[currentDropTable[i]] + ".png")
lootImages.append(itemPhoto)
button = Button(dropTableButtons, image = lootImages[i])
button.pack()
Basically all of the buttons have the same image. I thought if I stored images in a list (see lootImages[]), it would save them to an index and I could create the buttons referencing the index number in this list, but it doesn't work).
If you need more info about my program, let me know. This is my first Python project, so the solution may be easy or staring me in the face but I've worked on it for awhile and searched to no avail.
Thank you.
/r/Python
https://redd.it/6b7aak
reddit
Need help dynamically creating buttons with different... • r/Python
Okay, I'll jump right into it. I need to dynamically create buttons that have different images and commands. I'm making a loot logging program for...
Can you help me choose a multiplatform frontend (mobile app/web) for a django backend project?
Hello
I'm working on a new project which needs to have both an iOS/Android app, and a web frontend.
I'm doing the backend with Django, but I don't know what to use for the mobile apps. I know there are framewroks (Cordova/Ionic) that can generate native apps with html-like code.
So, do you have any suggestion about which one to use? The app is quite simple, it's a product database wit CRUD, search, filter and a couple of graphs/reports, nothing fancy.
Should I go for a REST API and the frontends consume it, or directly the django app render the views for the different frontends?
Any help is well received.
Thanks pals.
/r/django
https://redd.it/6b39b4
Hello
I'm working on a new project which needs to have both an iOS/Android app, and a web frontend.
I'm doing the backend with Django, but I don't know what to use for the mobile apps. I know there are framewroks (Cordova/Ionic) that can generate native apps with html-like code.
So, do you have any suggestion about which one to use? The app is quite simple, it's a product database wit CRUD, search, filter and a couple of graphs/reports, nothing fancy.
Should I go for a REST API and the frontends consume it, or directly the django app render the views for the different frontends?
Any help is well received.
Thanks pals.
/r/django
https://redd.it/6b39b4
reddit
Can you help me choose a multiplatform frontend (mobile... • r/django
Hello I'm working on a new project which needs to have both an iOS/Android app, and a web frontend. I'm doing the backend with Django, but I...
Share picture in Modal
I have a gallery of picture thumbnails. They expand as modals. I want users to share them on FB/Twitter. I read up on Open Graph, but the documentation is...lacking on how to deal with a list of images without adding all of them to the metadata.
Does anyone have any experience here?
/r/djangolearning
https://redd.it/6b3clp
I have a gallery of picture thumbnails. They expand as modals. I want users to share them on FB/Twitter. I read up on Open Graph, but the documentation is...lacking on how to deal with a list of images without adding all of them to the metadata.
Does anyone have any experience here?
/r/djangolearning
https://redd.it/6b3clp
reddit
Share picture in Modal • r/djangolearning
I have a gallery of picture thumbnails. They expand as modals. I want users to share them on FB/Twitter. I read up on Open Graph, but the...
I have a main album database, and i want to filter it by individual user profiles. so that each user has different albums that they're listening too. How would I go about this?
For example:
I want to have a main database of all the music albums. (done)
Create different users (WIP)
Now how can i take these users so that each user has their own list of albums that theyre listening to?
Kind of like spotify, no one has the same playlists, etc.
/r/djangolearning
https://redd.it/6b1ab2
For example:
I want to have a main database of all the music albums. (done)
Create different users (WIP)
Now how can i take these users so that each user has their own list of albums that theyre listening to?
Kind of like spotify, no one has the same playlists, etc.
/r/djangolearning
https://redd.it/6b1ab2
reddit
I have a main album database, and i want to... • r/djangolearning
For example: I want to have a main database of all the music albums. (done) Create different users (WIP) Now how can i take these users so that...
What video series or book do you recommend for learning Django?
I have:
* Strong programming fundamentals in C/C++/C#
* Strong familiarity with Python
* Basic familiarity with HTML / CSS
* Zero familiarity with PHP
/r/django
https://redd.it/6b8jtp
I have:
* Strong programming fundamentals in C/C++/C#
* Strong familiarity with Python
* Basic familiarity with HTML / CSS
* Zero familiarity with PHP
/r/django
https://redd.it/6b8jtp
reddit
What video series or book do you recommend for learning... • r/django
I have: * Strong programming fundamentals in C/C++/C# * Strong familiarity with Python * Basic familiarity with HTML / CSS * Zero familiarity...
Kronos help
I'm looking for some help with Kronos. I've never used cron tasks before -- but I'm running a task every 15 minutes to retrieve data from an external API and update my database with that information.
I have it installed on my local and my production environments, and for testing purposes, i want to still be able to call the task manually in my local environment using Kronos.
However - I only want the task to repeatedly run in my production environment.
Is there an easy way to get Kronos / cron tabs to only run automatically in production?
/r/django
https://redd.it/6b7xj0
I'm looking for some help with Kronos. I've never used cron tasks before -- but I'm running a task every 15 minutes to retrieve data from an external API and update my database with that information.
I have it installed on my local and my production environments, and for testing purposes, i want to still be able to call the task manually in my local environment using Kronos.
However - I only want the task to repeatedly run in my production environment.
Is there an easy way to get Kronos / cron tabs to only run automatically in production?
/r/django
https://redd.it/6b7xj0
reddit
Kronos help • r/django
I'm looking for some help with Kronos. I've never used cron tasks before -- but I'm running a task every 15 minutes to retrieve data from an...
How to make your Django context processors lazy
https://rock-it.pl/how-to-make-your-django-context-processors-lazy/
/r/django
https://redd.it/6aus61
https://rock-it.pl/how-to-make-your-django-context-processors-lazy/
/r/django
https://redd.it/6aus61
Rock IT
How to make your Django context processors lazy
If you came here, you probably know what is a context processor, but let's quickly recap. It's a function, that returns dictionary of values. Those values will be injected to rendering context without explicitly defining them in view. They allows us to refactor…
Generating a simple JSON proxy for a gRPC service is made easy.
https://github.com/RussellLuo/grpc-pytools/tree/master/examples
/r/Python
https://redd.it/6b7qkl
https://github.com/RussellLuo/grpc-pytools/tree/master/examples
/r/Python
https://redd.it/6b7qkl
GitHub
RussellLuo/grpc-pytools
Some useful Python's gRPC tools. Contribute to RussellLuo/grpc-pytools development by creating an account on GitHub.