django

Django RSS Feed Authentication

I am looking into adding RSS feeds to one of my Django apps and I would like to be able to have them be authenticated. I want to use the new syndication framework in Django 1.2. I've read the docs on how to do this and have the basic feeds setup. I am new to authenticating feeds, so I am not sure what the best approach to take is o...

Unable to login to admin site in localhost

I can't login to the admin site on localhost. I try with firefox, IE. I try using the 127.0.0.1:8000 address. Also, I set the SESSION_COOKIE_DOMAIN to localhost, localhost:8000 I change the host file to: 127.0.0.1 test.com and set: SESSION_COOKIE_DOMAIN = 'test.com' I can login in production (only after the SESSION_COOKIE...

django: can we do loader.get_template('my_template.txt')?

Hi, I want to use django template to process plain text file, and tried this: from django.template import loader, Context t = loader.get_template('my_template.txt') however, it works for this: from django.template import loader, Context t = loader.get_template('my_template.html') Can we load txt files using django template loader? ...

Change Django Form Data before it's processed

I have a form for a model wich has two fields: field_A and field_B. I want to: when the form is rendered: only field_A is displayed when i call form.save() field_B is saved in the model with the value from field_A What i've tried: field_A = forms.CharField(required=True) field_B = forms.CharField(required=False) def save(self, *arg...

Returning two things in one HttpResponse

I am trying to implement paging across ajax calls. The page should not refresh when the user wants to see the next x num of results. Here is my problem. Returning the QuerySet is super simple. I just do (sumaJson is custom) data = serializers.serialize('sumaJson', result_page.object_list, relations=('first_major', 'country_of_origin', ...

Google appengine blobstore debugging

I'm having an issue with blobstore uploads, but because of the way gae handles all of that, actually figuring out what the error was is giving me some trouble. I'm using django, which unfortunately tries very hard to prevent exceptions from reaching the user without formatting. It looks like the uploads are successful, there are __Blob...

How to replace all the Characters with * using Regular Expression

I am having a text like s = bluesky i want to get it as s = ******* (equal no of * as no of characters) I am searching for a regular expression for python. Plz help. Any help will be appreciated Edit 1 : b = '*'*len(s) How can we do it in Django Template ...

Is there any filter in Django to display asterisk(*) instead of text

I am eager to know whether any filter is available for displaying all the text as * like this mytext = 'raja' {{ mytext|password }} should show **** How can we do this. plz help ...

Should I remove 'django.contrib.comments' from my installed apps when I modify it by subclassing?

I'm customizing django comments. According to the docs you'll need to add your customized app to INSTALLED_APPS in settings.py, and set COMMENTS_APP to your app name. INSTALLED_APPS = [ ... 'my_comment_app', ... ] COMMENTS_APP = 'my_comment_app' Should I also remove 'django.contrib.comments' from INSTALLED_APPS? ...

Distinct in many-to-many relation

class Order(models.Model): ... class OrderItem(models.Model) order = models.ForeignKey(Order) product = models.ForeignKey(Product) quantity = models.PositiveIntegerField() What I need to do is to get the Order(s) which has only one order item. How can I write it using the QuerySet objects (without writing SQL)? ...

Error in django unittest while loading a fixture

Hello all, I am making unittests for a django app. I need some data in the database for my tests so I am using a json fixture. I have two fixtures: for users and it works ok. for some webpages The fixture 2 cause the following error: Problem installing fixture 'C:\Users\luc\Dev\Hg\mnl-adminpub\website\fixtures\website-unittest.js...

How to perform this sql in django model?

SELECT *, SUM( cardtype.price - cardtype.cost ) AS profit FROM user LEFT OUTER JOIN card ON ( user.id = card.buyer_id ) LEFT OUTER JOIN cardtype ON ( card.cardtype_id = cardtype.id ) GROUP BY user.id ORDER BY profit DESC I tried this: User.objects.extra(select=dict(profit='SUM(cardtype.price-cardtype.cost)')).annotat...

custom html field in the django admin changelist_view

Hi Stackers' I'd like to some little customisation with the django admin -- particularly the changelist_view class FeatureAdmin(admin.ModelAdmin): list_display = ( 'content_object_change_url', 'content_object', 'content_type', 'active', 'ordering', 'is_published', ) list_edit...

problems rendering a template when using a decorator in Django

I have this URL in my project: url(r'^alerts/inbox/$', 'inbox', {'template_name': 'inbox.xhtml' }, name = 'inbox'), The inbox view is exactly this: @login_required() @ownsBid def inbox(request, template_name): return render_to_response(template_name, context_instance=RequestContext(request)) My ownsBid decorator is: def ownsBi...

Django ManyToMany relationship with abstract base - not possible, but is there a better way?

Given the following models: class BaseMachine(models.Model) fqdn = models.CharField(max_length=150) cpus = models.IntegerField() memory = models.IntegerField() class Meta: abstract = True class PhysicalMachine(BaseMachine) location = models.CharField(max_length=150) class VirtualMachine(BaseMachine) h...

Using Django-admin and a custom user-specific admin concurrently

I'm creating a Django powered website that will have numerous applications (Blog, Shop, Portfolio, etc.) that will be edited by 5 or so people, and I have so-far been designing everything with the Django admin in mind. I have come to realise that this is a very bad way of thinking -as really- the Django admin should really only be for ...

A m2m Django permission model

Users on a webapp I'm building have multiple objects that are "theirs" Let's pretend the object is called Toy. I want them to be able to set privacy options for their Toys so they can set the following visibility options: Friends of friends Friends Only allow a defined set of people Friends only, but deny a set of people (to keep it ...

Should Django's comments form know when user is logged in?

I'm using the standard Django comments app in my project. If the User is logged in then the comment form still shows fields for user_name and user_email. If anything is entered into those, the data is saved to the database with the comment, along with the user_id of the logged-in User. When the comment is displayed, the name of the logg...

Django/SQL: what's most efficient, more columns or more tables?

I have a MySQL database that I'm using with Django. One of my tables has around 60 columns. I'm wondering whether to split it into 5-6 smaller tables. This would make logical sense, since the columns split nicely into 5-6 logical groups. The downside would be that some of the Django pages would then require 5-6 row queries instead of 1....

Passing named arguments to functions in Django templates

I have in my Django controller a function that is called as follows: trip.driverTrip.filter(status='pending') What it will be the equivalent of calling this in a template. If I just want to call the filter function, the following will suffice: {{trip.driverTrip.filter}} But is there a way to pass it arguments ? ...