Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lagg
Nov 10, 2005

The wilder the hat, the wilder the man.
I'm trying to make a "shopping cart" that will list out several objects that have been saved in session.

So far I've been able to use form.Form, formset and formset_factory to output a list of forms.

I'm looping through my session to make up "initial_data" for the formset.

I have "custom made" the form because I don't want the widgets that a model form would output, and I only need 1 of the fields from the model

(quantity = forms.IntegerField(required = True) is all I need)

My issue is that I don't know of anyway of dynamically setting the label for one of the fields, and I'd like to also output of a model's method in each form.

I could do a integerField for the method output, but I'd have to set it as read-only and the widget just looks wrong.

Ideally I'd like something like this for the inital_data

{'quantity': {'label='object.name', 'value'='2'},
'cost': object.cost()}

So that it outputs like this
(qty is the only field I want editable)

Mac & Cheese Qty:[ 2 ] $5.00
Pickles Qty:[ 4 ] $12.00
...etc

Right now all I get is

Quantity [ 2 ]
Quantity [ 4 ]

I've thought about just looping through formset and each form and doing the form 'by hand' and doing a dict of labels and costs that would correspond to each quantity field, but I can't wrap my head around how that would line up based on how formset names the forms.

I've also thought about doing "my own" formset by just making a dict considing of a form, label, and cost, but I can't wrap my head around how I would validate those forms on POST.

Any ideas or advice is much appreciated, and apologies if this has been asked before in this thread


:pseudo: BREAKING NEWS: :eng99:

I solved my own problem.

Using range(len(formset)) I looped through each form in the formset and made a list of dictionaries that were made up of formset[i] and session['objects][i] (they will match up because I looped through session['objects'] to create the 'initial_data' for the formset_factory)

I passed this list of dicts to the template.

Then, in the template instead of looping through {{form}} or {{formset}} I looped through the list of dictionaries, piecing together the form like {{formset}} generates.

Anytime I needed something like "id_form-X-field" or 'label for=id_form-X-field'(where x is suppose to be the form #) I used "forloop.counter0" (which I just learned about :eng99:).

It wasn't too easy, but wasn't too hard. I just kept getting lead down the wrong paths of "custom field" and "custom widget"

:guitar:

Lagg fucked around with this message at 20:53 on May 16, 2011

Adbot
ADBOT LOVES YOU

ufarn
May 30, 2009
I am trying to do a runserver on these Django files from the book Pratical Django to see if it's compatible with 1.3.0, which I'm not so sure about. When I try to run it, I get this:

code:
>python manage.py runserver

Error: No module named coltrane
Can someone help a goon out? I don't know if the problem is because of incompatibility, or whether I just missed something.

wheezy360
Mar 8, 2006
It means you don't have the django-coltrane app installed/on your PYTHONPATH, but you have it in INSTALLED_APPS in your settings.py file, so Django can't find it.

ufarn
May 30, 2009

wheezy360 posted:

It means you don't have the django-coltrane app installed/on your PYTHONPATH, but you have it in INSTALLED_APPS in your settings.py file, so Django can't find it.
What exactly is PYTHONPATH, and where can I find it?

epswing
Nov 4, 2003

Soiled Meat
This http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ was published in 2006. Is a class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) still the best way to add fields to the User model?

Marvel
Jun 9, 2010

epswing posted:

This http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ was published in 2006. Is a class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) still the best way to add fields to the User model?

The canonical way these days seems to be using django-profiles (written by the author of the blog post you linked)

Marvel
Jun 9, 2010

ufarn posted:

What exactly is PYTHONPATH, and where can I find it?

God I hate PYTHONPATH

It's an environment variable that you can set. so

pre:
PYTHONPATH=/home/shithead/some_python_shit/ python
will include all the python files in /home/shithead/some_python_shit

To see what is currently in your path, do this

pre:
python
>>> import sys
>>> print sys.path
To add to your path in your code, you can do this:

pre:
python
>>> import sys
>>> sys.path.append('/some/path')
actually gently caress it just read this http://www.stereoplex.com/blog/understanding-imports-and-pythonpath

MonkeyMaker
May 22, 2006

What's your poison, sir?
My friend ag3ntorang3 and I just launched djangopeople.me which is basically a replacement for djangopeople.net. Anyway, check out, let us know what you think, poo poo like that.

Captain Capacitor
Jan 21, 2008

The code you say?

MonkeyMaker posted:

My friend ag3ntorang3 and I just launched djangopeople.me which is basically a replacement for djangopeople.net. Anyway, check out, let us know what you think, poo poo like that.

The location-awareness is nice, but a little too specific. Would be nice to narrow down by City or something like that.

MonkeyMaker
May 22, 2006

What's your poison, sir?

Captain Capacitor posted:

The location-awareness is nice, but a little too specific. Would be nice to narrow down by City or something like that.

You can zoom in on the map when you set your location a LOT further than anyone else can when they view your profile, so they won't be camping outside your door or anything.

We'll probably introduce some anonymizing abilities, too, to make it friendlier to you paranoid types :tinfoil:

Belgarath
Feb 21, 2003
Anyone have any ideas about how I could possibly go about converting a site from Drupal to Django-cms?

quaunaut
Sep 15, 2007

WHOOSH
Okay! I posted about this problem in the Python thread but it turns out it's a problem purely with Django. So far, as nice as Django is, I'm finding the community(at least in IRC) is full of dicks. This is probably a really easy problem to get over, but I can't figure it out all the same.

I'm getting a constant error whenever I try to log in with any user, 'User' object has no attribute 'backend'. Or, you can replace 'User' with 'AnonymousUser'. This depends on whether I've logged into the admin panel or not.

Regardless- for some reason, my Authenticate calls are going through fine without error(as far as I can tell), but no Backend is being set... ever. What could possibly cause this?

As for showing off code, here you go:

code:
def twitter_authenticated(request):
    # Step 1. Use the request token in the session to build a new client.
    token = oauth.Token(request.session['request_token']['oauth_token'],
                        request.session['request_token']['oauth_token_secret'])
    client = oauth.Client(consumer, token)

    # Step 2. Request the authorized access token from Twitter.
    resp, content = client.request(access_token_url, "GET")
    if resp['status'] != '200':
        print content
        raise Exception("Invalid response from Twitter.")

    """
    This is what you'll get back from Twitter. Note that it includes the
    user's user_id and screen_name.
    {
        'oauth_token_secret': 'IcJXPiJh8be3BjDWW50uCY31chyhsMHEhqJVsphC3M',
        'user_id': '120889797',
        'oauth_token': '120889797-H5zNnM3qE0iFoTTpNEHIz3noL9FKzXiOxwtnyVOD',
        'screen_name': 'heyismysiteup'
    }
    """

    access_token = dict(cgi.parse_qsl(content))

    # Step 3. Lookup the user or create them if they don't exist.
    try:
        user = User.objects.get(username=access_token['screen_name'])
    except User.DoesNotExist:
        # When creating the user I just use their [email]screen_name@twitter.com[/email]
        # for their email and the oauth_token_secret for their password.
        # These two things will likely never be used. Alternatively, you
        # can prompt them for their email here. Either way, the password
        # should never be used.
        user = User.objects.create_user(access_token['screen_name'], '%s@twitter.com' % access_token['screen_name'], access_token['oauth_token_secret'])

        # Save our permanent token and secret for later.
        profile = Profile()
        profile.user = user
        profile.oauth_token = access_token['oauth_token']
        profile.oauth_secret = access_token['oauth_token_secret']
        profile.save()

    # Authenticate the user and log them in using Django's pre-built
    # functions for these things.

    user = authenticate(username=access_token['screen_name'], password=access_token['oauth_token_secret'])
    login(request, user)

    return HttpResponseRedirect('/')
Another funny thing- I get the same exact problem when I just fake the auth poo poo, and put in just the commands in the auth tutorial on Django's website. So no idea what relevance that has.

Edit: I should note, a lot of what you're seeing there is a part of Python-Oauth2. In fact, nearly this entire piece is a straight lift from how they're supposed to do the Django implementation, as detailed on the site there.

quaunaut fucked around with this message at 16:13 on Jun 6, 2011

Profane Obituary!
May 19, 2009

This Motherfucker is Dead
What exactly are you trying to do? Are you trying to let people authenticate using Twitter instead of a built in username/password?

Profane Obituary! fucked around with this message at 14:13 on Jun 7, 2011

quaunaut
Sep 15, 2007

WHOOSH

Profane Obituary! posted:

What exactly are you trying to do? Are you trying to let people authenticate using Twitter instead of a built in username/password?

Yep.

MonkeyMaker
May 22, 2006

What's your poison, sir?
Best way to do Twitter auth that I've found yet: django-social-auth. It's what we used on djangopeople.me and it's amazingly simple.

quaunaut
Sep 15, 2007

WHOOSH

MonkeyMaker posted:

Best way to do Twitter auth that I've found yet: django-social-auth. It's what we used on djangopeople.me and it's amazingly simple.

I don't think I'd be able to use any existing python twitter libraries, would I? At least, not in that implementation?

Edit: lol. It's built off of the same library as what I'm working out of for oauth. So I bet I could easily use this for oauth then just flip it over to the twitter API when it's time to do poo poo!

gently caress yeah. Gonna do more research here.

quaunaut fucked around with this message at 01:28 on Jun 8, 2011

MonkeyMaker
May 22, 2006

What's your poison, sir?

quaunaut posted:

I don't think I'd be able to use any existing python twitter libraries, would I? At least, not in that implementation?

Edit: lol. It's built off of the same library as what I'm working out of for oauth. So I bet I could easily use this for oauth then just flip it over to the twitter API when it's time to do poo poo!

gently caress yeah. Gonna do more research here.

Existing libraries for what? Sending tweets? I used it with Tweepy with no problems. It's just for creating/validating the local accounts based on Twitter (Facebook, OAuth, etc) auth.

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah
Help me Django thread!

I have a work order database. I need to find the average time it takes for a staff member to close their tickets on a weekly/monthly/yearly basis (relative to "now").

As it stands now, there's two columns in my database for storing this information: the ticket creation date and the ticket closing date. How would I go about doing something like this?

Yay
Aug 4, 2007

root beer posted:

Help me Django thread!

I have a work order database. I need to find the average time it takes for a staff member to close their tickets on a weekly/monthly/yearly basis (relative to "now").

As it stands now, there's two columns in my database for storing this information: the ticket creation date and the ticket closing date. How would I go about doing something like this?

Off the top of my head, something like:
code:
# get everything that's finished
qs = YourObject.objects.filter(end_date__isnull=False)
# compile a list of timedeltas into calculated seconds
time_spent = []
for your_object in qs:
    time_spent.append((your_object.end_date - your_object.start_date).seconds)
# calculate mean.
mean = sum(time_spent, 0.0) / len(time_spent)
ought to work. Should be valid code, but treat it as pseudo-code; that is, it may not be perfect ;) Note that to keep it readable I avoided using a list comprehension, but that ought to work too. Most of the work is done for you in subtracting two datetimes into a timedelta, tbh.

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah

