django

Django slugified urls - how to handle collisions?

I'm currently working on a toy project in Django. Part of my app allows users to leave reviews. I'd like to take the title of the review and slugify it to create a url. So, if a user writes a review called "The best thing ever!", the url would be something like: www.example.com/reviews/the-best-thing-ever. That's all well and good...

Which framework for a project?

I am contemplating between three frameworks: Django, CakePHP and Zend. The project will include social aspect (members), will have a cart/checkout, lots of different forms and very heavy database usage. I would like to write most of my sql by myself but have only basic knowledge of web development. Both PHP and Python will be new languag...

deploying django to UserDir

I would like to deploy my django pet-project on our student server. We have apache2 with UserDir mod and I don't have access to apache2 config files. How do I deploy? :-D I come from PHP background and I deploy my PHP scripts by uploading them to my public_html dir and everything shows up on http://ourserver.com/~myusername. I read djan...

Avoiding O(n) queries with Django

I've got models like this: class PledgeItem(models.Model): title = models.CharField(...) usd_amount = models.DecimalField(...) class Pledger(models.Model): name = models.CharField(...) ... class Pledge(models.Model): pledger = models.ForeignKey(Pledger) item = models.ForeignKey(PledgeItem) usd_amount = m...

Flexible Model for CMS (Online Magazine) in Django

I am about to redesign an Online Magazine which was built in Plone. And I am going to do it in Django. (For the simple reason that I like Django and that I have to maintain this particular site for (basically) free.) However I am unsure about the way I should design the Models. Basically the idea is to have a Site structure - which in P...

a better way to do ajax in django

The other day I wrote some AJAX for a Django app that i have been working on. I come from Ruby on Rails, so I haven't done much in the way of raw JS. So based on Rails' partials, I something similar to the following in a sort of pseudocode, don't sweat the details: 1) JS function using prototype's Ajax.Updater ('tablediv' being the id...

Creating a news archive in Django

Hi need some help, I looking to build a news archive in python/django, I have no idea where to start with it though. I need the view to pull out all the news articles with I have done I then need to divide them in months and years so e.g. Sept 09 Oct 09 I then need in the view to some every time a new news article is created for a new...

Cannot access django app through ip address while accessing it through localhost

I have a django app on my local computer. I can access the application from a browser by using the url: http://localhost:8000/myapp/ But I cannot access the application by using the ip of the host computer: http://193.140.209.49:8000/myapp/ I get a 404 error. What should I do? Any suggestions? ...

Django - accessing the RequestContext from within a custom filter

I've got a filter currency, which takes a value in USD and converts it to a currency (either USD or GBP). The currency to convert to is stored in the session, but filters don't take RequestContext, so I can't grab it straight from there. Is there a better way than passing the relevant session element into the template, and from the temp...

How to approach creating Related Links generic (like Comments/Tags) in Django

Since I have not found a Related Links app that works with Django 1.0/trunk, I was looking to create my own. I would like to attach "Related Links" to models in the same generic way that Comments framework or Tags work. I've looked over the Content Types documentation but can't wrap my head around (nor find much documentation for) ho...

Is it possible to limit of object creation of a model in admin panel?

I just want to know that is it possible to limit the number of objects of a model in admin panel? It is that, for example, I have a model named 'Homepage' and in the admin panel I don't want a user can create more than one instance of Homepage. Is there a way I can do this? ...

How to build flexible inline formsets?

I have a complex form containing an inline formset, which basically has got some text fields and a file upload field. Now, I want to enable the user to create a new record, and within the same step attach several files. I think there are different options to achieve this, maybe I could write a jQuery-Plugin that clones the formset, do a...

Separate Admin/User authentication system in Django

I've recently started learning/using django; I'm trying to figure out a way to have two separate authentications systems for administrators and users. Rather than create a whole new auth system, I'd like to leverage django's built-in functionality (i.e. session management, @login_required decorator, etc.). Specifically, I want to have ...

Get list values in a Django Template

In view: return render_to_response('template.html', {'headers': list(sort_headers.headers()) }, context_instance=RequestContext(request)) In template: {{ headers }} <br /> {{ headers|slice:"1" }} In browser: [{'url': '?ot=desc&amp;o=0', 'text': 'Nombre', 'class_attr': ' class="so...

What is the best way to deal with a django model object?

I need some clear thinking on how to handle a save function on a django model. As you'll see below I am at a loss on how to do this elegantly. I'd like to pass the entire object to another module and analyze it there. My motivation for having the analysis broken out and not in models.py is that I will be frequently refining the analy...

What is the best way to post a date/time into a django view?

I'd like to build a view that allows the user to get a list of things that are happening around a certain time. What is the best way to build this request? E.g. If I wanted to get all of the events that are happening right now I could post to /events/2009/09/29/8/23/ That seems rather tedious especially if I want to have multiple date...

Access User object when generating a feed in Django

I'm working on a website that keeps track of upcoming homework assignments. I'd like to provide an RSS/Atom Feed that shows their upcoming assignments. However, I have no idea how I'm going to limit the items in the feed to their own, as not many feed readers support cookie-based sessions. Basically, I need to access the request object...

Set a "global pre-request variable" in Django in Middleware

I'm trying to combine Google App Engine with RPX Now user authentication and a per-user limited access pattern. The per user access-limiting pattern relies upon GAE's global User.get_current_user(), like-so: from google.appengine.api import users class CurrentUserProperty(db.UserProperty): def checkCurrentUser(self, value): if v...

Django ORM: Chaining aggregated querysets into one

Can I chain these two querysets into one? qs1 = OrderTicket.objects.filter(date__gt=datetime.date(2009, 1, 1), date__lt=datetime.date(2009, 1, 30)).values('order_type').annotate(value_1 = Sum('gbp_value')).order_by('order_type'), qs2 = OrderTicket.objects.filter(date__gt=datetime.date(2009, 2, 1), date__lt=datetime.date(2009, 2, 30)).va...

Aggregating multiple feeds with Universal Feed Parser

Having great luck working with single-source feed parsing in Universal Feed Parser, but now I need to run multiple feeds through it and generate chronologically interleaved output (not RSS). Seems like I'll need to iterate through URLs and stuff every entry into a list of dictionaries, then sort that by the entry timestamps and take a sl...