django

User-specific model in Django

I have a model containing items, which has many different fields. There is another model which assigns a set of this field to each user using a m2m-relation. I want to achieve, that in the end, every user has access to a defined set of fields of the item model, and he only sees these field in views, he can only edit these field etc. Is ...

django template change behaviour to silent_variable_failure = False

http://www.djangobook.com/en/beta/chapter10/ "Note that django.core.exceptions.ObjectDoesNotExist, which is the base class for all Django database API DoesNotExist exceptions, has silent_variable_failure = True. So if you’re using Django templates with Django model objects, any DoesNotExist exception will fail silently." Whilst I'm dev...

Django deploying as SaaS (basecamp style)

Hi Djangonauts, I am almost done developing a Django project (with a few pluggable apps). I want to offer this project as a SaaS (something like basecamp). i.e: project1.mysaas.com , project2.mysaas.com etc I seek your expertise in showing me the path. Ways I have thought of are: 1 use Sites to define site specific settings.py 2 a...

Django - Edit data in db

Hi to all! I have a question regarding editing/saving data in database using Django. I have template that show data from database. And after each record i have link that link you to edit page. But now is the question how to edit data in db without using admin panel? I run thought tutorial in djangobook but i didn't see how to achieve...

django Postgres IntegrityError

Can somebody please explain to me how to properly test Postgres DB errors, particularly IntegrityError. For example i have next test: class TestSlugs(TestCase): # This slug must be unique b = BookPublisher(slug=self.duplicate_slug) self.assertRaises(IntegrityError, b.save) #check if there's only one BookPublisher s...

[Python] ImportError: DLL load failed : - when trying to import psycopg2 library

>>> import psycopg2 Traceback (most recent call last): File "", line 1, in File "C:\Python26\lib\site-packages\psycopg2\__init__.py", line 60, in from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID ImportError: DLL load failed: The application has failed to start because its si de-by-side configuration is incorrect. P...

Mix of Inheritance + Inclusion tags

We know about "extend" inheritance tag and inclusion tags. What about the combination of it, like an asp.net grid templates. Like this: {% template %} {% content top %}some html{% endcontent %} {% content bottom %}some html{% endcontent %} {% endtemplate %} UPD: Is there such tags already developed? ...

Presentation template framework with pre-built login/session handling?

Just fishing for ideas here. Do any of the major template presentation frameworks (such as Smarty, Django) have prebuilt login/security handling? I want to save time on the security handling because it will consume a lot of time to worry about that. I want to build a site from ground up but I dont really want to go so far as starting ...

Django: many-to-many relations, and through

I want to store which user invited another user to a group... but django is telling me this is ambigous and against the rules (which makes sense). groups.group: Intermediary model Group_to_Member has more than one foreign key to User, which is ambiguous and is not permitted. So how do I do this correctly? Maybe a generic rel...

Admin interface editable Django app settings

Is there a good way provide user configurable app settings in Django admin? Basically I would like to have a nice forms where site owner can easily edit such one off information as his contact information, front page text content, etc. Sort of like a normal admin interface of a model, but limited to only one undeletable item in the mode...

Is this a bug in Django formset validation?

Manual example: http://docs.djangoproject.com/en/1.0/topics/forms/formsets/#formset-validation (I'm using Django 1.0.3 to run on Google App Engine) Code: from django import forms from django.forms.formsets import formset_factory class ArticleForm1(forms.Form): title = forms.CharField() pub_date = forms.DateField() class ArticleFo...

In Django how to show a list of objects by year

I have theses models: class Year(models.Model): name = models.CharField(max_length=15) date = models.DateField() class Period(models.Model): name = models.CharField(max_length=15) date = models.DateField() class Notice(models.Model): year = models.ForeignKey(Year) period = models.ForeignKey(Period, blank=True, ...

How do I get the default value for a field in a Django model?

I have a Django model with some fields that have default values specified. I am looking to grab the default value for one of these fields for us later on in my code. Is there an easy way to grab a particular field's default value from a model? ...

Programmatically saving image to Django ImageField

Ok, I've tried about near everything and I cannot get this to work. I have a Django model with an ImageField on it I have code that downloads an image via HTTP (tested and works) The image is saved directly into the 'upload_to' folder (the upload_to being the one that is set on the ImageField) All I need to do is associate the already ...

Using list_filter with Intermediary Models

We have three models, Artist: class Artist(models.Model): family_name = models.CharField(max_length=50) given_name = models.CharField(max_length=50) Group: class Group(models.Model): name = models.CharField(max_length=50) members = models.ManyToManyField(Artist, through='Membership') and Membership: class Membershi...

is there similar syntax to php's $$variable in python

is there similar syntax to php's $$variable in python? what I am actually trying is to load a model based on a value. for example, if the value is Song, I would like to import Song module. I know I can use if statements or lambada, but something similar to php's $$variable will be much convenient. what I am after is something similar t...

Models duplicating on save instead of updating

I'm trying to make a Django application to handle events. The view below handles the editing of already created events. @login_required def event_admin(request, event_id): event = get_object_or_404(Event, pk=event_id) if request.method == 'POST' and request.user == event.organiser: event_form = EventAdminForm(request.PO...

How to tame the location of third party contributions in Django

I have a django project which is laid out like this... myproject apps media templates django registration sorl typogrify I'd like to change it to this... myproject apps media templates site-deps django registration sorl typogrify When I attempt it the 'site-dependencies' all break. Is there a way to implement this structur...

How do I read CalDAV objects from Google using python/django?

I've looked at vObject, iCalendar and the official list of CalDAV libraries, including 3 in python. However, I can't find any code that can get me an event object from a given CalDAV (i.e. google, exchange, etc.) server using a username/password. Most of the django calendar related code uses native code libraries and not WebDAV. An idea...

Running a Python script outside of Django

I have a script which uses the Django ORM features, amongst other external libraries, that I want to run outside of Django (that is, executed from the command-line). Edit: At the moment, I can launch it by navigating to a URL... How do I setup the environment for this? ...