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
deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

nbv4 posted:

My problem is that everytime I want to edit a Position object, it complains if I leave the three inline PosBase objects empty. I have two other inlines on other models that are just ignored when you try to save the object with blank inlines. I can't figure out why it's doing this. I tried changing around "blank=True, null=True" in the ForeignKey fields, but all that seems to do it cause a totally blank object to be saved and then linked to the parent object. What the heck...

Try getting rid of the default=0.

Adbot
ADBOT LOVES YOU

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
For any newbies out there with some python knowledge the Django 1.0 Template Development book is absolutely amazing. Don't just browse it, READ IT. It's very in depth but easy to follow if you read the whole thing.

Ohh, and it's not just about Templates, it covers pretty much everything django.


edit: forgot to mention: it's not quite as easy on the newbie as bitpropbhet's, nor as broad on subjects. But it covers some nuances that are very important to a django developer, I have learned a LOT from it.

bitprophet posted:

Did you mean me? :shobon: I think bitkeeper is the "savagely optimized" guy.

eek, yeah I did, pretty sure I confused your name with the software product, didn't really feel like looking it up, sorry.

deimos fucked around with this message at 21:02 on May 28, 2009

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

bitprophet posted:

Did you mean me? :shobon: I think bitkeeper is the "savagely optimized" guy.

Have you read Scott's book? I made work buy your django book and read through it but haven't had time to really read it through except for some of the more advanced parts, and Marty's book which is equally awesome and metaclassy as gently caress.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
django now runs on Glassfish V3. Huzzah. Now there's no platform left to escape the power of django.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

duck monster posted:

I've always wanted to enhance my Django experience with the joys of configuring a mindfuckingly huge number of complicated XML files.

Actually, I haven't had to touch an XML file on our glassfish servers since... ohh... never. It has a very sexy web-based administrator. Also, setting up a dynamic language site is stupid easy, all you have to do is declare a new container and tell it it's gonna be python/ruby/whatever and configure a couple more variables and huzzah, django. It's actually easier than configuring apache.

caveat; I haven't done anything more than get it up and running, haven't actually transfered a decently sized django to glassfish and tested. Also, our glassfish cluster has a person that maintains it.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

king_kilr posted:

I *think* django-mptt has some helpers, but I might be wrong, and they need to put out a god damned 1.0 release.

?? django-mptt is 1.0+ compatible last I checked.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Magicmat posted:

How is Windows development support for Django, and Python in general? I'm talking about how well the actual interpreter works, as well as support tools like the version control system of choice for the Django community, and especially IDEs and/or editors. This is just for development; deployment would still be on the usual Linux stack.

I was trying to get back into Rails, but my response to asking the same question of them was "good luck; get a Mac." The Ruby interpreter is slow on Windows; the VCS of the Rails community is Git, which barely works on Windows and certainly not as well as SVN or Hg; and the editor of choice for Rails, Text Mate, is OS X only.

I'm getting tired of feeling like a second class citizen. Is Django development viable on windows? Or will I be locked out of some tools and using poor ports of others?

As a corollary, what is the IDE of choice for Django? Or even just the best code editor? (And don't say Vim or Emacs.)

Magicmat posted:

(Vim or Emacs.)

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

outlier posted:

What's people favourite choice / method for creating multi-stage forms in Django? I'd like a solution where on the one page a user can click forwards (and backwards) through a multipart form.

Do you mean like a Form Wizard?

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Hanpan posted:

Another absolutely retarded question:

Is there a way to exclude fields form a query set? I am putting my result straight into JSON, and I am I trying to exclude a "tags" ManyToMany field from my model since I don't need it and it will hit the database unnecessarily. I have tried this:

code:
projects = Projects.objects.category(slug).exclude(tags)
But obviously it doesn't work. Is there a way to do this?

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields

code:
projects = Projects.objects.category(slug).values()

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

LOLLERZ posted:

This is kind of an Apache/WSGI problem, but I'm trying to deploy Django, and I thought maybe someone here would have seen this before:

I'm on WinXP and when I run net start apache I get the following error message in Event Viewer:
code:
The Apache service named  reported the following error:
>>> httpd.exe: Syntax error on line 3 of 
C:/Program Files/Apache2.2/conf/httpd.conf: 
Cannot load C:/Program Files/Apache2.2/modules/mod_wsgi.so
into server: The specified module could not be found.
For reference, the relevant part of my httpd.conf is
code:
ServerRoot "C:/Program Files/Apache2.2"
Listen 80
LoadModule wsgi_module modules/mod_wsgi.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
I think it's some kind of permissions issue, but I can't figure out how to prove that.

Silly question but does the file exist?

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

LOLLERZ posted:

That's a perfectly reasonable question, but yes, I have the correct file for my major/minor version of Python, and for my install of Apache, and it's named correctly. It's in the same location as all the other mod_whatever.so files.

well if you renamed it to mod_wsgi.so and placed it in the right directory then check windows permissions for the other .so files and compare it to your mod_wsgi.so

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

bitprophet posted:

I'm lucky enough to admin my own systems and/or generally work in environments where the sysadmin is actually told what the system will be used for and can tailor the backup/mount scheme accordingly. (I also tend to use a one-big-partition setup unless the system has obvious needs otherwise, because I've run into other peoples' poor partition size planning way more often than I run into situations involving SANs or needing specific mount flags. v:shobon:v yes I work in a small/medium sized web shop, how'd you guess?)

