django

get an error while applying a widget to a field

Here is my model class RecipeIngredient(models.Model): recipe = models.ForeignKey(Recipe) ingredient = models.ForeignKey(Ingredient) serving_size = models.ForeignKey(ServingSize) quantity = models.IntegerField() order = models.IntegerField() created = models.DateTimeField(auto_now_add = True) updated = models...

sharing database table between two django projects

I have two different Django projects that are meant to run in parallel and do pretty different things. However they need to share a common database table, the Client table.. Both projects contains multiple apps that needs to contain foreign keys mapped to that Client model.. I'm not sure what would be the best approach.. ...

django tar generation on request

Greetings, By using Django, I want to generate a tar.gz which contains the files below, and render a tar.gz file: Content from an Ubuntu server: /home/user/myfolder /home/user/image.jpg an xml file from www.mysite.com/foo.xml (which is a dynamicly generated xml file. Rendered tar.gz file myfolder/ content/ ..... ...

Django Db Images video

Hi How can I store Images, Videos and Audio via Django in a Mysql db? I know I can either store the link to the image, video, audio, or the image, video, audio itself. But how does this exactly work. I know about the models and how they create tables via the manage.py. But is there a good tutorial on how to create an image (e.g. jp...

how to enable custom string in django.po for Localization in django

this is the demo.rar file. 1 . i use this code to create a zh-CN : django-admin.py makemessages -l zh-CN 2 . i add some string to django.po : msgid "zjm1126" msgstr "哈哈哈!!!" 3 . and then compile it : django-admin.py compilemessages but i don't find it become chinese words so why ? thanks ...

"Annotating" querysets with model function returns

Basically I want to do something similar to annotating a queryset but with a call on a function in the model attached to the response. Currently I have something like: objs = WebSvc.objects.all().order_by('content_type', 'id') for o in objs: o.state = o.cast().get_state() where get_state() is a function in the model that calls an...

Django url parsing -pass raw string

Hello, I'm trying to pass a 'string' argument to a view with a url. The urls.py goes ('^add/(?P<string>\w+)', add ), I'm having problems with strings including punctuation, newlines, spaces and so on. I think I have to change the \w+ into something else. Basically the string will be something copied by the user from a text of his cho...

Comet framework for Django

What is the easiest way to implement HTTP push (comet) on Django? Are there any existing frameworks? Simple examples would be great. ...

Django templates: testing if variable is in list or dict

Hi, was wondering if there is a way to test if a variable is inside of a list or dict in django using the built in tags and filters. Ie: {% if var|in:the_list %} I don't see it in the docs, and will attempt something custom if not, but I don't want to do something that has already been done. Thanks ...

Django (Dajax / Jquery?) plugin to display a console of live messages

Hi, I'm trying create a box in my Django app that displays text (and possibly images) from the server as certain processes are completed server side. I was hoping to use a plugin that used Dajax / Jquery but I'm unable to find one. Is there a solution out there that is simple? Thanks. ...

Django Feeds Add Item Entity

I have a Django Feed spitting out RSS. The problem is the model that i am using has extra fields that dont get included in the default RSS that I need to use on the receiving end of RSS. I found documentation on "add_item_elements" method that sounds like I want to do. Yet I cant seem to get it to work. Method implementation is below. ...

Django Admin Queryset Method Override; Poorly Performing Query

I have a system with multiple Sites in it. Every User object in the system gets a Profile object attached to it which governs which Sites they have permission to interact with. The system also has an Article model which can belong to multiple sites. So, when a user loads up the Article admin page, I only want them to see Articles that ar...

How to lazily evaluate ORM call after fixtures are loaded into db in Django?

I've got a module pagetypes.py that extracts a couple of constants (I shouldn't really use word constant here) from the db for later reuse: def _get_page_type_(type): return PageType.objects.get(type=type) PAGE_TYPE_MAIN = _get_page_type_('Main') PAGE_TYPE_OTHER = _get_page_type_('Other') then somewhere in views I do: import pag...

list_editable and save changes to individual row/cell

Hi all, Does anyone know if there is a way to save changes on a per row/cell basis for forms with list_editable in django admin? I would like to have a button for each row and each cell to do that. Thanks a lot! Jason ...

How to display a relative-to-absolute date cross-browsers?

How can I manipulate dates so that they show up as "just now"... "5 mins ago"... "3 hours ago"... "June 22nd, 2010 at 1:45pm" in similar fashion to how SO displays the dates next to the answers/comments to each question? To further complicate matters, the dates stored in my database are in GMT time (which is fine), but I want them to a...

How do I "print" something to the console in pylons?

paster serve --reload development.ini ..for debug = true THis is what I do to load a development server for Pylons. However, when I do: print "hello world" THis message doesn't print out in the console. In Django, it does. ...

Django GenericTabularInline simply won't work, but model is correct.

Hi there, I just converted one of my models to use a generic foreign key. The model is working correctly with these, database is reporting correct values, and the API I have is working perfectly with the new foreignkey with zero change (Kept the same field name). However, the admin totally fails. The Inline shows no data, despite there...

๋GeoDjango problem

I already create model by use django.contrib.gis.db.models but when I use admin page to add item, After save then django give me "Caught an exception while rendering: cannot set GeometryProxy with value of type: " so admin page crash, anyone have some guide to fix this. ...

Django to do its own NTLM Authentication (HTTP Headers & all)

I'm considering moving from Apache to Lighttpd for an internal web application, written with python. The problem is that I'm relying on libapache2-mod-auth-ntlm-winbind ... which doesn't actually seem to be a well support & updated package (though that could be because it really does work well). I'm looking for suggestions and hints ab...

Google Maps not working in Django template on App Engine development server

When I add this script to a plain HTML file's HEAD section <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt; and I run this script on the body onload, function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, cent...