django

How to make a private download area with django?

Hello I would like to implement a private download area on a website powered by django. The user would have to be logged in with the appropriate rights in order to be able to get some static files. What would you recommend for writing this feature. Any tips or tricks? Thanks in advance Update: Maybe because of my bad english or my la...

How can I upload files to django from within AS3 Flash?

I need to build a file uploader in AS3 that is capable of uploading files into an authenticated django view which contains a form with a file upload input. I have been working on this for an entire 7 days, all day. After much digging, I have discovered that Adobe, in their infinite wisdom has disabled cookie headers from being sent...

How should I use django models from other applications?

What is the proper way to use models from other django applications in my application? For example, should I simply go into the other application's models and add my functionality effectively coupling the two applications? Should I subclass the models using a django proxy model to add my application specific functionality? This method, ...

How do I display notifications from `django-notification`?

I've been reading the docs for django-notification, and they seem to cover creating notifications just fine, but not how to display them to users. Is there a good reference for this out there, and my Google-fu has just failed me? If not, can someone give me some pointers here? Thanks. ...

Django Testing Framework with login decorators - do they work? Error with reverse

I am using the Django testing framework (which is useful, but feels clunky and awkward). A test keeps failing, and the traceback leads me to believe it's an issue with the login decorators. Here are the tests, the error, and the relevant code: class TestMain(TestCase): fixtures = ['timetracker'] def test_login(self): c ...

Render one queryset into 2 div columns (django template)

Is there a good way to render the enumeration of a queryset into two div columns? Using 960 grid, I've got something to the effect of... <div class="container_16"> <div class="grid_8 alpha"></div> <div class="grid_8 omega"></div> </div> In Django, one model needs to have it's enumerated contents rendered in both of those colu...

How to query a Django model defining a IP range with two int fields (IP, mask)

I have: class Range(models.Model): ip = models.IntegerField() # as produced by socket.inet_aton + struct.unpack mask = models.IntegerField() Given a certain IP, how can I get all the ranges that match this specific IP using the Django models? If I were using raw SQL, I would use the database's bitwise operators, but the Djang...

How do I POST an object's model for use in a view via ajax?

Am working on my earlier hit count question and ran into another stumbling block: how do I post an object's model information through ajax ? I am using the generic object_detail view for a number of my models and I want to add some ajax to the template that calls my updapte_object_hit_count function (thereby tracking the object's hit ...

Passing Custom Form parameter to formset

Hi, I have the following Form defined class MyForm(ModelForm): def __init__(self, readOnly=False, *args, **kwargs): super(MyForm,self).__init__(*args,**kwrds) if readOnly: Do stuff to make the inputs readonly MyForm works perfectly when I instantiate it in the view as a form form = MyForm(readOnly=True...

What is the best way to do a nav bar search box in Django?

I would like to have a search box integrated into a nav bar that appears on the top of each page (hey, there is an example of what I am talking about up there at the top of this StackOverflow page). Perhaps the nav.html may look like: <ul id="menu"> <li><a href="/products"></li> <li><a href="/service"></li> <li>{{ nav_searc...

Ecommerce with django in google app engine

Is there any module available for googlecheckout/paypal in django on google app engine? are there any example apps which are doing this? ...

Django ORM - select_related and order_by with foreign keys

I have a simple music schema: Artist, Release, Track, and Song. The first 3 are all logical constructs while the fourth (Song) is a specific instance of an (Artist, Release, Track) as an mp3, wav, ogg, whatever. I am having trouble generating an ordered list of the Songs in the database. The catch is that both Track and Release have a...

django query set

I am writing queryset in django. In the first queryset it is working fine. In the second it is giving the error " cannot resolve xyz into a field .. .. " In models.py class XYZ(models.Model): id= models.AutoField(primary_key=True) name = models.CharField(max_length=200) addres= models.CharField(max_length=200) def __unico...

Using thickbox with imagekit

I want to use jQuery Thickbox for displaying my images but so far when I click on a thumbnail all I get is the loading progress bar. I've set up my display as below (maybe this will help) <div class="thumbs"> {% for p in photos %} <a href="{{ p.original_image.url }}" title="{{ p.position.position }}" class="thickbox" rel="gallery...

Should I normalize the intermediary model in django?

Say I have four pair-wise M2M related models: A, B, C, D. I have created an intermediary model ABCD to establish relationships between them. If there are many duplicate column pairs in the database, is it a normal practice to normalize the intermediary model into multiple models? What I am concerned about are: 1. Breaking down ABCD wil...

Copying values from a dictionary into an object in Python

I have a dictionary that I would like to iterate through and copy the key-value pairs into an object in Python. The dictionary is POST, and the object is a Model (in Django, perhaps Django has better way to do this). In PHP, I'd be able to use variable assignments: foreach($post as $key => $value) { $my_model->$key = $value; } A...

Configure Django to find all doctests in all modules?

If I run the following command: >python manage.py test Django looks at tests.py in my application, and runs any doctests or unit tests in that file. It also looks at the __ test __ dictionary for extra tests to run. So I can link doctests from other modules like so: #tests.py from myapp.module1 import _function1, _function2 __test__...

Remove pk field from django serialized objects

I'm serializing a bunch of objects with: json = serializers.serialize("json", objects, fields=('name', 'country')) I have not included 'pk' in my fields list, but the produced JSON includes a primary key with each serialized object. I do not want my API to expose primary keys to the general public. Short of munging the output JSON, ...

Setting an object in the Django cache API fails due to pickle error

I'm trying to manually set an object in the Django cache API but it fails (i think due to pickling?) The object is given to me by a third party, my code is: def index(request, template_name="mytemplate.htm"): user_list = cache.get("user_list_ds") if user_list is None: # this is the expensive bit I'm trying to cache ...

Storing Images on App Engine using Django

I'm trying to upload and save a resized image in a db.BlobProperty field on Google App Engine using Django. the relevant part of my view that process the request looks like this: image = images.resize(request.POST.get('image'), 100, 100) recipe.large_image = db.Blob(image) recipe.put() Which seems like it would be the logical django ...