Yay posted:

Off the top of my head, something like:
code:
# get everything that's finished
qs = YourObject.objects.filter(end_date__isnull=False)
# compile a list of timedeltas into calculated seconds
time_spent = []
for your_object in qs:
    time_spent.append((your_object.end_date - your_object.start_date).seconds)
# calculate mean.
mean = sum(time_spent, 0.0) / len(time_spent)
ought to work. Should be valid code, but treat it as pseudo-code; that is, it may not be perfect ;) Note that to keep it readable I avoided using a list comprehension, but that ought to work too. Most of the work is done for you in subtracting two datetimes into a timedelta, tbh.
Excellent, another case wherein Python takes something that seems complex and makes it stupidly simple.

Thanks a bunch.

Hughlander
May 11, 2005

Anyone remember a blog post in the last month or so about an easy skeleton for starting up a new Django project?

I'm trying to document the creation of a new site basically from easy_install virtualenv on out, and there was some blog post that covered a lot of it, I remember specifically that it mentioned pip's requirements.txt and creating the new virtualenv, but some google searches for it haven't turned it up.

EDIT: Found it, it was http://www.mahdiyusuf.com/post/5282169518/beginners-guide-easy-install-pip-and-virtualenv

Hughlander fucked around with this message at 21:02 on Jun 11, 2011

