I'M using django south on a bigger project, the only thing I don't like about it, that you can't create schemamigrations for all of your apps at once (I have a lot of apps that inherit from the same abstract model, if I change that base model there are alot of apps to migrate) - thought you can actually migrate all of them at once (usin...
It seems that Django's object model filter method automatically uses the AND SQL keyword.
For example:
>>> Publisher.objects.filter(name__contains="press", country__contains="U.S.A"
will automatically translate into something like:
SELECT ...
FROM publisher
WHERE name LIKE '%press%'
AND country LIKE '%U.S.A.%'
However, I was won...
I'm using django-bookmarks for one of my projects and recently updated to Django 1.2.1. I noticed that the form submit does not validate since the update. Please note that I did confirm this is working with Django v1.1.1, so the new version and form field validation is different.
This is the model that forms.py is building off of:
cl...
Hi. I'm studying django. In my project I'm having trouble with making a query with django ORM:
SELECT MIN( id ) AS id, domain, COUNT( * ) AS cnt
FROM app_competition
WHERE word_id = 1545
GROUP BY domain
Help me please make this query
...
Hi,
I have django ModelForm for model with ManyToManyField. I want to change widget for this field toCheckboxSelectMultiple. Can I do this without overriding a field in a form definition?
I constantly use code similar to this:
class MyModel(ModelForm):
m2m_field = forms.ModelMultipleChoiceField(queryset = SomeModel.objects.all(),
...
Following the example of writing a custom django-admin command here, I've created the following custom command:
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
args = ''
help = 'Test command'
def handle(self, *args, **options):
self.stdout.write("Hello World!")
Surpri...
I have a form in my Django app (not in admin) that allows staff members to select a user from a dropdown.
forms.ModelChoiceField(queryset = User.objects.filter(is_staff=False), required = False)
The problem is that the dropdown shows users by usernames whereas I'd rather it show their full name from user.get_full_name() and use userna...
Background: Running a PostgreSQL database for a Django app (Django 1.1.1, Python2.4, psycopg2 and Postgres 8.1) I've restored the database from a SQL dump several times. Each time I do that and then try to add a new row, either shell, admin, or site front end, I get this error:
IntegrityError: duplicate key violates unique constraint "a...
I'm making the following request through command-line cURL:
curl -X POST http://localhost:8000/api/places/ -vvvv -d "place[name]=Starbucks"
However, when I try to access the parameters by calling
request.POST.getlist('place')
I get an empty array as a response. How can I access the sub-dictionary which I can then pass to the ORM?
...
I have a "Category" model, and a "Project" model, which contains a ForeignKey to "Category." So each Project can only belong to one Category.
I want to create a list that ends up looking like the following:
Category 1
Project 1
Project 2
Category 2
Project 3
Project 4
etc.
I think the following psuedocode will work:
<ul class="cate...
I'm trying to create form, for adding new friend/updating existing one. My first solution uses ModelForm, but data from updated form are not saved. Also problem is that my model has CharFields ('code', 'pid'), that I need to validate with regex through my form. If I exclude those fields in Meta, and add them to the FriendForm, when the f...
How do you deal with hierarchical URLs in Django? Any best practices for that?
Eg. If I would have an URL like /blog/category1/category2/myblogentry (using eg. django-mptt), would you do some checking before in urls.py or give the whole path to a view, let it check every part if it is a valid category etc?
Doesn't sound so tough, but ju...
In my project I have to add functionality for deleting friends from users list. When clicking on 'Delete friend' link, the following view is loaded (with the friends.id sent) :
def delete_friend(request, id):
friend = get_object_or_404(Friend, id=id)
friend.delete()
return HttpResponseRedirect(reverse('user_profile',))
...
I'm looking to send an SMS with the Twilio api, but I'm getting the following error:
"unknown url type: https"
I've recompiled python with Openssl, so my code runs fine from the python interpretor, but whenever I try to run it in one of my django views I get this error. Here is my code from my view:
def send_sms(request):
recipient ...
Hi all,
I know this is probably a question that is asked a ton on here but I haven't been able to find exactly what I'm looking for. I'm a JAVA developer that is learning Python and Django and I'm looking for a good development environment. I would like to be able to edit python code, css, html and javascript all in the same editor i...
I want to check in django if a URL exists and if it does I want to show something on screen.
e.g:
if URL_THAT_POINTS_TO_SOME_PDF exists
SHOW_SOMETHING
...
Hello world!
I'm creating a django app that creates a calendar and a google docs folder for the users, and uses the API to insert events and add documents. A few months ago, it worked nice enough; now I'm doing a major refactoring of my code and, while testing the aforementioned components, I discovered that they don't work anymore! Whe...
hello,
I'm making a little vote system, in wich one can vote an answer, but only once. I have not created a form for the vote, i am creating the vote when someone submits it (accesses a link)
How can i make, in my situation, for a person to be able to vote only once?
It would be better if i would make a form instead?
my code:
def voteup...
Is there any way in django to store cookies which is independent to browser ?
is there any technique just like what flash SharedObject does ..?
...
Hi
I have a simple article model with pub_date field and a unpublish_date field.
Is there any way to automagically set my is_published field to False when the unpublish_date is in the past?
class Article(models.Model):
title = models.CharField(max_length=500)
post = models.TextField(blank=True, null=True,)
pub_date = mode...