I have a model:
class MyModel(models.Model):
a = models.IntegerField()
b = models.IntegerField()
c = models.IntegerField()
Now, I need something like unique_together(a,b, max_occurences=3) constraint to be added to the above model (so that there can be up to 3 values of c for each pair of (a,b), and ideally those 3 val...
Heya!
I have three models:
Variable, which has Group as a foreign key
Group, which has Set as a foreign key
Set
I want to create a form that lets user create a new Set based on existing Set. Only things that user is able to modify are the Set name and Variable values.
This has given me an idea of using inlineformset_factory to acce...
I am currently trying out Haystack for our django based forum site. I was trying to use the simple search engine option but i get an error telling me it is not available. the haystack documentation says it is still an option and I cannot find anything about why it would not be an option anymore. Anyone have an knowledge on this? I am...
I would like to implement a decorator that provides per-request caching to any method, not just views. Here is an example use case.
I have a custom tag that determines if
a record in a long list of records is
a "favorite". In order to check if an
item is a favorite, you have to query
the database. Ideally, you would
perform...
I need some help (sorry for my poor english).
I 'm trying to get all photos from each album. I don't know how to make the query.
I need this data (and order the photos by atribute "order" it will fantastic).
House1-title
photo1: descritpion
photo2: descritpion
photo3: descritpion
House2-title
photo1: descritpion
photo2: descritpi...
Hi,
I am about to choose hosting provider for my Django project. I took a look on a linode
and it looks very promissing. It looks like very elastic solution but in my case this might be a disadvnatage since I'm not so experienced in servers configuration (alternative provider for me has great tools to quickly do the job, but linode has ...
Hi, I have a model like so:
class Activity(models.Model):
title = models.CharField(max_length=200)
summary = models.TextField(null=True, blank=True)
tasks = models.ManyToManyField('self', symmetrical=False, null=True, blank=True)
It works like this, an activity can be linked to itself and the parent activity is call...
I am using Twitter OAuth to login users. The login takes users to Twitter and upon successful OAuth returns them to a specified url. From this url I would like to redirect users back to the page they were on before logging in.
What is a good way to do this?
...
def __number():
# This line returns the number of the latest created object
# as a "Factura" object in format "n/year"
last = Factura.objects.filter(f_type__exact=False).latest('number')
# We convert it into a string and split it to get only the first number
spl = str(last).split('/')[0]
# Convert it into intege...
I recently upgraded to Django 1.2.1 because I was specifically interested in the ability to have basic many-to-many inline fields. When using the admin like so:
Initial models:
class Ingredient(models.Model):
name = models.TextField()
class Recipe(models.Model):
ingredients = models.ManyToManyField(Ingredient)
Initial admin...
Imagine you have a web application written in Django and Python 2.65, and MySQL 5.1 is your database of choice.
Now, imagine you will need to scale your app to handle searching 100's of thousands of document and potentially 100's of thousands of users will be using it.
Reality: Haystack 1.0 with PySolr and Solr 1.4.0 is proving slow i...
hello,
I'm making a simple vote class, where a user can vote up or vote down an answer. I don't want this function to return anything,as the vote for every user is created when he votes.
The problem is that my redirection, or empty return gives me an error like: The page isn't redirecting properly from browser.
My code:
def vote_answer...
I have requirement like this:
On one server(linux) I need to run 2 instances of the same Django project (the same name, different versions). I've noticed that there is some conflict with settings module (both projects use the same file, which of course is wrong).
Do you have some pointers how to solve this problem?
...
Here's my problem. I have a mac with 2.5 installed & was using django 1.1 with it. I had no problems until I decided to upgrade python & django. I uninstalled django from my mac as per the djangoproject.com website recommends. I left python 2.5 on my mac as not to interfere with pre-installed mac programs. I put python 2.6 & 3.1 on my ma...
i have a LogEntry in django admin for superadministrator users, but, now i need a LogEntry for the other "staff" users, it's this possible?
Thanks folks!
...
Hello, I'm trying to create a custom field which would automatically add COLLATE information into the WHERE part of SQL query:
class IgnoreDiacriticsField(models.TextField):
def get_prep_lookup(self, lookup_type, value):
if lookup_type == 'exact':
return ' "' + self.get_prep_value(value) + '" COLLATE utf8_genera...
Let's say I have a form for adding/editing products (with field 'user' being a foreign key to my User) triggered from two separate view functions - add/edit :
def product_add(request):
userprofile = UserProfile.objects.get(user=request.user)
if request.method == 'POST':
form = ProductAddForm(request.POST, request.FILES,)...
I have a Django model that defines a TimeSlot. Each TimeSlot can hold a certain number of users (TimeSlot.spots). Each TimeSlot also has a certain number of users already held in it (a many to many field, TimeSlot.participants.
When I pass to the template that displays the available TimeSlots to the user, I annotate with TimeSlot.objec...
Hi All,
I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need.
Every time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the templa...
I have a django app, a forum app, that has templates with it. In those templates, there are urls that point to parts of the app. For instance the thread_list template has links to each thread like so:
{% for thread in threads %}
<a href="{% url forum_thread thread %}">{{thread.title}}</a>
{% endfor %}
The thing is, I don't really ...