django

Submitting a Form to a Django Server is Really Slow

I have a webpage that looks like: <html> <head> <title>Hi</title> </head> <body> <form name="mainForm" method="post" action=""> <p> <input type="checkbox" name="PLD"> <input type="submit" value="Submit"> </p> </form> </body> </html> If the checkbox is not checked, form submission works i...

a StringIO like class, that extends django.core.files.File

class MyModel(models.Model) image = models.FileField(upload_to="blagh blagh...") #more spam... I have a file in memory and I want to save it via Django FileField save method, like this: photo.image.save(name, buffer) # second arg should be django File I've tried to use StringIO, but it doesn't extend django.core.files.File and thu...

Django: How to find out whether RawQuetySet has rows ? There's no count() method

Hello, I think the title speaks for itself. I have a complex query with a subquery, but sometimes it returns no values, which is absolutely normal. But I can not prevent the ValueError message, cuz I am not able to find out whether RawQuerySet is empty or not. The RQS object is always present, but if I try to access it's first row resul...

Django i18n {% blocktrans %} query

Hey, I have been reading through the django i18n translation documentation and I can't figure out the best way to translate a string that contains html. For instance, the html below. How would I retain <strong></strong> in the blocktrans statement? <p>This email is to acknowledge placement of order number <strong>{{ order.order_num...

Django aggregate and grouping : code cleanliness problem ...

Hello ! Here is a small problem I am having. 3 very simple models : >>> class Instrument(models.Model): ... name = models.CharField(max_length=100) ... >>> class Musician(models.Model): ... instrument = models.ForeignKey(Instrument) ... >>> class Song(models.Model): ... author = models.ForeignKey(Musician) I would l...

Django: limiting model data

Hi there! I'm searching in a way to limit the queryset which I can get through a model. Suppose I have the following models (with dependencies): Company |- Section | |- Employee | |- Task | `- more models... |- Customer | |- Contract | |- Accounts | `- other great models ... `- some more models... It should be n...

How to apply django patches

I want to apply a patch to this bug (http://code.djangoproject.com/ticket/13095) but I have never done it before and I have no idea where to begin. Can anyone point me to a tutorial? ...

obtaining pid of child process

Hi, I am using python's multiprocessing module to spawn new process as follows : import multiprocessing import os d = multiprocessing.Process(target=os.system,args=('iostat 2 > a.txt',)) d.start() I want to obtain pid of iostat command or the command executed using multiprocessing module When I execute : d.pid it gives me ...

jquery dynamic input field on select option onchange..

I have a select option box with the value from database. If i select an option the other three text field will be loaded with data from database based on select option id or primary key value. how do i do that in django , jquery. Thank you so much ...

Django multilingual - how to preview content from any language?

I'm using django-multilingual for a Django based website. When I define the __unicode__ function for a model to return this way: def __unicode__(self): return unicode(self.title) However my default language is English and I have some items that are inserted in Dutch only. When I preview the full list, I get "None" as a title. ...

Django urls conf

So I worked with Django for a bit and understand regex rudimentary. I know if there is request it "maps"(not sure what that means) the urls to a certain definition in the view. That is clear and understandable for one page. But what if I want to design a urlpattern for multiple pages and/or the whole website. I dont understand that...

Get user from URL segment with Django

I have a web application which will return a user id based on the first segment of the url, much like Twitter: http://www.myapplication.com/user-name-goes-here/ It can go deeper too, like so: http://www.myapplication.com/user-name-goes-here/news/article_1/ In order to break the site down, I am using the following URL routing techniqu...

jquery dynamic input field on select option onchange..

How can i poppulate the student name, roll and marks upon selecting the student subject based from select onchange event using jquery. Thank you so much. My views.py def add_student(request): subject = Subject.objects.all() if request.method == "POST": obj = Student() obj.name = request.POST['name'] ...

Capturing event of client disconnecting! - Gevent/Python

Hi folks, I'm using long polling for a chat with gevent. I'm using Event.wait() when waiting for new messages to be posted on the chat. I would like to handle the occasion a client disconnects with some functionality: e.g. Return "client has disconnected" as a message for other chat users Is this possible? =) ...

Editor or IDE supporting django templates and HTML/CSS validation?

Is there a IDE that supports editing django templates and that is able to validate HTML and CSS? Requirements: be able to detect and highlight errors in CSS, example: forgot to close "}", or invalid css attribute be able to make it learn new css attributes (like css3 ones or browser specific ones) - we don't want to see them invalidat...

Pulling Data From Multiple Tables in Django

I'm kind of new to Django and am having some trouble pulling from existing tables. I'm trying to pull data from columns on multiple joined tables. I did find a solution, but it feels a bit like cheating and am wondering if my method below is considered proper or not. class Sig(models.Model): sig_id = models.IntegerField(primar...

Elegantly generating a datetime from a URL in Django?

I'm working on a web app that will allow the user to do a lookup by date, so that, for example: results = Something.objects.filter(end = date) I'm planning on passing in the date information via the URL, like this: example.com/invoicer?2/9/1984 I'll then grab the date via request.GET, break off the first part and store it as the m...

How can I track a user events in Django?

I'm building a small social site, and I want to implement an activity stream in a users profile to display event's like commenting, joining a group, posting something, and so on. Basically, I'm trying to make something similar to a reddit profile that shows a range of user activity. I'm not sure how I'd do this in Django though. I thoug...

Django user.is_authenticated works some places, not others

In my template, I have the following: <ul class="tabbed" id="network-tabs"> {% if user.is_authenticated %} <li><a href="{% url acct-my-profile %}">My Account</a></li> <li><a href="{% url acct-logout %}">Log Out</a></li> {% else %} <li><a href="{% url acct-login %}">Log ...

django-mptt children selection works on localhost but not on server

I have the same code on localhost and on server (thanks to mercurial), but it works a little bit different. I want to render category and its subcategories in template using this code: views.py: def category(request, category_slug): try: category = Category.objects.get(slug=category_slug) except: raise Http404 ...