Out of curiosity, where would a POSIX or LFHS compliant location for "web apps" like this be? Please don't say something horrid like /home/django/myapp :cry: I'm guessing /var/django/myapp or /opt/django/myapp?

The correct place for that stuff IS /srv according to the LFHS.

http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/srv.html

deimos fucked around with this message at 22:48 on Oct 20, 2009

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

nbv4 posted:

it depends on how you have your database set up. If you have a few hundred thousand pizzas and more than a few hundred toppings, the above queryset will slow things down a lot. Me, personally, I try to avoid any kind of full-table annotate like that unless it's a query that only gets executed once a day or something.


What? No it doesn't, at least not that annotate (Well, at least not on DB2, MySQL, PostgreSQL or Oracle, ymmv in MSSQL***). Unless your indexes are retarded. If you have a several million pizzas you'll have a different issue.

As always the trick is to get django's query for the operation and index appropriately (I think this particular query might benefit from a compound index) after an EXPLAIN/ANALYZE.

quote:

Also, "denormalization" isn't really the right word. You're not denormalizing all of your data, you're just denormalizing for that one query.

Denormalization is the correct word. Denormalization is not always done on your entire data set, but on some fields that. In this case it might be useful since pizza toppings don't change, but, again, you won't run into problems until the several millions, and even then I bet you'd have to do some fancy denormalization on other parts of your data set before this particular query becomes a problem.


*** Specially not in DB2. And actually over time PostgreSQL and Oracle generate bitmap indexes on the fly too, so no index needed there. Pretty sure DB2 also does this.

deimos fucked around with this message at 13:38 on Dec 28, 2009

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
Oooo, this is awesome, native-ish django in non-relational databases:
http://bitbucket.org/wkornewald/django-nonrel/wiki/Home

It's still got some work to go but my mediocre test app worked, pretty nice.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

ATLbeer posted:

Virtualenv is probably out of scope in a basic tutorial but, tests... drat right, adding it to my to-do list

