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
king_kilr
May 25, 2007
fabric!

Adbot
ADBOT LOVES YOU

king_kilr
May 25, 2007

Yay posted:

We're ghetto fabulous, and use bash/svn export/rsync. I tried showing my boss Fabric, and he didn't seem interested ("What does it get us that bash doesn't?" - I've not used Fabric, so couldn't easily answer).

It gets you the mantras of deployment:

Repeatability
Maintainability
and Anyone on the planet would actually want to work with this-ability

king_kilr
May 25, 2007
code:
from appname.models import Model

king_kilr
May 25, 2007
Take a look at how FilePathField is implemented (http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/__init__.py#L817), now copy that for your logic.

king_kilr
May 25, 2007
Those 2 are equivilant in every way. You can't select_related a many to many (or any multivalued relationship).

king_kilr
May 25, 2007

Hanpan posted:

Ahh yes, I forgot about all that crazy salting.

Another question which came up today; I have a Media Manager app which I am attaching media to 'content' using the following table:

code:
class MediaAttachment(models.Model):
	media = models.ForeignKey(Media, related_name='attachment')
	content_type = models.ForeignKey(ContentType)
	object_id = models.PositiveIntegerField(db_index=True)
	object = generic.GenericForeignKey('content_type', 'object_id')
It works great, I can attach a Media object to my Entry objects just fine. The problem I have noticed is that when I delete an Entry object with attached Media, it doesn't delete the record in the MediaAttachment table. I'm ending up with a lot of redundant data in my MediaAttachment table :smith:

I want to keep the Entry model as abstract as possible, so overwriting the delete method to remove any media attachments seems a if a lame solution. Does anyone have any bright ideas as to how I could remove those redundant records when an Entry object is deleted?

If you put a GenericRelation on the Entry object then it will get deleted automatically: http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#reverse-generic-relations

king_kilr
May 25, 2007
If you think there's a problem with the docs, please please please file bugs on them, including just needing more details.

king_kilr
May 25, 2007

Captain Capacitor posted:

Never worked for Twisted :crossarms:

I love the framework, I really do. But when your documentation says one thing, your Epydoc says another and the code does something else entirely, it's a problem.

Yes it is. We take our documentation seriously.

king_kilr
May 25, 2007
That stuff isn't called by clean, it's called by full_clean (or maybe _full_clean).

king_kilr
May 25, 2007
Wouldn't touch it. Just use mod_wsgi or gunicorn behind nginx and be happy.

ps: 1.3 is out

king_kilr
May 25, 2007
Putting MySQL in the working category, that's cute. Just try: referential integrity at the same time as full text search, actually useful GIS queries, deferred constraints, optimizing queries using IN, the list goes on...

The error you're seeing is because you got an error in your transaction and ignored it, once a transaction enters an error state it must be rolled back.

king_kilr
May 25, 2007

Yay posted:

Additional note: calling form.save() should do the work of Order.objects.create for you. (Aside: what's wrong with creating instances of Order()? I've never encountered anything that said that was bad, nor have I had any problems with it)

code:
if form.is_valid()
    order = form.save(commit=False)
    order.authors.add(request.user)
    order.save()
    return redirect(order)

You probably need `order.save_m2m()` as well.

Adbot
ADBOT LOVES YOU

king_kilr
May 25, 2007

Lamacq posted:

`form.save_m2m()` I think you mean. `save_m2m` is defined on the ModelForm, not the Order instance IIRC.

:commissar:, I think I'm going to go commit something to forms to drown my sorrows.

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