django

cascading forms in Django/else using any Pythonic framework

Can anyone point to an example written in Python (django preferred) with ajax for cascading forms? Cascading Forms is basically forms whose field values change if and when another field value changes. Example Choose Country, and then States will change... ...

Django template ifequal comparison of decimals

So, I have a decimalfield that can be 3 different values. In my view, I pass in a dictionary of values that contains the appropriate decimal values as keys. {% for item in booklist %} {% for key, value in numvec.items %} {{item.number}} {% ifequals item.number {{key}} %} {{value}} {% end...

Why don't Django admin "Today" and "Now" buttons show up in Safari?

I'm developing a Django application that contains a model with a date/time field. On my local copy of the application, the admin page for that particular model shows this for the date/time field: This is as expected. However, when I deploy to my webserver and use the application from there, I get this: The application on the server...

What is the best way to embed HTML in an RSS feed?

I am using Django's RSS capabilities to build an RSS feed. The <description> of the RSS feed items contains HTML markup. Currently, I am just injecting the HTML markup into the feed using the following template: {{ obj.post }} Django, of course, translates special characters (<, >, &, etc.) to their respective HTML entities. I know I...

Django: how do you serve media / stylesheets and link to them within templates

Variations of this question have been asked, but I'm still unable to get my stylesheets to load correctly when my templates are rendered. I'm attempting to serve static media from the Django process during development - which is strongly discouraged in production, I'm aware. I'll post my configuration and my template, and hopefully some...

Bisect queryset around another model's queryset

I'm writing an user-driven app with several zones to it. I want to allow users to customise their messaging settings so they only get emails on the parts and actions they care about. I've drawn up the following Class: class EmailSetting(models.Model): user = models.ForeignKey(User, related_name="%(class)s_related_user") key = mo...

Django: Increment blog entry view count by one. Is this efficient?

I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry in latest_entry_list: entry.views = entry.views + 1 entry.save() If there are ten (the limit) rows returned from the initial query, will the save issue 10 seperate updated calls to ...

django drop down menu public template error

Hello, My public template grabs data from Postgres to a drop down menu. The template displays the data in the drop down menu. When the selection is activated the following error occurs: commodity() takes exactly 2 arguments (1 given) The template code, views and URL are here: http://dpaste.com/109411/ Thank you, Ana ...

How do I override Django's administrative change password page?

I'd like to override Django's administrative "Change Password" page (change_password.html). As such, I've placed Django's "/contrib/admin/templates/registration/password_change_form.html" in my project's "/templates/admin/registration/password_change_form.html" directory. Unfortunately, this doesn't seem to do the trick. At this point...

Is it "better" to have an update field or COUNT query?

In a Django App I'm working on I've got this going on: class Parent(models.Model): name = models.CharField(...) def num_children(self): return Children.objects.filter(parent=self).count() def avg_child_rating(self): return Child.objects.filter(parent=self).aggregate(Avg('rating')) class Child(models.Model)...

How do i combine a list and a form in the same page using django?

Am building a Q&A page, sort of stackoverflow kinda page! Am having a bit of a problem trying to render the form. Am pasing 3 objects to the template that renders the page i.e. Question object, Answers related to the question and Answer form object. In the first part of the page i want to display the Question, then the answers list foll...

Why is my django view returning a zero obejct list?

Guys, I might be lazy or am blind! but the following code is returning ZERO! items, while very well i know there is some items in the list, View: def post_answer(request, quest_id=None): answer_list = Answer.objects.filter (questionis__pk=quest_id).select_related() ... # if a put a print stmt here ( answer_list[0].answer ) the...

How to perform SQL LEFT JOIN's using Django?

Essentially I need a count of each Entries Comments: SELECT e.*, COUNT(c.id) as comments FROM blog_entry e LEFT JOIN blog_comment c ON e.id = c.entry_id GROUP BY e.id, e.name, e.name_slug, e.date_published, e.category, e.image, e.body, e.is_published, e.views, e.subscription_sent ORDER BY e.date_published DESC LIMIT 15; But I don't kn...

How do I read a Django HTTPResponse in Flex?

I'm a complete Flex noob, so I apologize in advance if I'm missing something obvious. I wrote a fairly simple file uploader in Flex, which calls my Django back-end via URLRequest (the FileReference object handles the upload). My upload works as intended and I have Django return a HTTPResponse object. As such, I'd like to read the cont...

What's the best way to "embed" a page number in a URL?

I'm developing a blog application using Django. Currently, the URL /blog/ displays the front page of the blog (the first five posts). Visitors can then browse or "page through" the blog entries. This portion is mapped to /blog/browse/{page}/, where page, of course, is an integer that specifies which "page" of blog entries should be displ...

Feature differentiation: Rails / Django

Are there any important features in Rails or Django which do not exist in the other framework? Is there anything important missing - for an enterprise web app - in either one? This question is not intended to be argumentative - I am trying to make an informed technology decison for an upcoming project. Two of the concerns I ha...

Which has more job openings for programmers - Rails or Django?

Based on this trend chart from indeed.com, Rails vs Django job openings my impression is that Rails currently has more openings but that Django is gaining popularity. Does anyone have personal experience in the job market or additional data to support this idea? ...

Queryset API distinct() does not work?

class Message(models.Model): subject = models.CharField(max_length=100) pub_date = models.DateTimeField(default=datetime.now()) class Topic(models.Model): title = models.CharField(max_length=100) message = models.ManyToManyField(Message, verbose_name='Discussion') I want to get order all the topics according to the lat...

Is it dangerous to leave your Django admin directory under the default url of admin?

Is it dangerous to have your admin interface in a Django app accessible by using just a plain old admin url? For security should it be hidden under an obfuscated url that is like a 64 bit unique uuid? Also, if you create such an obfuscated link to your admin interface, how can you avoid having anyone find out where it is? Does the goo...

Is it fair to accuse Rails of "magic"?

When I first started looking into Rails and Django I was steered away from Rails by Django developers who felt that Rails was a black box which uses an excess of "magic" (leaky abstractions). Upon exploring Rails further I wonder whether this is an uninformed assumption based on not knowing how to achieve customization in Rails without t...