django

Django | how to append form field to the urlconf

I want to pass a form's field value to the next page (template) after user submit the page, the field could be user name, consider the following setup def form_submit(request): if request.method == 'POST': form = UsersForm(request.POST) if form.is_valid(): cd = form.cleaned_data try: ...

can you use this method to load staic file using django on google-app-engine.

look this simple django on gae : http://code.google.com/p/google-app-engine-samples/source/browse/trunk/django_example and this is my code: DIRNAME = os.path.dirname(__file__) MEDIA_ROOT = os.path.join(DIRNAME, 'Media') MEDIA_URL = '/mymedia/' (r'^mymedia/(?P<path>.*)$', 'django.views.static.serve',{'document_root':settings.MEDIA_RO...

Need help installing django-cms

This question is from a Django and Django-cms rookie attempting to install django-cms on a shared hosting account. Here's what I have done so far: Django has been installed in ~/.local/lib/python (using python 2.4.3) Flup has also been installed in same place Created my app (site) directory - ~/.local/lib/python/eck downloaded and extr...

get average from set of objects in django

Hay, i have a simple rating system for a property. You give it a mark out of 5 (stars). The models are defined like this def Property(models.Model) # stuff here def Rating(models.Model) property = models.ForeignKey(Property) stars = models.IntegerField() What i want to do is get a property, find all the Rating objects, co...

Django Show M2M field in either model when using forms.ModelForm

Hi I am using the forms.ModelForm to create my form. I want to be able to show the manytomany field in both model forms, how do I do this? If the manytomany relationship is defined in the model it is fine and just appears but if it is not in the model (but is still linked via the other model) it does not appear. How can I make it sh...

Complex form widgets in Django

I am looking for good helper libraries to generate a rather complex form in Django. Dynamic field dependencies: Say if option a is selected certain fields are shown/hidden and subset of these are mandatory depending on option selection. Add more: On clicking "Add more" button that clones some widget. This is something which ToscaWid...

Showing user ratings for django object list

I have a template which is just a simple list of objects, and I would like to show the current user's rating for each object next to that object. Here are the relevant models: class Problem(models.Model): question = models.TextField() answer = models.TextField() topic = models.ForeignKey(Topic) class Attempt(models.Model): ...

Get original query from Django

Hi, I would like to get the original query (in the exact same format as sent) from Django. Currently, django sends me a query dict object, wherein if I do querydict.urlencode(), I get the query back, but in a different format from what is sent, since dictionary mangles the positions. For GET, we can use, request.get_full_path(). I ha...

Django website on Apache with wsgi failing

I have a website I've built in django that I'm trying to get working on our corporate Apache server (on debian) for our intranet at my workplace. Unfortunately, Apache keeps returning server errors whenever I try to navigate to my site. Although I can navigate to the statics folder. My Apache config and wsgi script look like the followin...

I can't load the css files

I want to load some .css files to my Django project but I don't know why they aren't loaded. The css files are located at "/myproject/media/css". settings.py: import os.path PROJECT_DIR = os.path.dirname(__file__) MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') urls.py: from django.conf import settings ... (r'^media/(?P<path...

Django check for any exists for a query

In django how to check whether any entry exists for a query sc=scorm.objects.filter(Header__id=qp.id) This was how it was done in php if(mysql_num_rows($resultn)) { } else { } ...

Facebook Graph API and Django

Hello, I am curious if there is any article/ library / anything useful that is built for the newly announced Facebook Graph API. I am planning to use it for a Python/Django project. ...

Django Generating RSS feed with description

Hey Guys, I am trying to generate a full rss feed, however when loading the feed in Mail, it just shows the title, with a read more link at the bottom. I have tried several different options. But none seem to work. I would like to generate the feed with a combination of several feeds in my modl. Here is the code i have tried: class...

Django vs GAE + Django vs GAE + other framework

I`m looking for opinion which one is better for building web applications(web sites). I have some experience with Django, and some with Google App Engine and App-Engine-Patch for Django. And it seems to me that only Django is working faster than the GAE implementation. Is there some other frameworks that simplify the developments process...

Unittest in Django. How to get the exception message from assertRaises()?

I used the assertRaises() to validation there will be an exception thrown and there is no problem of this. My question is, is there any way to get the exception message from assertRaises()? I would like to assert for different types of exceptiosn as well by parsing the exception message.. ...

How do I use Django signals with an abstract model?

I have an abstract model that keeps an on-disk cache. When I delete the model, I need it to delete the cache. I want this to happen for every derived model as well. If I connect the signal specifying the abstract model, this does not propagate to the derived models: pre_delete.connect(clear_cache, sender=MyAbstractModel, weak=False) ...

Can I create a django widget which posts back the form on a mobile?

Hi, I would like to create a widget for use in Django Forms. There is a problem though: i don't know how to make it properly work on a mobile. I'm wanting to create something like this: Send message to: search-box-here search and pressing search will post the page, but not actually submit the form at all. instead the widget will perfor...

Django: Staff Decorator

I'm trying to write a "staff only" decorator for Django, but I can't seem to get it to work: def staff_only(error='Only staff may view this page.'): def _dec(view_func): def _view(request, *args, **kwargs): u = request.user if u.is_authenticated() and u.is_staff: return view_func(reque...

Complex derived attributes in Django models

What I want to do is implement submission scoring for a site with users voting on the content, much like in e.g. reddit (see the 'hot' function in http://code.reddit.com/browser/sql/functions.sql). Edit: Ultimately I want to be able to retrieve an arbitrarily filtered list of arbitrary length of submissions ranked according to their sc...

Learning Django as an experienced ASP.NET developer

I am quite aware of the MVC concept, though I have never developed anything bigger in ASP.NET MVC, but I have been developing ASP.NET pages for years now. So is there any good tutorial or even better: a book that is suitable for an ASP.NET developer and does comparisons? Especially I am looking for information on Django reusability/how...