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

MEAT TREAT posted:

I really liked WebFaction the last time I had to use Django. At the time they were just rolling out some new sever scaling features but it looked promising. I know they offer MySQL databases, but I'm not sure what else.

Going with this too. Other than a few oddball file locations (It is, after all a shared host rather than vhost setup) , its really configurable, and if theres something that aint working right, the support is one of the best I've encountered. Its some sort of variant of chroot jail setup, and get a shell account which can be used to install stuff into your jail, and so on.

Just be a bit wary the documentations a little iffy regarding python version types sometimes.

Adbot
ADBOT LOVES YOU

duck monster
Dec 15, 2004

Possible heresy incoming....

I wonder how difficult it would be to write a django template tag that does this

{% python %}
bunch of embedded python
{% endpython %}

Normally that sort of things bad form, but sometimes django template system really shits me with its lack of features.

It would enable php-esque shittiness, but a contract in a hurry sometimes demands shittiness.

Naturally you wouldn't want something like this to occur

{% python %}
for item in blah:
{% endpython %}
Blah html
{% python %}
???????
{% endpython %}

Because it'd just end up confusing the block indentation stuff, but as long as whats in between the tags is more or less self contained, it would probably just be implementable with an eval() call.

I think. . . . .

raymond
Mar 20, 2004
It probably wouldn't be hard, but what are you really struggling with? The only problem I've had with Django's template language is the lack of variable assignment, which I ended up writing a dodgy template tag to solve.

German Joey
Dec 18, 2004

raymond posted:

It probably wouldn't be hard, but what are you really struggling with? The only problem I've had with Django's template language is the lack of variable assignment, which I ended up writing a dodgy template tag to solve.

can't you just use the {% with %} tag for that?

duckmonster, what do you find yourself unable to do with template tags and filters?

raymond
Mar 20, 2004

German Joey posted:

can't you just use the {% with %} tag for that?

