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
url_for and jquery/javascript

Ok I am at my wits end. I am trying to add a url parameter to url_for.
I know it works, because when I hardcode the id goes to the page. Where I am having trouble is the jquery/javascript part. I don't know the correct combo.

$("#show_link").append("<tr><td><a href='{{ url_for('site.doc',id=5) }}' id='"+id+"'>"+id+"</a><td></td><td>"+name+"</td><td>"+name2+"</td></tr>");

The above works, because the id is hard coded.
when I try to add the javascript id it does not work. It prints out

id=+id+

Here is one of the combo's I have tried.

$("#show_link").append("<tr><td><a href='{{ url_for('site.doc',id='"+id+"') }}' id='"+id+"'>"+id+"</a><td></td><td>"+name+"</td><td>"+name2+"</td></tr>");

Yes id does have a value associated with it.


/r/flask
https://redd.it/6di61d
Django 3 'User' object has no attribute 'admin'

\*\*SITUATION\*\*

&#x200B;

\- I am modifying this \[GitHub\]([https://github.com/divanov11/crash-course-CRM/tree/Part-22-S3-File-storage](https://github.com/divanov11/crash-course-CRM/tree/Part-22-S3-File-storage)) project from this \[YouTube Series\]([https://www.youtube.com/watch?v=inQyZ7zFMHM&list=PL-51WBLyFTg2vW-\_6XBoUpE7vpmoR3ztO&index=22](https://www.youtube.com/watch?v=inQyZ7zFMHM&list=PL-51WBLyFTg2vW-_6XBoUpE7vpmoR3ztO&index=22)) and this is a \[demo\]([https://dennisivy-crm.herokuapp.com/](https://dennisivy-crm.herokuapp.com/)) how the original application runs.

\- My goal is to add settings option for Merchant(in the code Admin or AdminUser) accounts in the marketplace, because in the original project only buyers have the option to add image and their contact details.

&#x200B;

&#x200B;

\*\*CODE\*\*

&#x200B;

[model.py](https://model.py)

\`\`\`

#database table create
class Customer(models.Model):
#empty fields accept - null=True
user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=200, null=True)
phone = models.CharField(max_length=200, null=True)
email = models.CharField(max_length=200, null=True)
profile_pic = models.ImageField(default="profile1.png", null=True, blank=True)
date_created = models.DateTimeField(auto_now_add=True, null=True)

#show customer name in admin panel
def __str__(self):
return self.name


class Adminuser(models.Model):
#empty fields accept - null=True
user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=200, null=True)
phone = models.CharField(max_length=200, null=True)
email = models.CharField(max_length=200, null=True)
profile_pic = models.ImageField(default="profile1.png",

/r/djangolearning
https://redd.it/hbjnu4
Updating Figure Display in Jupyter

Hello /r/IPython

&#x200B;

I'm not sure if this is the right place to ask this, but the jupyter subreddit doesn't seem very active. Anywho, I'm trying grabbing images from webcam and doing some processing on it, and I want the output from the code block to update, maybe redrawing the figure/axis so that the newer image shows. Here's what I have:

```
plt.ion()
webcam = init_cam() #sets resolution and stuff
fig, ax = plt.subplots(1)
axim = ax.imshow(tFrame) #Show some pre-grabbed image

while True:
frame = get(webcam) #gets image from webcam
axim.set_data(frame)
plt.show(block=False)
#plt.pause(1) #I've tried with and without pauses
```

And long story short, it doesn't update the figure and appears to only show the first frame. Am I doing something wrong? Is there another way to do this? Any help would be appreciated!

/r/IPython
https://redd.it/k8a6nx