django

Can I create automatic login to django using secret in URL?

How can I let users log in to my Django site just by clicking a link? I send out weekly emails asking my users to update information, and I would love to let them log in just by clicking a link. I have seen this on other sites (like Squarespace), but has anyone done this with Django before? ...

How to get enumerated results from a query in Django?

I have a query that orders a table according to a particular field. The table is related to one competition, so knowing the position is important. As the table can grow to have a lot of rows, I have paginate it (25 rows per page) using generic views, but the problem I've got is to present the numbered position on the table. This informa...

Position charts on Django

I'm trying to do something similar to this, in Django. This is part of the page of Anna: Pos NickName Points --- --------- ------ 1 The best 1000 ... 35 Roger 550 36 Anna 545 37 Paul 540 It's a chart showing the scoring system, and it intends to show the first position, as well as the relat...

Will Python use all processors in thread mode?

While developing a Django app deployed on Apache mod_wsgi I found that in case of multithreading (Python threads; mod_wsgi processes=1 threads=8) Python won't use all available processors. With the multiprocessing approach (mod_wsgi processes=8 threads=1) all is fine and I can load my machine at full. So the question: is this Python beh...

How to handle crossdomain.xml in django?

I'm running an an ubuntu vm - django is running under apache2 behind nginx I need to setup crossdomain.xml - currently getting 'access denied' etc when trying to play flash movs whats the best way to set this up? ...

Display value of a django form field in a template?

I have a form with an email property. When using {{ form.email }} in case of some validation error, django still renders the previous value in the input tag's value attribute: <input type="text" id="id_email" maxlength="75" class="required" value="[email protected]" name="email"> I want to render the input tag myself (to add some javascr...

Passing arguments to the generic views Django queryset

I would like to make a queryset on a generic view in this way: category_info = { 'queryset' : ModelObject.objects.filter(category=category_id) } where the category_id will be stated on the URL (r'^category/(?P<category_id>\d+)$', 'object_list', category_info ) But I don't know how to take the data from the URL and pass it ...

passing arguments to a dynamic form in django

I have a Dynamic Form in forms. How can I pass a argument from my view when I instantiate my form. something like form = DynamicForm("some string argument") This is the form I have: class DynamicForm(Form): def __init__(self, *args, **kwargs): super(DynamicForm, self).__init__(*args, **kwargs) for item in range(5): ...

Use Python logging to determine where a method was called from

I'm trying to debug a Python Django app. I've got additional fields being added to a model. I've tracked this down to one method: django.db.models.options.add_field() The only place this method is called is: django.db.models.fields.init.contribute_to_class() def contribute_to_class(self, cls, name): self.set_attributes_from_name...

Serving static media during Django development: Why not MEDIA_ROOT?

I read this guide about serving static media with Django during development. I noticed that MEDIA_URL and MEDIA_ROOT were not used in this. Why? What's the difference? I tried doing it with MEDIA_URL and MEDIA_ROOT, and got weird results. ...

add float number in template (django)

Maybe i'm missing something but i'm looking to add a float number, something like this: {%floatnumber|add:3.4%} Filter add round my result so I don't want to write my filter, but if is the only way, i'll copy add filter Now i'm doing this: def addf(value, arg): """Adds the arg to the value.""" return float(value) + float(ar...

How to distuingish between Django's automatically created ManyToMany through-models and manually defined ones?

Hi. Say we have models from django.db import models class AutomaticModel(models.Model): others = models.ManyToManyField('OtherModel') class ManualModel(models.Model): others = models.ManyToManyField('OtherModel', through='ThroughModel') class OtherModel(models.Model): pass class ThroughModel(models.Model): pblm = mo...

simple auth system in django failing

I'm writing a simple auth system to login (and logout) users. The username is an email address, which looks up an email field. I'm using: user = User.objects.get(email__exact=email) # if user obj exists if user: # if authenticate if authenticate(user, email, password): # create session request.session['user'] = ...

Apache basic authentication on Django site

I'm trying to add basic Apache name/password authentication to a running Django site. I've following the example here. I've created an .htpasswd file and have the following in httpd.conf: WSGIScriptAlias / /home/ann/webapps/django/domesday.wsgi <Directory /home/ann/webapps/apache2> AuthType Basic AuthName "Authentication Required" Auth...

Dynamically update ModelForm’s Meta class model field

def SiteAdminForm(model_cls, *args, **kwargs): class MerchantAdminForm(forms.ModelForm): class Meta: exclude = ('external_links', 'published', 'logo','image_zip_file',) model = model_cls def __init__(self, *args, **kwargs): super(MerchantAdminForm, self).__init__(*args, **kwargs) ...

Why does Nose not see any of my environmental variables?

I'm just getting started using Nose and Nosetests and my tests are failing because Nose can't see the environmental variables. So far, the errors: AttributeError: 'Settings' object has no attribute 'DJANGO_SETTINGS_MODULE' I fixed this by exporting DJANGO_SETTINGS_MODULE from .bash_profile export DJANGO_SETTINGS_MODULE="settings" No...

Multiple django-apps on python path or in project

I have a decent sized django project and when I originally built it I kept all the apps in an apps folder under the project root. project/apps/articles, project/apps/video etc. After a while I decided to move to best practices and make them more reusable so I moved them into their own separate apps then symlink'd them to my python path....

Django settings.py and pyfacebook middleware don't allow multiple facebook applications in 1 project

I want to run multiple facebook applications from a Django project project\ settings.py fbapp1\ 'needs FACEBOOK_API_KEY=KEY1 fbapp2\ 'needs FACEBOOK_API_KEY=KEY2 For Facebook authentication and APIs to work pyfacebook middleware uses conf.settings to get the FACEBOOK_API_KEY for each request and adds a Facebook object to each re...

Can django_admin_log be monitored through Django's admin?

The table django_admin_log is useful to monitor the actions of users in the admin. Right now, I can achieve that by querying the database directly. Is there a built-in functionality where I can view the table django_admin_log through Django's admin for all users? ...

Django: Is there a safe and robust way to allow account-holders to have separate domains on your app?

If I want my account holders to be able to have their own sub-domains and even their own domains altogether. Using NGINX as my proxy server, should I create domains for each one in my NGINX conf and have my clients point their domains there or is there reasons why this would be bad? Also, if I do that, how can I pass account-specific (ac...