I have a view that gets data from a form and executes a subprocess:
def sync_job(request, job_id, src, dest):
form = SyncJobForm()
check = SyncJob.objects.get(id=job_id)
check.status = True
check.save()
pre_sync = SyncJobCMD.objects.get(id=1)
p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE)
syncoutput,s...
I want to read in real time the output of a subprocess called from a form in a view. Here is my views.py:
@login_required
@condition(etag_func=None)
def sync_form(request):
# do things to validate form
return HttpResponse(sync_job(request, job_id, src, dest))
def sync_job(request, job_id, src, dest):
# we check the argument...
When a user visits mysite.com/articles, they see I a lists several articles.
How can I include this list into another page, e.g. the home page, but so that I can still add extra content to the home page? This list of articles will only appear on those 2 pages, so a custom tag seems a bit like overkill.
Thanks
...
I have the following in my models.py:
class HostData(models.Model):
Manager = models.ForeignKey(Managers)
Host = models.CharField(max_length=50, null=True)
HostStatus = models.CharField(max_length=200, null=True)
Cpu = models.PositiveIntegerField(max_length=10, null=True)
Disk = models.FloatField(null=True)
I would like to r...
Why does the commented out code work, while the other code returns a BoundField error? Shouldn't they be equivalent?
form = PostForm(request.POST)
post = Post(title = form['title'], details = form['details'])
#post = Post(title = request.POST['title'], details = request.POST['details'])
Also, I fear the title to this question makes n...
I get a Must be a User Instance error message.
TRACEBACK
Traceback:
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/ApPeL/Sites/Django/omu2/../omu2/friends/views.py" in add
13. if form.is_v...
I would like to display some content located in my models in some of my template pages.
I am using django-page cms
In the documentation views are not used to display content. Instead ready made template tags are used.
http://packages.python.org/django-page-cms/display-content.html
I do not understand a word of this. Please Bear with ...
Hi.
I have been using rackspace CDN for the last few months with django-imagekit and django-cumulus.
And I am not really happy with the results.
I seem to get load of errors because of timeouts etc.
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/connection.py", line 347, in get_container
return Container(self, cont...
I am using Django-page-CMS
Everything works fine However once I create my own views which extend from pages used within the CMS the CSS does not display.
This is strange because these pages display the CSS fine, as long as I do not use my own views.
I would greatly appreciate some help on this matter or at least some suggestions on wh...
Hello, I have a django app that suppose to display invoices and clients. Now for some reasons When I run the Django sever, for some reasons it only displays the invoice data in invoice_list but cannot displays the clients data in clients_list. The clients data does shows up in another view, but not in invoice_details view.
EDIT: I Seem...
For example If I have the following models, views and code in a template...
class news(models.Model):
type = models.ForeignKey(----) (charfield)
title = models.CharField(max_length=100)
published = models.DateTimeField(default=datetime.now)
summary = models.CharField(max_length=200)
def ----():
items = news.objects...
How can I get data from paramiko channel class in real-time? I have 2 functions, the first one calls the second one from a HttpResponse (a generator basically):
return HttpResponse(ssh_exec(request, job_id))
ssh_exec:
def ssh_exec(request, job_id):
job = ssh_job.objects.get(id=job_id)
cmd_to_use = str(job.command)
client = par...
Hello, this is a Django related question. I have an invoice that I have created from a database which displays the information. Now I want to know is if I can send these details to an email address. I have tried looking at this page at http://docs.djangoproject.com/en/dev/topics/email/, but I don't know if I am looking for that. I am ass...
On my django site, I decided to just use the admin templates for the UI, but I made a few tweaks like the site name, color, etc. even my custom views just extend admin/base_site.html I did this by creating templates/admin/base_site.html with the following code:
{% extends "admin/base.html" %}
{% load i18n %}
{% block title %}{{ title }...
Hello, I am trying use the django ORM to get a list by year of all my articles with an article count beside it, such as this:
2010 (5 articles)
2009 (4 articles)
2008 (9 articles)
I have tried things such as:
archive = Articles.objects.dates('created', 'year').annotate(archive_count=Count('created'))
or:
archive = Articles.objects.v...
I'm using django and have a page of search results that I want to be able to filter by category with ajax (jquery) requests. There's a filter bar on the side of the page and when someone selects certain categories and clicks submit, those corresponding results should show up on the page. My code looks something like this:
<input type=...
Hello, another Django send_mail question. Seems like I have problems displaying data in an email that separate form from function. Seems like this is a variable problem.
Edit: I manage to make the client name show up! Now how can to the same thing with invoice. Say that I wanted to display the date, invoice_no, work_orders & contract_i...
I'm trying to use Django's built-in admin docs feature to make writing templates easier. Supposedly if you go to /admin/docs/views you should get documentation for every view in your application. I see a list, but none of the links work:
-) Any view listed that's related to my application just goes to a blank page with nothing but the n...
Hey everyone,
Here is my problem. I have a model Project, that has a quote field in it. When a new instance of project is created I need to append the last 2 digits of the year plus a hyphen onto the start of the "quote" field. Ex. 2010 = "10-". Im just not quite sure how to start it?
As of right now I have hard coded in "10-" in a...
I have a Django form setup using GET method. Each value corresponds to attributes of a Django model. What would be the most elegant way to generate the query? Currently this is what I do in the view:
def search_items(request):
if 'search_name' in request.GET:
query_attributes = {}
query_attributes['color'] = request...