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
duck monster
Dec 15, 2004

jupo posted:

This really is brilliant. One of the biggest hurdles the company I work for have faced with Django is actually selling it to clients due to how relatively unknown it is. I've honestly never heard of Alfresco before but looking at their client base this is just the kinda thing we need to pitch Django at an "enterprise" (I just threw up a little) level.

Alfresco is very loving cool, because it lets you automate business processes and do things like hook up with an ISO quality consultant or whatever and implement paper trail management and poo poo like that.

If you get into the workflows part of it, it starts to get really cool. Someone goes into word, fills in an order request, publishes it into an alfresco folder using words sharepoint interface, the thing then automatically forwards it to your manager, who reviews, ticks off, then fires a pair of copies into the purchases and engineering, meanwhile your customer logs into your django based portal (all authenticating from the same AD source) , reviews progress, and possibly adds a comment.

And you could impement that poo poo in a couple of days.

Double points if you replace the customers shared drives with the alfresco repository (It has a samba interface) , and start porting their ad-hoc internal processes into proper business flows.

Alfresco is serious enterprise poo poo, and it isn't microsoft, so theres geek cred right there.

Theres nothing it can do that sharepoint can't also do, and theres probably a few things sharepoint does better, but sharepoint can also be ridiculously frusturating, and I'm not aware of any django interfaces into sharepoint yet.

