I have a DateTimeField called created in my model and I would like to get all the objects where created date is 30 min or more. How would query this using MyModel.objects(....) in django?
One of my applications in my Django project require each request/visitor to that instance to have their own thread. This might sound confusing, so I'll describe what I'm looking to accomplish in a case based scenario, with steps:
User visits application
Thread starts
Until the thread finishes, that user's server instance hangs
Once the thread completes, a response is delivered to the user
Other visitors to the site should not be affected by any other users using the application
How can I accomplish something like this? If possible, I'd like to find a lightweight solution.
Does anyone here use django-grappelli here ?
I would like to read some experience of developers or users, if there are common mistake to avoid or why you use or do not use grappelli.
Thanks for sharing
Hello everyone,
My database has two types of entries: The very dynamic (users, comments, etc) and the more static (email templates, flat-pages).
During testing I want a clean DB but with the real 'semi-static' data.
Is there a way to make Django's testing system to load parts of the original DB ?
Thanks
When you run syncdb in Django, the primary keys of the content types will be recomputed. If I create new models, the next time I run syncdb, the primary keys of the content types will be different.
If I have an application running in production, how can I update the database with the new models and keep the integrity of content type pks?
Hello,
I want to implement a commenting system for some pages by using the build-in commenting framework of Django.
The only addition to the default commenting framework is that other registered users can up/down vote comments (one time allowed indeed), just like Digg or Reddit style.
I have found RedditStyleVoting however it seems out of date and not really covering what I am looking for.
My application has two node types: a parent node which can hold recursive child nodes. Think of it like the post-comment system in SO, but comments can be recursive:
parent_1
child_11
child_12
child_121
child_3
parent_2
child_21
child_211
child_2111
Important to note that the parent nodes have different attributes and behavior than the child nodes.
What is the correct (and presumably most efficient) way of modeling this relationship in Django?
I trying to restful server that one can upload image, By use django-piston I can put,get,post information restfully but don't know how to upload image.
Hi All, Im new to django and trying to make a user registration form with few validations.
Apart from this I also want a username suggestion code which will tell the user if the username he is trying to register is available or already in use. Then it should give few suggestions that might be available to choose from. Can anyone who might have worked on the same or somewhat same project help me with this.
Thanks
Within Django, can a function local to a model be called on object creation to dynamically fill a field?
class someModel(models.Model):
id = models.FloatField(primary_key=True, default=generate_id())
def generate_id(self):
newId=time.time()
return newId
So far I haven't had any luck with getting it to work or with locating documentation that covers it.
How can I set up Django in Window Xp and Ubuntu OS
I finished the step for connection with Database and some problem with connect to admin..
I do it from reading ebook and do it..So there is any easy steps for me..
Please share all idea.
There is a form ,which is submitted and then the page is redirected to another page.But if the user hits the refresh button again on the new page .the following message is displayed
To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.
And on press "OK"
A duplicate entry is created how do i prevent this or how do i handle this
I am using a django,application
Thanks..
In django models say this model exist in details/models.py
class OccDetails(models.Model):
title = models.CharField(max_length = 255)
occ = models.ForeignKey(Occ)
So when sync db is made the following fields get created
and later to this of two more fields are added and sync db is made the new fields doesnt get created.How is this to be solved,Also what is auto_now=true in the below
these are the new fields
created_date = models.DateTimeField(auto_now_add=True)
modified_date = models.DateTimeField(auto_now_add=True, auto_now=True)
Hi,
I have a XML file that is managed by other programs, I am writing a web service such that users are able to query this file. In essence i am using a xml based database instead of using sql as the model database in Django.
how do i do this? all the tutorials that i find use a sql database in the backend. is there a way to use the xml file as a database.
In Django, I have SESSION_COOKIE_DOMAIN set to my domain name. But I would actually like to run the same site with two different domain names.
With SESSION_COOKIE_DOMAIN set, only the named domain allows the user to login. Is it possible to allow both domains to login?
I am using the delete() function from django.contrib.comments.views.moderation module. The staff-member is allowed to delete ANY comment posts, which is completely fine. However, I would also like to give registered non-staff members the privilege to delete their OWN comment posts, and their OWN only. How can I accomplish this?
In Django there is a settings file that defines the middleware to be run on each request. This middleware setting is global. Is there a way to specify a set of middleware on a per-view basis? I want to have specific urls use a set of middleware different from the global set.
Hi!
I need to implement a "Remember me" button in a login form that uses the django-registration app. Any ane can help me showing me the way for do this?
Thanks
I am working on a Silverlight project that uses Django on the server using piston for the REST API. I understand that Silverlight doesn't support the PUT and DELETE http verbs. Is there another way i can pass these kinds of commands to piston?
Ive defined a a class that inherits from django.contrib.syndication.feeds.Feed
class Rss(Feed):
...
def item_title(self, item):
return "Hello"
def item_description(self, item):
return "Test"
The issue those strings are never used, even when not using a template whats used is the templates you define.
Am I missing something?
Hi,
is there something like getters and setters for django model's fields?
For example, I have a text field in which i need to make a string replace before it get saved (in the admin panel, for both insert and update operations) and make another, different replace each time it is read. Those string replace are dynamic and need to be done at the moment of saving and reading.
As I'm using python 2.5, I cannot use python 2.6 getters / setters.
Any help?
Hello All,
I m not able to change the locale of django -admin when i switch to different locale from browser.But if i mention in my settings.py the language code then it is working but browser locale doesnot have any impact on it
#setting.py
LANGUAGES = (
('ar', gettext_noop('Arabic')),
('ja', gettext_noop('japanese')),
('bg', gettext_noop('Bulgarian')),
LANGUAGE_CODE = ''#
LANGUAGE_COOKIE_NAME = 'django_language'
LOCALE_PATHS = ()
In a django template, I want to get an value from the first object in a list's field.
I have the following code
{{ list.object|first.field }}
But it results in an error.
Is there a way to achieve this without writing a loop or doing it in the view?
Hi Im using Filebrowser for Django and also TinyMCE. I include TinyMCE in my admin text area editor by adding a admin template to folder media in my templates with filename base_site.html
Now when I add a image with filebrowser, tiny_mce adds a leading ../../../../ before /media/uploads/etc/image.jpg
Any ideas why? I guess its some URL thats not set correct. But im not sure if its tiny_mce or filebrowser.
I have a simple django's query set like:
qs = AModel.objects.exclude(state="F").order_by("order")
I'd like to use it as follows:
qs[0:3].update(state='F')
expected = qs[3] # throws error here
But last statement throws:
"Cannot update a query once a slice has been taken."
How can I duplicate the query set?