django

Is content from AJAX call added to Django context variable

Hi, I am using the JQuery load function to load part of my page. Can I access the variables from that page in the page that loads it. e.g. Page A uses JQuery load function to load B Page B loads and sets a variable in context called pageB_var which holds a django object Page A can then access this variable by doing {{pageB_var}} sinc...

django authentication .htaccess static

In my app users can upload files for other users. To make the uploaded files accesible only for the addresse I need some kind of static files authentication system. My idea, is to create the apache hosted directory for each user and to limit access to this derectory using .htaccess. This means that each time new django user is created,...

Django 1.2 + South 0.7 + django-annoying's AutoOneToOneField leads to TypeError: 'LegacyConnection' object is not iterable

I'm using Django 1.2 trunk with South 0.7 and an AutoOneToOneField copied from django-annoying. South complained that the field does not have rules defined and the new version of South no longer has an automatic field type parser. So I read the South documentation and wrote the following definition (basically an exact copy of the OneToOn...

Where to put Django startup code?

I'd like to have these lines of code executed on server startup (both development and production): from django.core import management management.call_command('syncdb', interactive=False) Putting it in settings.py doesn't work, as it requires the settings to be loaded already. Putting them in a view and accessing that view externally ...

mysql function warning

hi here is a short version of function which im using on daily basis, it works fine except it throws a warning 'No data - zero rows fetched, selected, or processed (errno. 1329)'. and since i start using this function with django there cant be any warning or error because it stop the whole process i have read that there is no warning fi...

How to layout a queue/worker structure to support large tasks for multiple environments?

For a Python/Django/Celery based deployment tool, we have the following setup: We currently use the default Celery setup. (One queue+exchange called "celery".) Each Task on the queue represents a deployment operation. Each task for an environment ends with a synchronisation phase that potentially takes (very) long. The following spec...

use admin functionality for a registered user to add products

Hello, I am developing a django project for auctions. I want to add the following functionality: A registered and logged in user must add a product (I have accomplished registration and authentication). When this user clicks some /add/product/ or whatever link, I need to fetch the very admin-add-product template-interface (redirect mayb...

Django: way to test what class a generic relation content_object is?

In my project I have a class, NewsItem. Instances of NewsItem act like a wrapper. They can be associated with either an ArtWork instance, or an Announcement instance. Here's how the NewsItem model looks: class NewsItem(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_o...

Datastore query outputting for Django form instance

Hello! I'm using google appengine and Django. I'm using de djangoforms module and wanted to specify the form instance with the information that comes from the query below. userquery = db.GqlQuery("SELECT * FROM User WHERE googleaccount = :1", users.get_current_user()) form = forms.AccountForm(data=request.POST or None,instance...

Django Test Failing

Hello all! I am experiencing an error running django unit tests, I've not experienced this before, and have been googling it all afternoon. I am getting this error in terminal after running django manage.py test: Error: Database test_unconvention couldn't be flushed. Possible reasons: * The database isn't running or isn't configured...

What's a good way to format AJAX responses? Or, using Django templating with AJAX

In some of the code I'm working on, the author max AJAX calls to a Django view that returns JSON. Once the JSON is retrieved, it'll be injected into the page with a function that looks like this (note, this is a simplification, but I'm sure you know what I'm getting at here): function build_event_listing(events) { var html = ''; ...

Default value for field in Django model

Suppose I have a model: class SomeModel(models.Model): id = models.AutoField(primary_key=True) a = models.IntegerField(max_length=10) b = models.CharField(max_length=7) Currently I am using the default admin to create/edit objects of this type. How do I set the field 'a' to have the same number as id? (default=???) Other...

How to build a Django form which requires a delay to be re-submitted ?

Hey, In order to avoid spamming, I would like to add a waiting time to re-submit a form (i.e. the user should wait a few seconds to submit the form, except the first time that this form is submitted). To do that, I added a timestamp to my form (and a security_hash field containing the timestamp plus the settings.SECRET_KEY which ensure...

Default value for hidden field in Django model

I have this Model: class Occurrence(models.Model): id = models.AutoField(primary_key=True, null=True) reference = models.IntegerField(null=True, editable=False) def save(self): self.reference = self.id super(Occurrence, self).save() I want for the reference field to be hidden and at the same time have th...

Django DRY Feeds

I'm using the Django Feeds Framework and it's really nice, very intuitive and easy to use. But, I think there is a problem when creating links to feeds in HTML. For example: <link rel="alternate" type="application/rss+xml" title="{{ feed_title }}" href="{{ url_of_feed }}" /> Link's HREF attribute can be easily found out, just use rev...

How do I add a field in Django model whose data type is set to text

text_field = models.CharField(max_length=max) can I do this? I am using postgresql 8.4. Thanks ...

How to copy a django project from one folder location to another?

Am using eclipse+pydev to build my django apps. I created a new workspace, built a new pydev project then created an empty folder in the new pydev project. In that empty folder i imported my old django application. Eclipse copied all the files & folders from my old django location to the new workspace. I made the necessary changes in th...

django powering multiple shops from one code base on a single domain

Hey, I am new to django and python and am trying to figure out how to modify an existing app to run multiple shops through a single domain. Django's sites middleware seems inappropriate in this particular case because it manages different domains, not sites run through the same domain, e.g. : domain.com/uk domain.com/us domain.com/es e...

Create Django formset wihtout multiple queries

I need to display multiple forms (up to 10) of a model on a page. This is the code I use for to accomplish this. TheFormSet = formset_factory(SomeForm, extra=10) ... formset = TheFormSet(prefix='party') return render_to_response('template.html', { 'formset' : formset, }) The problem is, that it seems to me that Django queries...

Manually logging in a user without password

Hi everybody; I hope you can help me figure the best way to implement a manual (server-side initiated) login without using the password. Let me explain the workflow: User registers Thank you! An email with an activation link has been sent blablabla (Account now exists but is marked not enabled) User opens email, clicks link (Account ...