how to auto-populate(auto-update) model's field(s) via custom button or on Save
45 views
Skip to first unread message
Andriyko
unread,
Nov 24, 2012, 7:40:58 PM11/24/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hello,
Please give an advice and some examples on how can I do the following. 1. I need to fetch some data (list of items) from external url and save that list into the field of the, say Model1(possible?) The problem is not how to fetch, but how to save. 2. This should be done dynamically from admin add/change Model1 page using custom button or on Save. 3. Currently I use another Model2 to store that list(ManyToMany). Is it possible to store that list as field(and show these items on the Model's page) without Model2 so that I can use items of that list in a template?
In short, I want to be able to auto-fill some field of the model on Save or/and with custom button. Possible?
Thanks
Sergiy Khohlov
unread,
Nov 26, 2012, 7:37:31 AM11/26/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
>>> import httplib
>>> myhost = httplib.HTTPConnection('www.google.com')
>>> myhost.request("GET")
>>> googleanswer = myhost.getresponse()
>>> print googleanswer.read()
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.ua/">here</A>.
</BODY></HTML>
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
The problem is not how to fetch, but how to save.
Sergiy Khohlov
unread,
Nov 26, 2012, 3:59:08 PM11/26/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
1. You dont need ManyToMany field
class urlclass(models.Model):
url =models.CharField()
class itemclass(models.Model):
url = models.ForeignKey(urlclass)
myitem = models.CharField()
#somewhere in view
def saveitems(url, itemlist):
for item in itemlist:
item = itemclass(url= urlclass.objects.get(url=url), myitem=item)
item.save()