django

Django and App Engine

I wanted to check the status of running Django on the Google App Engine currently and what the benefits of running django on GAE over simply using Webapp. Django main killer feature, IMHO, is the reuseable apps and middleware. Unfortunately, most current Django apps use models or model forms (django-tags, django-reviews, django-profile...

django formset - how to update an object

Hi, How can I update an object from a formset using request.POST? Here is my code and my problem is that this always creates a new PhoneNumber object. But I want to update the old PhoneNumber object. def contact_detail(request, contact_id): contact = get_object_or_404(Contact, pk=contact_id) phone_number_list = PhoneNumber.ob...

Problem with django's url template tag (and reverse() function)

I have the following view function in activities.views: def activity_thumbnail(request, id): pass I'm trying to get the URL for that view in one of my templates. When I try the following: {% url activities.views.activity_thumbnail latest_activity.id %} I get the following error: Caught an exception while rendering: Reverse ...

Django: signal when user logs in ?

In my Django app, I need to start running a few periodic background jobs when a user logs in and stop running them when the user logs out, so I am looking for an elegant way to get notified of a user login/logout query user login status From my perspective, the ideal solution would be a signal sent by each django.contrib.auth.views...

How can I schedule a Task to execute at a specific time using celery?

I've looked into PeriodicTask, but the examples only cover making it recur. I'm looking for something more like cron's ability to say "execute this task every Monday at 1 a.m." ...

Migrate user accounts from Joomla to Django

I'm overhauling a site I'd originally made using Joomla to Django, and I was wondering if I can import the user records directly from Joomla (my main concern is the user passwords as they are encrypted). ...

django last 30 entry list with count

With a model like this in Django, how to retrive 30 days entries with count how many were added on that day. class Entry(models.Model): ... entered = models.DateTimeField(auto_now_add=True) ...

How does Django + mod_wsgi affect the python path?

I have a simple setup with my python libraries in /domains/somedomain.com/libs/ and all my tests run fine. I start WSGI with DJANGO_SETTINGS_MODULE to "somedomain.settings" where somedomain is a package in libs/ Suddenly, when adding pywapi.py into libs/ I can't import it when hitting the site. But, if I add 'import pywapi' to my wsgi s...

Django: Initializing a FormSet of custom forms with instances

Given the following models: class Graph(models.Model): owner = models.ForeignKey(User) def __unicode__(self): return u'%d' % self.id class Point(models.Model): graph = models.ForeignKey(Graph) date = models.DateField(primary_key = True) abs = models.FloatField(null = True) avg = models.FloatField(...

Passing **kwargs to Django Form

I am trying to build custom django form for changing username and user email for an application. That's why I need to pass the user details from the session to a form in order to check if the logged user exists. I am doing in this way: in views.py personal_info_form = PersonalInfoForm(prefix='personal_info', user_details=user_details) ...

Compare attributes of a Django Queryset in a template using the `in` Operator

I'm trying to use the in operator to determine if a template variable on the current page is also a foreign key in another model. The model is like so: class WishlistItem(models.Model): user = models.ForeignKey(User, related_name='wishlist_items') issue = models.ForeignKey(Issue) On the "Issue" page template, I'm trying to d...

Django FILES upload: path and filename

When an uploaded file is received by the Django server, its name can be read using UploadedFile.name If filename in the multipart-data content contains a path like: '/a/b/c', UploadedFile.name seems to contain '/c' . How can I retrieve the full path and not just the file name. Thanks. Laurent Luce ...

Indeterminite number of apps/widgets in Django template

Hi, I'm working on a site that will have a bunch of pages with an indeterminate amount of "apps" on each page. Something like a calendar app, and a random picture app, or whatever, each in a neat little box. While it's possible to write a template with a bunch of if tags that include other templates, this is a bit of a hassle. I'd like ...

Drag and drop ordering of formset with extra entries

I have been looking for a way to allow the user to easily change the order of entries in a formset. I found a StackOverflow question that addresses this subject, with the accepted answer referencing a Django Snippet that uses a JQuery tool to allow drag 'n drop of the entries. This is nifty and cool, but I have a problem with 'extra' e...

Programmatically Upload Files in Django

Hello everyone, I have checked several other threads but I am still having a problem. I have a model that includes a FileField and I am generating semi-random instances for various purposes. However, I am having a problem uploading the files. When I create a new file, it appears to work (the new instance is saved to the database), a f...

Why can't I find '__path__' in django.db.__init__.py?

backend_dir = os.path.join(__path__[0], 'backends') Why can't I find it? ...

how to start a thread when django runserver ?

I want to start a thread when django project runserver successfully. where can I put the create-thread-and-start code? Is there any hook for the django runserver? ...

Invalidating a path from the Django cache recursively

I am deleting a single path from the Django cache like this: from models import Graph from django.http import HttpRequest from django.utils.cache import get_cache_key from django.db.models.signals import post_save from django.core.cache import cache def expire_page(path): request = H...

django access model object fields on run-time

Hi, I have a list of fields for an object: fields = ('title', 'first_name', 'last_name) Now I want to access the fields of my object on runtime, without harcoding it like this. myobject.title What I'm searching for is something like this: myobject.getFieldValue('title') Is there a method like this in django? I did not find one....

Django/Python: How can I make the following number increment (not in database)

I would like to create a number like: 000000000001 to save to the database. I obviously cannot increment in this fashion (I don't think) in a database, so I'm looking for the most efficient method for pulling the previous number from the database and incrementing it by 1 to create the next record: 000000000002 and so on... If I st...