Lamacq
Jun 15, 2001

Breezeblock RIP

Hughlander posted:

Anyone remember a blog post in the last month or so about an easy skeleton for starting up a new Django project?

I'm trying to document the creation of a new site basically from easy_install virtualenv on out, and there was some blog post that covered a lot of it, I remember specifically that it mentioned pip's requirements.txt and creating the new virtualenv, but some google searches for it haven't turned it up.

EDIT: Found it, it was http://www.mahdiyusuf.com/post/5282169518/beginners-guide-easy-install-pip-and-virtualenv

FWIW here's my django app skeleton: https://github.com/technivore/django-app-skeleton. It's forked from Corey Oordt's original version with some minor changes that fit my style. I really like it because it fits the documentation-driven development method I've been using with pretty good success lately. But long story short, it will create the virtualenv for you; I think you might have to have virtualenvwrapper installed too though.

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah
Again, time to call upon the Django thread to save my job:

In my work order system, my boss has asked for a way to be able to view a monthly breakdown of how many orders were created per month for any given year. I know that QuerySets have the ability to do things like
pre:
Order.objects.filter(created_on__year=2010)
.

I have a couple ideas how to do it, but I'm betting there's some method for doing so hiding away that I have no clue about that'd take hours of coding and condense it into a couple lines.