Quick note though: These guys also do a drupal add on for alfresco, and hosed if I can get it to work :(

Adbot
ADBOT LOVES YOU

Profane Obituary!
May 19, 2009

This Motherfucker is Dead
I started using django-treebeard in order to get a nestable series of models that i can use for categories/sub categories/sub-sub categories and so on. The problem i ran into is that there is no admin interface for django-treebeard. Before i go and see about implementing one, is there any django-treebeard like solutions that do come with an admin interface that i can just use out of the box?

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.

Profane Obituary! posted:

I started using django-treebeard in order to get a nestable series of models that i can use for categories/sub categories/sub-sub categories and so on. The problem i ran into is that there is no admin interface for django-treebeard. Before i go and see about implementing one, is there any django-treebeard like solutions that do come with an admin interface that i can just use out of the box?

django-pagecms does exactly this in the admin. I don't know how well it maps to treebeard but it'd be worth digging around in their custom admin pages.

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

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.

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.

Just for clarity - django-pagecms uses django-mptt

Profane Obituary!
May 19, 2009

This Motherfucker is Dead
Actually pagecms i think just made my entire job easier! I should have known i was semi reinventing the wheel.

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.

king_kilr
May 25, 2007

deimos posted:

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

Only trunk, mind you I live by the motto "trunk is the only stable branch", but it's still aggravating when you have to point this out to people.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
I'm trying to get Django setup on a Fedora Core box. I installed python, postgresql, mod_wsgi, and finally django. I added the following to my httpd.conf:

code:
<VirtualHost *:80>
        WSGIScriptAlias / /home/fletch/projects/domain/apache/django.wsgi
        ServerName domain.com
        ServerAlias *.domain.com
</VirtualHost>
Reloaded the httpd.conf and when I go to domain.com in my browser I get the "Firefox can't find the server at https://www.domain.com." No errors thrown in my apache error_log. Not sure where to go from here...any tips?

edit: I can ping the domain and it resolves to my server

edit2: gently caress I don't know what the deal was but it finally started logging the error in error_log, it was a typo in my django.wsgi file, couldn't find my settings file

Can I still use an htaccess file to password protect my dev environment? How would I do that?

fletcher fucked around with this message at 01:48 on Jun 25, 2009

bitprophet
Jul 22, 2004
Taco Defender

fletcher posted:

Can I still use an htaccess file to password protect my dev environment? How would I do that?

.htaccess files are a lovely crutch (in that they make people ask the question you just did, instead of understanding how Apache config actually works) that get a ton of use because of shared PHP hosting setups.

Since you've got access to the Apache config, just plunk whatever you would've put in a .htaccess file, into a <Location> block, e.g.
code:
<VirtualHost blah>
    blah blah
    blah blah
    <Location "/">
        AuthType Basic
        AuthUserFile /etc/apache2/users.htpasswd
        AuthName "lol no"
        Require valid-user
    </Location>
</VirtualHost>

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

bitprophet posted:

Since you've got access to the Apache config, just plunk whatever you would've put in a .htaccess file, into a <Location> block, e.g.

Ahh, that's what I had tried originally. Forgot to put it in a Location block. Thanks!

bitprophet
Jul 22, 2004
Taco Defender

fletcher posted:

Ahh, that's what I had tried originally. Forgot to put it in a Location block. Thanks!

Yea, that's the trick: a .htaccess is, for the most part, exactly equivalent to placing the contents of the .htaccess within a Location or Directory block whose value is the path to where the .htaccess was. (i.e. /var/www/foo/bar/.htaccess => <Directory /var/www/foo/bar> or <Location /foo/bar>)

Stuff like AuthType and friends don't even work at the top level of a config or vhost; see the docs and note the "Context" header of that doc section. Whenever something I do doesn't seem to work, I first make sure I'm using the directive(s) in the appropriate context :)

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
I'm a bit confused on how to organize my code into different apps, what portions deserve their own app, which ones to lump together, etc. Can somebody help me clarify this?

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.

fletcher posted:

I'm a bit confused on how to organize my code into different apps, what portions deserve their own app, which ones to lump together, etc. Can somebody help me clarify this?

There isn't a hard and fast rule. I've worked on projects that were so small with no chance of growing, that they only contained a few models and views and so I lump them all together into one app for the site.

Then I've worked on projects so large that contained over 50 applications - some of these contained no models, only templatetags for example. Some things just didn't belong *anywhere* such as various utilities that get used across a variety of apps, so they went under their own app called "misc".

Just apply common sense. Groups things together under apps when they logically belong together and you've got enough code going on that warrants the distinction between apps. The beauty of both Python and Django is that your environment is so logically organized from the get-go that in my experience you never really paint yourself into some huge corner that you have to backtrack from when major changes need to occur.

king_kilr
May 25, 2007

fletcher posted:

I'm a bit confused on how to organize my code into different apps, what portions deserve their own app, which ones to lump together, etc. Can somebody help me clarify this?

http://www.youtube.com/watch?v=A-S0tqpPga4 watch this :)

duck monster
Dec 15, 2004

I tend to just use one app and many controller files organised by theme, per file.

I do wish Django insisted on putting controller methods in objects. Its probably just my OO dysfunction, but exposed functions make me barf.

king_kilr
May 25, 2007

duck monster posted:

I tend to just use one app and many controller files organised by theme, per file.

I do wish Django insisted on putting controller methods in objects. Its probably just my OO dysfunction, but exposed functions make me barf.

It's perfectly possible to organize your views onto classes if you like, this is actually the plan for the future of generic views (and the admin is already organized this way). http://code.djangoproject.com/ticket/6735

king_kilr
May 25, 2007
Anyone looking for a large django codebase to look at may be interested in: http://www.everyblock.com/code/, http://github.com/brosner/everyblock_code/tree/master

spencer for hire
Jan 27, 2006

we just want to dance here, someone stole the stage
they call us irresponsible, write us off the page
I've been messing around with Django for the past few days but I ran into this error
code:
TypeError at /blog/2009/Jun/30/new/
object_detail() got multiple values for keyword argument 'queryset'
Generic views were cool until I got to object_detail then it spat that error out.
I've been trying everything but can't figure out what I did wrong.

Note: I'm new to this whole programming thing so forgive anything horrendous in the code, I dont know any better.

Separating the generic views from the urls.py seems like i'm kind of double-defining things. I did it because I read that it would be helpful if I was to extend on the generic views. Is this bad practice?

my views.py
code:
from blog.models import Post
from django.views.generic.date_based import archive_index, archive_year, archive_month, archive_day, object_detail

def blog_index(request):
    return archive_index(request, queryset=Post.objects.all(), date_field='pub_date', num_latest=5)

def year_archive(request, year):
    return archive_year(request, year, queryset=Post.objects.all(), date_field='pub_date')

def month_archive(request, year, month):
    return archive_month(request, year, month, queryset=Post.objects.all().order_by('-pub_date'), date_field='pub_date')

def day_archive(request, year, month, day):
    return archive_day(request, year, month, day, queryset=Post.objects.all().order_by('-pub_date'), date_field='pub_date')

def post_detail(request, year, month, day, slug):
    return object_detail(request, year, month, day, slug, queryset=Post.objects.all(), date_field='pub_date')
urls.py
code:
from django.conf.urls.defaults import *

urlpatterns = patterns('mysite.blog.views',
    (r'^$', 'blog_index'),
    (r'^(?P<year>\d{4})/$', 'year_archive'),
    (r'^(?P<year>\d{4})/(?P<month>\w{3})/$', 'month_archive'),
    (r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/$', 'day_archive'),                      
    (r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$', 'post_detail')   
)

multigl
Nov 22, 2005

"Who's cool and has two thumbs? This guy!"

spencer for hire posted:

I've been messing around with Django for the past few days but I ran into this error
code:
TypeError at /blog/2009/Jun/30/new/
object_detail() got multiple values for keyword argument 'queryset'
Generic views were cool until I got to object_detail then it spat that error out.
I've been trying everything but can't figure out what I did wrong.

Note: I'm new to this whole programming thing so forgive anything horrendous in the code, I dont know any better.

Separating the generic views from the urls.py seems like i'm kind of double-defining things. I did it because I read that it would be helpful if I was to extend on the generic views. Is this bad practice?

I feel like you're doing way to much work, You can pass those necessary arguments to the generic views from the URLs see here for passing arguments to a view from the url line directly

VVVVV he's right

multigl fucked around with this message at 09:28 on Jul 4, 2009

king_kilr
May 25, 2007

multigl posted:

I feel like you're doing way to much work, You can pass those necessary arguments to the generic views from the URLs see here for passing arguments to a view from the url line directly

Also, the reason your particular method is broken is that object_detail is expecting a single item, and your .all() is returning a QuerySet with a more than one item.

That's not the reason for the exception, and I have no idea how you reached that conclusion. The exception is because he's passing too many positional variables to the object_detail view. Specifically slug is passed as a keyword argument and queryset is the 4th positional argument. Thus he's passing the slug as a positional argument in the queryset position, as well as queryset the keyword argument. Also queryset should be a queryset, not a single item.

multigl
Nov 22, 2005

"Who's cool and has two thumbs? This guy!"

king_kilr posted:

That's not the reason for the exception, and I have no idea how you reached that conclusion. The exception is because he's passing too many positional variables to the object_detail view. Specifically slug is passed as a keyword argument and queryset is the 4th positional argument. Thus he's passing the slug as a positional argument in the queryset position, as well as queryset the keyword argument. Also queryset should be a queryset, not a single item.

oops you're definitely right, I never use generic views.

spencer for hire
Jan 27, 2006

we just want to dance here, someone stole the stage
they call us irresponsible, write us off the page

king_kilr posted:

That's not the reason for the exception, and I have no idea how you reached that conclusion. The exception is because he's passing too many positional variables to the object_detail view. Specifically slug is passed as a keyword argument and queryset is the 4th positional argument. Thus he's passing the slug as a positional argument in the queryset position, as well as queryset the keyword argument. Also queryset should be a queryset, not a single item.

That was it, thank you so much.

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys
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 fucked around with this message at 23:22 on Jul 5, 2009

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.)

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys

deimos posted:


So the answer is that Django development is no better on Windows than Rails?

Man, maybe I should just give in and do ASP.Net. At least that IDE is awesome.

MonkeyMaker
May 22, 2006

What's your poison, sir?
Django/Python can be done on Windows, but, yes, I'm sure it's horrible. Windows just isn't a random-language-friendly platform. Why not just use VirtualBox to run Linux and not have to deal with the bullshit of installing on Windows?

As far as IDEs and editors go, Vim/Emacs or just something simple like Notepad++ should be plenty.

But, really, if you don't want to do ASP/PHP, get a Mac or run Linux.

dvgrhl
Sep 30, 2004

Do you think you are dealing with a 4-year-old child to whom you can give some walnuts and chocolates and get gold from him?
Soiled Meat

Magicmat posted:

So the answer is that Django development is no better on Windows than Rails?

Man, maybe I should just give in and do ASP.Net. At least that IDE is awesome.

When I was messing around with it, I set up RoR with XAMPP and used Notepad++ all on Windows with no problems. I did use SVN, but I wouldn't say that there was any issue that made RoR development on a Windows box a hardship. You can even use Aptana with the RoR plugin if you want something more than just a text editor to develop in.

That being said, gently caress if I could get Django to ever work on Windows (or Linux for that matter). I didn't spend much time though as it was just a curiosity to play around with.

Wulfeh
Dec 1, 2005

The mmo worth playing: DAoC
I had no problems developing on a windows machine with Django back in 0.96, and we used a Debian box for our production server.

I used Notepad++ for editing and tortoise svn as an interface for using svn on windows.

As for the python interpreter, I don't know if it runs any faster or slower, but I don't remember running into anything that stopped me from developing. Just make sure to setup all your path variables correctly in Windows and there shouldn't be any trouble.

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.

MonkeyMaker posted:

Django/Python can be done on Windows, but, yes, I'm sure it's horrible. Windows just isn't a random-language-friendly platform. Why not just use VirtualBox to run Linux and not have to deal with the bullshit of installing on Windows?

As far as IDEs and editors go, Vim/Emacs or just something simple like Notepad++ should be plenty.

But, really, if you don't want to do ASP/PHP, get a Mac or run Linux.

This just isn't even remotely true. I've been developing with Django on Windows and deploying on Linux full time for around a year now and I believe in that time I've had a grand total of one issue - some 3rd party Django app that had hard coded slashes in it rather than using os.sep

Install Apache on Windows, MySQL or Postgres - everything just works.

No Safe Word
Feb 26, 2005

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.)
I've tried getting eclipse with pydev working, but I'll be damned if I don't just go back to vim. I do a fair share of development on Windows, and it works fine for me.

edit: Catching this before the edit:

king_kilr posted:

Django (as well as Python) is fully supported on Python.
:downsowned:

No Safe Word fucked around with this message at 05:13 on Jul 6, 2009

king_kilr
May 25, 2007
Django (as well as Python) is fully supported on Python. One of the Django core committers is a regular Windows user and verifies that everything works.

Git
Aug 21, 2004

Magicmat posted:

So the answer is that Django development is no better on Windows than Rails?

Django development is fine on Windows. I didn't encounter any problems or notice any quirks or anything from doing so during my albeit brief usage of Windows for development. I did get annoyed enough by general Windows stuff to offload my code to a Linux server and edit it remotely, though that's a reflection on my OS preferences rather than any sort of sleight against Python or Django.

As for IDEs, it seems like most developers I know use Eclipse with PyDev, and the rest seem to use Wing or Komodo. Personally, I prefer just using a text editor, specifically TextMate on OS X, gedit on Linux, and Notepad++ on the rare occasions I use Windows.

bmoyles
Feb 15, 2002

United Neckbeard Foundation of America
Fun Shoe
This might be worth looking into too:
http://www.e-texteditor.com/
Billed as "TextMate for Windows"
I dunno how true that is, but it supports TextMate bundles on Windows, so it may get you close.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
The issues I've run into on Windows mostly have to do with the binary distributions of third party apps not supporting newer versions of python. This was mostly last year when 2.6 had just come out, so I'm sure it won't be the same situation right now. It's just something you have to keep in mind when developing on Windows.

Here is the MySQLdb which only supports python 2.4 and 2.5 on Windows. I don't know if it will work with 2.6.
http://sourceforge.net/projects/mysql-python/files/

duck monster
Dec 15, 2004

Magicmat posted:

So the answer is that Django development is no better on Windows than Rails?

Man, maybe I should just give in and do ASP.Net. At least that IDE is awesome.

It works great. I use Eclipse with PyDev and it works fantastic.

There are also python plugins for Netbeans and Visual Studio.

Python is a microsoft anointed first class citizen on the Windows platform.

No Safe Word
Feb 26, 2005

duck monster posted:

It works great. I use Eclipse with PyDev and it works fantastic.

There are also python plugins for Netbeans and Visual Studio.

Python is a microsoft anointed first class citizen on the Windows platform.

Ehhh.. IronPython is, which is generally up to date with CPython, but not 100%. For most uses it's up to date. The latest stable release brings it up to full Python 2.5 support but there's a beta that supports 2.6 and I've heard that it's pretty stable as well.

MonkeyMaker
May 22, 2006

What's your poison, sir?
Having a problem with Django's admin and ImageField.

I know for a fact that PIL works fine. It'll open and modify any image I try in the shell and regular terminal, so I don't see how PIL could be the problem.

Django's admin, however, won't accept any image, returning the error: "* Upload a valid image. The file you uploaded was either not an image or a corrupted image." for any image I give it.

Any ideas?

king_kilr
May 25, 2007
If you're on a semi-out of date trunk I'd upgrade right the hell now. For a while in the 1.1 dev process image fields were fairly messed up.

Adbot
ADBOT LOVES YOU

Git
Aug 21, 2004

This is a pretty cool IBM developerWorks article on writing better Django models, with a mind to improving query performance and with the use of model managers.

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