A good overview to a decent directory organization skeleton would be awesome so people get used to a sane directory structure. Something like this (which I think is based off of ericflo's work, but if it's his I can't find it anywhere else).

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

king_kilr posted:

There's a better source than adrian: http://twitter.com/TheOnion/status/10921296161 :) If anyone has any questions about it I can probably answer them, I interned there last summer

I really wish they'd do decent explanation of their rationale, my work is looking at Drupal for a bunch of poo poo which I think it'll be a terrible fit for which a framework (I am partial to django but I've said use anything) would be a much better fit. If I could point to an article or blog post or blurb with their rationale I would have some ground on my arguments.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

nbv4 posted:

why not? I'm actually thinking of dumping memcache and going back to the file cache at least until my site grows a little more. Memcache uses memory which for me is in short supply, and the file cache performs just as well. For reference, my site gets about 2 access per second during peak times.

Contrary to popular belief, rdbms are not that slow, specially for indexed key/value storage (where the queries will be easily cached). The DB backend is probably going to be faster, more thread-safe and less io intensive than file caching.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

ufarn posted:

It, too, doesn't seem to understand Gmail's + filters, which means that you can make an infinite amount of accounts when signing up with the same e-mail address, as long as you use a different filter every time.

Just to nitpick; using + for subaddressing predates gmail and it's been an RFC proposal since around '03.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
Way to cancel Open Django East on me king_kilr! :mad: This sucks, trip cancelation will cost me moolah.

(I know it's not his fault.)

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

SlightlyMadman posted:

Amazon is definitely the way to go if you can spend a couple bucks more and don't mind being your own sysadmin. I've got a few sites up there and it works great, just make sure you back poo poo up yourself, because they do have occasional server failures and don't perform any sort of backups themselves.

Not only this, but AWS has free tiers for which you might qualify, if you ever launch the site you can probably hand off half the poo poo to AWS anyways: database to RDS, caching to ElastiCache, content delivery to cloudfront, etc.

As a general note, CloudFront is a ridiculously good CDN for the price, specially the latest iteration that got launched a few days ago.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

SlightlyMadman posted:

For some reason I've never managed to get a micro server to qualify for the free tier

Maybe because of this:

quote:

* These free tiers are only available to new AWS customers, and are available for 12 months following your AWS sign-up date. :words:

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Suspicious Dish posted:

The problem for me is that each item you enter into an M2M needs a PK, which means it needs to be saved. That means that there's a mess of worms where I have to make sure I have all my data before I can enter it into the M2M or enter it into the database, and...

This is relational theory 101 not just django, it's proper database design. M2M is trivial once you understand proper normalization. An ORM is not an excuse to not know how relational databases work.

In order to make it easier and not have to fight the ORM the few times you may have to you can always play around with ForeignKey.on_delete and/or setting null=True.

e: null=True is not something you actually want to do if you want to maintain referential integrity, just threw it out there so that you can learn, the hard way when your entire database becomes a nightmare of potholed crap data, that referential integrity is important :toot:

deimos fucked around with this message at 22:10 on May 30, 2012

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Suspicious Dish posted:

Unfortunately, due to commit_manually making sure the DB is clean after committing, I get a 500 error when I return from my view because a context processor just simply ran a select query, so I have to force it clean, but that's another issue.

Isn't this solved by changing the middleware order?
e: middleware != context processor


Err, this is your problem because you're using commit_manually as a decorator on the whole view and not taking into account querying context processors on the render call. You have two options there, abstract the transactional database manipulation into it's own method with the commit_manually decorator or use commit_manually as a context manager for the block of code that is transactional.

edit2:
another option is to simply commit/rollback after render_to_response, so this:
code:
@transaction.commit_manually
def myview(request):
    // blah
    // bleh
    transaction.commit()
    return render_to_response('blah.html')
becomes:
code:
@transaction.commit_manually
def myview(request):
    // blah
    // bleh
    transaction.commit()
    ret_val = render_to_response('blah.html')
    transaction.commit()
    return ret_val
edit3:
Yet another option is, in your context processors to do something like this:
code:
if transaction.is_managed():
    transaction.commit();
But on that one you're getting into :catdrugs: territory.

deimos fucked around with this message at 23:22 on May 30, 2012

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Suspicious Dish posted:

I'm doing option 2, only replace the commit() with set_clean().

Yeah, I feel it's a better approach to use one of the first 2 options (both are basically: don't use the decorator on the entire view).

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

German Joey posted:

The problem has nothing to do with M2M relations, but rather is because of Django's idiotic ON DELETE CASCADE feature. Deleting a row in a through table thus causes all kinds of chaos unless you know how to explicitly step around it.

Hello friend, may I interest you in ForeignKey.on_delete?

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

MonkeyMaker posted:

CBVs are really simple once you get down their basic API. But, sadly, there aren't good docs for it yet.

code:
from django.views.generic import DetailView

from myapp.models import MyModel


class MyDetailView(DetailView):
    model = MyModel
    template_name = "path/to/my/detail.html"
And you're done. In the template's context, the selected object will be {{ object }}. By default DetailViews expect a slug or pk kwarg to come in. You can override that, but it's obviously easier not to.

Do not confound CBVs and G(eneric)CBVs, two different beasts altogether.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Suspicious Dish posted:

Apparently I'm the only person who keeps running into Django gotchas. It's awesome when trying to use transactions means that Django drops any exception in the function on the floor. Welp.

Yes, you're the unique snowflake that has run into a framework's warts, no one else ever has had issues with django ever. Solution Soon™. For development you can use this gist.

deimos fucked around with this message at 16:24 on Jun 8, 2012

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

ufarn posted:

EDIT: Sounds like this is a :airquote:known problem:airquote::

It doesn't seem like a DB error, seems like the naive implementation of the development http server having timing issue. If your requests take long enough it'll throw that error.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
wait nm, idiot I am.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
RIP Malcolm Tredinnick (source)

One of the first persons to answer a question for me on #django was Malcolm, I actually feel sad.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Thermopyle posted:

Is there any pre-packaged easy way to emulate the heroku experience to some degree on a shared host like Dreamhost? I've got a couple projects that are a long way from being worth paying any money to host on Heroku, but it would be sweet if I could just git push them or something to Dreamhost and not worry about getting/updating requirements and the like...

If it's not a super serious app why not run it on Heroku's free tier?

edit: as an alternative Fabric scripts or setting poo poo under saltstack/puppet/chef would work, with saltstack being my new favorite hotness.

deimos fucked around with this message at 21:58 on May 23, 2013

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Maluco Marinero posted:

Might have a look into using Puppet instead, at the moment I just have a page long shell script that's doing the trick, but I know in bigger setups I want something a little more expressive.

Risking repeating myself, saltstack is really really really growing on me to program infrastructure, it's not super mature but it's being developed at breakneck speed, if you're ditching chef for something try saltstack. And there's this.

Adbot
ADBOT LOVES YOU

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
Pydanny just tweeted this and I thought I'd share with you guys, it's a pretty great resource for CBVs.

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