205b
Mar 25, 2007

root beer posted:

Again, time to call upon the Django thread to save my job:

In my work order system, my boss has asked for a way to be able to view a monthly breakdown of how many orders were created per month for any given year. I know that QuerySets have the ability to do things like .

I have a couple ideas how to do it, but I'm betting there's some method for doing so hiding away that I have no clue about that'd take hours of coding and condense it into a couple lines.

You've got the QuerySet for a given year, and you can filter it further to get QuerySets for each month, or use count() if you just need the number of orders.

code:
# note that I'm new to Django and this may or may not actually work
q = Order.objects.filter(created_on__year=2010)
jan = q.filter(created_on__month=1)
feb = q.filter(created_on__month=2).count()
I'm not sure how the caching is done but I think you can hit the database once for the first queryset and then use cached data for subsequent filtering.

e: I think you just solved one of my own Django problems by having me reread the official documentation :v:

205b fucked around with this message at 08:23 on Jun 14, 2011

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

root beer posted:

Excellent, another case wherein Python takes something that seems complex and makes it stupidly simple.

Thanks a bunch.
That's just regular simple. Stupidly simple is, as Yay said, turning that loop into a list comprehension:

code:
time_spent = [(o.end_date - o.start_date).seconds for o in qs]
You're still expending a lot of energy to create those lists, though. You can use a generator expression to dynamically generate the sum off the recordset, skipping the list entirely (only do this if you don't need the results again later):

code:
mean = sum(o.end_time - o.start_time for o in qs) / len(qs)

Vulture Culture fucked around with this message at 19:07 on Jun 14, 2011

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah

ninepints posted:

You've got the QuerySet for a given year, and you can filter it further to get QuerySets for each month, or use count() if you just need the number of orders.

code:
# note that I'm new to Django and this may or may not actually work
q = Order.objects.filter(created_on__year=2010)
jan = q.filter(created_on__month=1)
feb = q.filter(created_on__month=2).count()
I'm not sure how the caching is done but I think you can hit the database once for the first queryset and then use cached data for subsequent filtering.

e: I think you just solved one of my own Django problems by having me reread the official documentation
Thanks, that's what I figured I'd end up having to do. I'm just gonna have to try it and see for myself how many queries it runs.


Misogynist posted:

That's just regular simple. Stupidly simple is, as Yay said, turning that loop into a list comprehension:

code:
time_spent = [(o.end_date - o.start_date).seconds for o in qs]
You're still expending a lot of energy to create those lists, though. You can use a generator expression to dynamically generate the sum off the recordset, skipping the list entirely (only do this if you don't need the results again later):

code:
mean = sum(o.end_time - o.start_time for o in qs) / len(qs)
This is great and really sped things up.

I love Django. I've learned so much about so many different of facets of programming because of it.

Captain Capacitor
Jan 21, 2008

The code you say?

root beer posted:

Thanks, that's what I figured I'd end up having to do. I'm just gonna have to try it and see for myself how many queries it runs.

This is great and really sped things up.

I love Django. I've learned so much about so many different of facets of programming because of it.


Simply because I love sharing random tidbits of Django goodness, if your Work order system needs any sort of async work done, look at Celery. I'm using it in the monitoring and stats system I'm writing and it integrates so very nicely.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Captain Capacitor posted:

Simply because I love sharing random tidbits of Django goodness, if your Work order system needs any sort of async work done, look at Celery. I'm using it in the monitoring and stats system I'm writing and it integrates so very nicely.
I think we're writing the same monitoring system.

Captain Capacitor
Jan 21, 2008

The code you say?

Misogynist posted:

I think we're writing the same monitoring system.
Edit: Way to edit your post and confuse people. I'm using Carbon and Whisper as a backend/replacement for RRD.

A few factors:

Control of repetitive tasks from a web frontend (allowing users to control how frequently stats are collected)
Task chaining
AMQP Integration
Ease of distribution for multiple workers (Or in my case, EC2 instances)

bitprophet
Jul 22, 2004
Taco Defender

Captain Capacitor posted:

I'm using Carbon and Whisper

:hfive:

I'm currently experimenting with collectd + Carbon/Whisper/Graphite (+ Nagios) for a monitoring stack. It's pretty nice so far.

Are you using Graphite at all or just the Carbon/Whisper components? If the latter, curious why.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Captain Capacitor posted:

Edit: Way to edit your post and confuse people.
Heh, sorry, I decided I didn't want to ask that question anymore.

Captain Capacitor posted:

I'm using Carbon and Whisper as a backend/replacement for RRD.

A few factors:

Control of repetitive tasks from a web frontend (allowing users to control how frequently stats are collected)
Task chaining
AMQP Integration
Ease of distribution for multiple workers (Or in my case, EC2 instances)
I looked at Whisper, but I opted instead for Mongo with capped collections. I like the idea of being able to easily extend the schema to support Holt-Winters intermediate values and other statistical data. Plus, the majority of the core app is asynchronous (Twisted) and txmongo fit the bill much more nicely than ferrying the Whisper stuff into a thread on the side.

I run into the same trap I always run into -- this thing will be nice as soon as I have more than design docs and ugly prototypes that don't do anything. I suck at the long tail.

Captain Capacitor
Jan 21, 2008

The code you say?

bitprophet posted:

:hfive:

I'm currently experimenting with collectd + Carbon/Whisper/Graphite (+ Nagios) for a monitoring stack. It's pretty nice so far.

Are you using Graphite at all or just the Carbon/Whisper components? If the latter, curious why.

As much as I love ExtJS, I'm not a big fan of how Graphite is coupled with everything. I love the Dashboard and the pseudo command line, but I find it just mashed together with Django. I want the nice parsing, but want to couple it with Django my own way. Plus PyCairo is a pain in the rear end to install. I've actually submitted a proposal to rewrite the API using REST or SimpleAPI.

Misogynist posted:


I looked at Whisper, but I opted instead for Mongo with capped collections. I like the idea of being able to easily extend the schema to support Holt-Winters intermediate values and other statistical data. Plus, the majority of the core app is asynchronous (Twisted) and txmongo fit the bill much more nicely than ferrying the Whisper stuff into a thread on the side.

I run into the same trap I always run into -- this thing will be nice as soon as I have more than design docs and ugly prototypes that don't do anything. I suck at the long tail.

That's pretty awesome. We needed something with some real flexibility. Our software (running on EC2 to scale) pushes stats to AMQP, which Carbon pulls from. We needed to be able to just to toss new metrics at our monitor as instances go up and down. So I'm writing a frontend for it all, tearing the guts out of Graphite and using Highcharts.

duck monster
Dec 15, 2004

I'm having a pretty loving wierd problem thats got me mystified.

Heres some registration code;-

code:
@transaction.commit_on_success
def ajaxregister1(request):
    #If this is a submitted form do this
    if request.method == 'POST':
        #Get the data.
        form = AjaxUserForm(request.POST)

        #Examine the data for validity 
        if form.is_valid():
            #
            # ITS ALL GOOD
            #
            #### @TODO: Make sure the username isn't taken.
            #
            #SAVE USER
            passw = makeCode()
            user = User.objects.create_user(username=request.POST['username'],email=request.POST['username'],password=passw)
            user.is_active=False
            user.save()
            #SAVE ACCOUNT CARD
            account = Account(user=user,companyname = request.POST['companyname'])
            account.signupCode = makeCode()
            account.save()
With an empty database, I get;-

code:
IntegrityError at /endpoint/register