The "with" tag is too limited. This might not mean much, but here is one way it has been used:
code:
{# When viewing these content types, build a slug based on the URL #}
{% assign "pane_slug" %}{% spaceless %}
    {% if page|is_type:"page" %}
        rhr_{{ page.url|replace:"/,_" }}
    {% else %}{% if section %}
        rhr_{{ section.url|replace:"/,_" }}
    {% endif %}{% endif %}
{% endspaceless %}{% endassign %}

{# Try to get some content using the generated slug #}
{% assign "pane_content" %}{% spaceless %}
    {% if pane_slug %}
        {% embed_url pane slug=pane_slug %}
    {% endif %}
{% endspaceless %}{% endassign %}

{# Use the content or fall back to the default #}
{% if pane_content %}
    {{ pane_content }}
{% else %}
    {% embed_url pane slug="rhr_default" %}
{% endif %}
The Django developers would probably hate it, but it lets the frontend guys have a lot more control.

I'm going to ask my manager if I can start a work blog to post stuff like this. Then I would be able to show the actual template tag source code.

MonkeyMaker
May 22, 2006

What's your poison, sir?
Just look at Jinja2, raymond. As far as I remember, it lets you do a lot more Python in the templates than Django's templating engine does (both by design).

duck monster
Dec 15, 2004

Oh its definately a design decision on Djangos behalf. The template language is intentionally sparse to try and enforce a logic/presentation separation, and 90% of the time thats a very good thing.

My favorite template system back when I was doing PHP dev was this thing called "Sigma" that was incredibly simple. Variable substitutions and blocks. If you need the block to repeat, you processed it twice in the code. It made for *very* simple templates that even the dumbest graphic designer could understand.

The problem though with simple syntaxes is that when you want to do something really loving unusual you end up either with a stupidly complex amount of tag fuckery, or having to write a template tag, or alternatively pushing display logic back into the view.

And thats where it becomes problematic. A good view/template arangement OUGHT allow you to just rewrite the template to have an entirely different presentation whilst leaving the view to just prepare the data. When you have to massage the data to fit a certain template , its problematic.

Thus it'd be nice to be able to go "Ok, we're swapping in a new template but it kind of needs some massaging (like maybe calculating a percentage or something) to allow the simple template model to cope with it. Being able to drop in a bit of python to massage it means that you dont have to rewrite views, just the template.

Its a weapon of last resort , strictly for when the deadlines too short to go loving around with hairy template tag semantics, but it'd be a loving handy weapon to have, as just a third-party template processor that can be optionally added in and used when needed.

e: I think it was called sigma, its been a long time since I've been a PHP dev. gently caress php.

duck monster
Dec 15, 2004

e: gently caress it, I'm not fixing this problem, I'm just not going to use green unicorn for debugging that page :sigh:

duck monster fucked around with this message at 06:20 on Aug 26, 2011

German Joey
Dec 18, 2004
like, i still don't get it. what can you not do just by writing a few new template tags/filters? those are your supposed to be inline "evals," for content not generated in the view, right there! what is "stupidly complex amount of tag fuckery" supposed to mean? tags and filters are so loving simple. what the gently caress kind of situation do you need a literal "eval" block for?

duck monster
Dec 15, 2004

German Joey posted:

like, i still don't get it. what can you not do just by writing a few new template tags/filters? those are your supposed to be inline "evals," for content not generated in the view, right there! what is "stupidly complex amount of tag fuckery" supposed to mean? tags and filters are so loving simple. what the gently caress kind of situation do you need a literal "eval" block for?

Well it'd be a personal convenience. Due to the complete inadequacy of the built in webserver in django (Serious, put even the slightest bit of pressure on the loving thing and it implodes) I usually use green unicorn to debug, which means I have to stop and restart django each code revision. Since templates are not cached (if you dont ask it to) , fiddlefucking around with some {% inline %} poo poo would be faster.

Its just a convenience.

Plus to be honest, custom tags arent THAT much simpler, since the code aint in the same place.

Opinion Haver
Apr 9, 2007

Is sending a SIGHUP to your gunicorn process really that much effort?

Yay
Aug 4, 2007
The template writer in me wants to retch at that {% assign %} tag. I'm glad that it works for you and yours, but at that point, I'd be seriously rethinking why it needs to be like that (time constraints aside).

duck monster posted:

Thus it'd be nice to be able to go "Ok, we're swapping in a new template but it kind of needs some massaging (like maybe calculating a percentage or something) to allow the simple template model to cope with it. Being able to drop in a bit of python to massage it means that you dont have to rewrite views, just the template.
I can't think of a time when either object methods or template tags (which aren't painful at all with classy-tags) weren't enough. I suspect if, in some way, they weren't enough, I'd still have to rethink the data being passed in to the template - if you can't massage the data with easy-as-pie classy-tags, you need different data anyway, right?

I do wish the method built into Django for writing templatetags was less goddamn painful though, and I can see why, given the absence of various apps that improve it, you'd want to avoid it.

epswing
Nov 4, 2003

Soiled Meat
nm

epswing fucked around with this message at 14:24 on Aug 27, 2011

Lamacq
Jun 15, 2001

Breezeblock RIP

duck monster posted:

Well it'd be a personal convenience. Due to the complete inadequacy of the built in webserver in django (Serious, put even the slightest bit of pressure on the loving thing and it implodes) I usually use green unicorn to debug, which means I have to stop and restart django each code revision. Since templates are not cached (if you dont ask it to) , fiddlefucking around with some {% inline %} poo poo would be faster.

I use the runserver_plus command from django-command-extensions, which uses the astonishingly great wsgi debugging server from Werkzeug instead of the built in django http server. shell_plus is really handy too. Check it out, you might like it better than gunicorn.

epswing
Nov 4, 2003

Soiled Meat
Does anyone use an IDE with a debugger, allowing them to step through djando code? I remember attempting this with the community version of Wing and it never worked properly (or I was doing something wrong).

Lamacq
Jun 15, 2001

Breezeblock RIP

epswing posted:

Does anyone use an IDE with a debugger, allowing them to step through djando code?

I use ipdb, and just stick in a call to ipdb.set_trace() wherever I want to start debugging. Whatever terminal you have runserver/runserver_plus running in will just turn into a debugging console.

duck monster
Dec 15, 2004

epswing posted:

Does anyone use an IDE with a debugger, allowing them to step through djando code? I remember attempting this with the community version of Wing and it never worked properly (or I was doing something wrong).

Wings is terrible and shouldn't be used by anyone.

epswing
Nov 4, 2003

Soiled Meat

duck monster posted:

Wings is terrible and shouldn't be used by anyone.

Ok, recommend me an IDE that supports debugging python/django. Don't say eclipse.

(PS, for dynamically typed languages I've only ever used a straight text editor. It would be useful to step through the code sometimes, though...for example, my recursion problem above, I don't know what the gently caress.)

Hughlander
May 11, 2005

epswing posted:

Ok, recommend me an IDE that supports debugging python/django. Don't say eclipse.

(PS, for dynamically typed languages I've only ever used a straight text editor. It would be useful to step through the code sometimes, though...for example, my recursion problem above, I don't know what the gently caress.)

PyCharms. Worship the nectar of Jet Brain!

raymond
Mar 20, 2004

Yay posted:

The template writer in me wants to retch at that {% assign %} tag. I'm glad that it works for you and yours, but at that point, I'd be seriously rethinking why it needs to be like that (time constraints aside).

It is absolutely about time constraints!

I totally agree that the {% assign %} tag is not ideal, but it allows the frontend developers (who generally don't know Python) to solve more problems than normal. Before I made it, people were making "prefix" and "suffix" arguments for lots of template tags. There are template tags that take like 10 optional arguments. I actually introduced the idea of keyword arguments in template tags (!!!). Some of the existing tags make me want to throw chairs at the desks of everyone that was made redundant this week. I have been there for nearly 3 years and this so low on the priority list that I haven't even thought of it until now.

I have some issues to work through, but at least I haven't resorted to an eval template tag. ;)

raymond
Mar 20, 2004

duck monster posted:

Its just a convenience.

Plus to be honest, custom tags arent THAT much simpler, since the code aint in the same place.
I still don't think it's that restrictive. You seem to be a freelance developer or something, so i can't see why you can't write all sorts of custom template tags to do the job.

I can't tell if you're not used to writing them, or just don't like them. I never blame the template system when I find something difficult to solve.

Captain Capacitor
Jan 21, 2008

The code you say?
While I can understand some frustration with it, I've never had a problem with PyDev. Especially since I can integrate nicely with my Fabric scripts.

Mulozon Empuri
Jan 23, 2006

Captain Capacitor posted:

While I can understand some frustration with it, I've never had a problem with PyDev. Especially since I can integrate nicely with my Fabric scripts.

What has pydev got to do with your fabric scripts?

Captain Capacitor
Jan 21, 2008

The code you say?

Mulozon Empuri posted:

What has pydev got to do with your fabric scripts?

Not necessarily for me, but makes it easy to set up for designers working on the project. Define run/debug commands that just call the fabric script using command line/environment variables to distinguish between test and production.

epswing
Nov 4, 2003

Soiled Meat

Hughlander posted:

PyCharms. Worship the nectar of Jet Brain!

Thanks for this recommendation. I've already used the debugger to locate a bug. I'll probably buy it.

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?
I have a 1.3 project that uses some legacy read-only databases in addition to the default. These databases should be used for the tests, no new versions should be created and torn down. Is the way to do this to extend DjangoTestSuiteRunner and override setup_databases and teardown_databases?

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah
Is there some sort of advanced inventorying solution for Django? So far I've found django-inventory and django-simple-inventory, but the former lacks a lot of features and the latter looks like it was put together in 10 minutes.

I work for a school district that wants to be able to inventory all of our computers (right now our warehouse manager uses a Filemaker database, ugh), and populate data based on machine name using WMI. This includes storing a bunch of custom fields as well as the specs for each machine including the software installed on it.

I figured no matter what solution I ended up with that I'd be programming the WMI portion myself, which is no big deal. I would just rather not write *all* of it completely from scratch.

duck monster
Dec 15, 2004

epswing posted:

Ok, recommend me an IDE that supports debugging python/django. Don't say eclipse.


The only problem I have with eclipse (and sadly its been a showstopper for me) is that it falls into a smouldering heap if its working on a network drive with an inconsistent connection. Which in my case is all the loving time (yay wireless), and recovers poorly from it.

I'd say pycharm, but sadly it handles that even more poorly. :(

The best I've come across so far has been sublime text 2 with the sublime port of Komodo's CodeIntel plugin. I have no idea if it debugs django directly but I'm usually working on a laptop with the dev server mounted via SMB. From looking around it doesn't natively do it, but since Sublime Text 2's plugins are done in python it ought be very straight forward to put together a plugin for it, especially since the plugin system seems pretty straight forward. There is a python console in it, but what would *rule* would be a way to pull up the django shell itself. Its a much simpler editor, but with the exception of debugging (And I tend to prefer handling that poo poo command line mainly out of "stubborn old dog" reasoning) it does almost everything essential whilst still feeling lightweight as hell. Ultimately its what bugs me with all the "heavy" ide's (other than my passionate hate for a "virtual" folder view that doesnt always reflect the file system reality without loving about with syncs etc) , is that I just want it to get out of my way and let me mash my sausagefingers into the keyboard, only popping up to offer tasty code completion morsels. Well that and telling me if I'm making an obvious dumbfuck move.

ANOTHER QUESTION

Is there a neat way of representing a true undirected (symmetrical) graph in M2M fields whilst still having an intermediate model to express things like edge weightings etc? I mean I can sort of fake it by just pretending its symetrical but theres all sorts of wierd implications like having to double process edges for INCOMING and OUTCOMING, then merging them and and and loving annoying (or add double edges but emulating symetry with double edges isnt actually the same as symetry in graph theory)

e: Actuallyt I can't find an example anywhere of using an intermediate model on an UNsymetrical model, and have no idea how to tell django which foreign reference on the intermediate model is the parent and the child. loving django documentation! e: I'm just going to try it and if it works I'll just have to accept it works and shudder at the magic.....

duck monster fucked around with this message at 07:03 on Sep 3, 2011

epswing
Nov 4, 2003

Soiled Meat
Sometimes when I do

code:
from django.contrib import messages
messages.success(request, 'My Message')
HttpResponseRedirect(...)
I don't see the message until I visit the page AFTER the one I've been redirected to.

What's going on here? When I say 'sometimes', I mean with most views this doesn't happen, but with one in particular, it does. And there's nothing that I can see which differentiates them.

raymond
Mar 20, 2004
Is this view missing the RequestContext? I think messages need that.

epswing
Nov 4, 2003

Soiled Meat

raymond posted:

Is this view missing the RequestContext? I think messages need that.

Ohhh the target view needs a RequestContext. Thanks!

Next Question!

When I import classes from other apps in my project, I've always used from myapp.somefile import SomeClass but PyCharm wants me to use from myproject.myapp.somefile import SomeClass

Pros/Cons?

epswing fucked around with this message at 05:36 on Sep 4, 2011

hey mom its 420
May 12, 2007

Explicitly referring to your project name from your apps is generally discouraged because it reduces the portability of your apps. Even if your apps aren't meant to be portable, I still wouldn't use it.

duck monster
Dec 15, 2004

epswing posted:

Ohhh the target view needs a RequestContext. Thanks!

Next Question!

When I import classes from other apps in my project, I've always used from myapp.somefile import SomeClass but PyCharm wants me to use from myproject.myapp.somefile import SomeClass

Pros/Cons?

Just throw the project directory into the python path. Refering to the projects name is bit of an anti-pattern for the reason mentioned above, but you shouldn't ever have to either.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

duck monster posted:

Just throw the project directory into the python path. Refering to the projects name is bit of an anti-pattern for the reason mentioned above, but you shouldn't ever have to either.

Doesn't manage.py do that for you?

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

MEAT TREAT posted:

Doesn't manage.py do that for you?

I forget if it does or not, but regardless that only works if you are using manage.py

duck monster
Dec 15, 2004

MEAT TREAT posted:

Doesn't manage.py do that for you?

It ought to, but you can't necessarily expect for an IDE to be able to parse that out. It at the very least requires the IDE to "get" django.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

duck monster posted:

It ought to, but you can't necessarily expect for an IDE to be able to parse that out. It at the very least requires the IDE to "get" django.

I thought that's what they meant when they say that the IDE supports django.

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

MEAT TREAT posted:

I thought that's what they meant when they say that the IDE supports django.

Normally supporting Django tends to be things like understanding the template language. Depending on their level of integration / features of the editor/ide it can also mean things like being able to introspect project paths, tab complete inside of setting strings, among some other misc features.

MonkeyMaker
May 22, 2006

What's your poison, sir?
Anyone here going to DjangoCon?

Adbot
ADBOT LOVES YOU

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

MonkeyMaker posted:

Anyone here going to DjangoCon?

I wish :(

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