django-views

How to properly use and cancel subprocess in python using Django?

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...

Using a generator to stream JSON data in real time from subprocess in Django with JQuery

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...

Django: How can I include the output of one view in another?

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 ...

How to return multiple objects related with ForeignKey in Django

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 are my Django GAE requests returning "Property details must be a str or unicode instance, not a BoundField"

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...

Django must be a "User" instance.

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...

Displaying page content using django-page-cms

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 ...

django image storage cdn

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...

views created in django-page-CMS disables all CSS? code included, a fix please

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...

Django question

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...

How do you display only specific variable information within a django-template ?

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...

Real time output from paramiko with Django

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...

Django question: An invoice that I want to send to an email

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...

Idiosyncracy while extending django admin template

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 }...

How to use Django ORM to get a list by year of all articles with an article count

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...

passing a javascript array to a django view

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=...

Using send_mail in Django: Cannot display data in invoice from functions

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...

Django admin/doc/views/ all blank or broken

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...

Specific Quote Issue

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...

Django: Generating a queryset from a GET request

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...