duplicate key value violates unique constraint "auth_user_username_key"
DETAIL:  Key (username)=(don.o@mufqweqweuck.com) already exists.
When I trace the database, it seems to be running the create user query twice somehow (which then both rollback so nothing actually hits the disk in postgres). But when I remove the .save(), it does it not-at-all.

I'm loving mystified by this.

duck monster
Dec 15, 2004

Ended up solving this. Turns out the auth_users table was completely busted and not generating and emitting id field sequences. So when it would queue up a table write in the create_user, pgsql was returning a null for the id number.

Consequently when you go to save() it, django goes "Ok, this hasn't been written to the db yet" and attempts an insert and the whole thing explodes in a ball of flames, rolling back the previous insert and crashing the app.

That was a oval office to debug. Still not a fan of postgres folks.

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah
Back again! Hopefully this'll be my last time, as email handling is the last feature of this system I have to implement... anyway, my problem.

I have this code for sending an email to a work order's author and all assignees:

code:
from django.contrib.comments.signals import comment_was_posted
from django.db.models.signals import post_save
from django.core.mail import EmailMessage
from django.template.loader import render_to_string
from django.contrib.auth.models import User


def comment_notification(sender, **kwargs):
	comment = kwargs['comment']
	subject = '[Order #%s] Response from %s' %(comment.content_object.id, comment.name)
	assignees = [u.email for u in comment.content_object.assigned_to.distinct()]
	assignees.append(comment.content_object.author.email)
	message = render_to_string('orders/email_template.html', { 
		'user'    : User.objects.get(username=comment.user_name).get_full_name(),
		'comment' : comment.comment,
		'email'   : comment.email,
		'order'   : comment.content_object,
		'btntext' : 'Response',
		'url'     : 'http://workorders.psd401.net/view/%s/?c=%s#c%s' \ 
                             %(comment.content_object.pk, comment.id, comment.id)
	})

	msg = EmailMessage(subject, message, 'orders@psd401.net', assignees)
	msg.content_subtype = "html"
	msg.send()
comment_was_posted.connect(comment_notification)
This works great, except for the part where the author and all assignees receive the email twice... but if the author is also assigned to the order, it still sends 2 emails, instead of 4 as I'd expect.

What the gently caress?

EDIT: I had it email me the assignees list and each email address is only listed once.

DICTATOR OF FUNK fucked around with this message at 19:41 on Jun 21, 2011

Yay
Aug 4, 2007

root beer posted:

This works great, except for the part where the author and all assignees receive the email twice... but if the author is also assigned to the order, it still sends 2 emails, instead of 4 as I'd expect.

What the gently caress?

EDIT: I had it email me the assignees list and each email address is only listed once.
Likely this is because you've not set the dispatch_uid on the signal connector. See the outdated (but still largely correct) wiki on the subject, and the actual docs

(edit: also; the use of .distinct() may not do what you expect it to do, as its not directly analogous to most people's experience with DISTINCT in SQL. YMMV.)

Yay fucked around with this message at 20:26 on Jun 21, 2011

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah

Yay posted:

Likely this is because you've not set the dispatch_uid on the signal connector. See the outdated (but still largely correct) wiki on the subject, and the actual docs

(edit: also; the use of .distinct() may not do what you expect it to do, as its not directly analogous to most people's experience with DISTINCT in SQL. YMMV.)
Perfect! Thanks a bunch.

If I could find a way to donate to the Django thread I would :3:

MonkeyMaker
May 22, 2006

What's your poison, sir?
Just a quick reminder to everyone that DjangoCon US is coming up soon (Sept 6-8) and early bird pricing ends on July 1. Also, if you want to submit a paper for a talk, that deadline is July 5. All the details are on http://djangocon.us.

Hughlander
May 11, 2005

I can't believe I can't find a simple app/widget that adds jquery autocomplete searching to django. I have a model with 2 M2Ms fields, and I want to have a non-admin page with a search box to search a field in the model, or a field in the 2 M2Ms and let me go to a new page with the details.

Every AJAX search type thing I've looked into is either admin only, based on a 5 year old jquery where the syntax has changed, or just didn't work when I tried it.

I know it's popular to bash web2py, but at least there that poo poo was literally a one liner.

Adbot
ADBOT LOVES YOU

Profane Obituary!
May 19, 2009

This Motherfucker is Dead
I've never used it but have you looked at https://github.com/jeffkistler/django-fancy-autocomplete ?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply