| pr3d4t0r | Owner_: The strangest thing is that the template is being included (via extend), then it chokes when it finds the first block. |
| pr3d4t0r | Owner_: Yes, child extends the page in the example. |
| girasquid | Is it even possible to pass an initial argument to a forms.BooleanField? No matter what I do, I can't seem to get it to be True when my form is rendered |
| Owner_ | pr3 i thought i only saw the parent template's link |
| pr3d4t0r | Owner_: Right. |
| pr3d4t0r | Owner_: Let me post the whole thing; there isn't much to it. Please stand by. |
| pr3d4t0r | Owner_: http://eugeneciurana.com/pastebin/pastebin.php?show=42565 |
| pr3d4t0r | Owner_: The template error occurs whether the block is overriden in the specialized template or not. |
| Eloff | Can I query database views (as opposed to tables) with the django orm? |
| cleifer | hey guys, i have a custom field i'm using to represent timedeltas until it lands it django proper - i'd like to make it so when the integer value is loaded from the db its converted to a timedelta -- anyone know if there's a hook for that, or if i need to use a descriptor? |
| Action: pr3d4t0r is very close to giving up on Django and using App Engine This One Time for the demo he's got pending and then resolve this later. |
| Owner_ | pr3d4t0r: ok i got no idea, osrry dude |
| Owner_ | bbl |
| cleifer | Adys, ping |
| pr3d4t0r | Odd_Bloke: No worries - thank you. |
| pr3d4t0r | Oh, he left :) |
| ubernostrum | pr3d4t0r: what version of Django are you using? |
| pr3d4t0r | ubernostrum: 1.1. |
| pr3d4t0r | ubernostrum: With Python 2.5.2. |
| Adys | cleifer: ? |
| cleifer | hey, i have a quick question about field hooks, i know you've done some work on durationfield |
| pr3d4t0r | ubernostrum: Let's see... it's on an Ubuntu Server, single core, dedicated machine. All it'll do is act as a dev Django server. Nothing else in the box. |
| Adys | cleifer: sure |
| cleifer | i'm working up a simple one until it lands in django -- having trouble knowing the hook to convert an integer from the DB to a timedelta |
| ubernostrum | pr3d4t0r: and what's the full error message it gives you? |
| cleifer | my field subclasses IntegerField and i'm storing seconds since that's the resolution we need |
| Adys | cleifer: did you look at the last durationfield patch? thats exactly what it does, subclasses bigint instead of int |
| cleifer | i can store timedeltas but when i retrieve my fields' value i get integers - just wondered if i needed to write a descriptor to convert that int to a timedelta or if i could do it in a hook when it loads from the db |
| cleifer | Adys, yeah i've looked at it, hot stuff! |
| Adys | but iirc it's something with from_python method |
| pr3d4t0r | ubernostrum: Would you prefer a browser capture or a paste? It's long. |
| Action: pr3d4t0r assumes that paste is OKi and that HTML formatting won't get messed up. |
| Adys | cleifer: but yeah basically you convert the value from int to timedelta in from_python |
| cleifer | yeah, i've got it going in, it's the reading the int from the db that i need to hook |
| pr3d4t0r | ubernostrum: http://eugeneciurana.com/pastebin/pastebin.php?show=42566 - here's the complete output as I see it on the browser. |
| intranation | pr3d4t0r: return HttpResponse(output.render(None)) |
| intranation | You want None to be {} |
| Adys | cleifer: ill brb, will check the patch in 5 mins |
| cleifer | Adys, thanks a ton! |
| intranation | If I came late and guessed correctly |
| Adys | cleifer: out of curiousity, any reason why you can't just use my patch and subclass it to use int? |
| cleifer | Adys, i don't want to patch django, we need to run on 1.1 |
| Adys | ah right |
| pr3d4t0r | intranation: Ah! |
| cleifer | so with your field, if I do obj.duration = timedelta(seconds=300), obj.save() -- then i reload shell, obj.duration == 300, or obj.duration == timedelta(seconds=300) ? |
| pr3d4t0r | intranation: Thanks a bunch - it makes sense. |
| intranation | Contexts always need to be a dictionary |
| intranation | because the key part of it is the variable name in the template |
| pr3d4t0r | intranation: Got it. It makes perfect sense. It needs an *empty* dictionary :D |
| pr3d4t0r | intranation, ubernostrum: Thanks.. |
| pr3d4t0r | Man, do I feel stupid right now... |
| intranation | pr3d4t0r: it's just one of those things you get used to after using Django for years... ;) |
|
|
| EyePulp | any way to allow a model manager to be passed an argument? I need to get a queryset back in a few different places using some vars from the request object, and I'd like to pass the request to a model manager to help with filtering |
| EyePulp | it just seemed cleaner, at least, to work it through a model manager. |
| cleifer | Adys, i got it figured out |
| cleifer | i needed to use the SubfieldBase metaclass on my field |
| visik7 | hi |
| visik7 | anyone using gocept.cxoracle with djangorecipe ? |
| cleifer | that ensures that to_python gets called |
| ubernostrum | pr3d4t0r: yeah, you always render a template with a Context object. |
| ubernostrum | pr3d4t0r: as covered by the Django documentation, which may be a good next stop... |
| pr3d4t0r | ubernostrum: I'm reading it - just had a mental fart thinking "I'm not passing anything to this one yet" so I used none instad of { } :\ |
| Action: pr3d4t0r hangs his head in shame. |
| pr3d4t0r | s/none/None/ |
| Adys | cleifer: ah |
| Adys | yeah fields are a bit complex |
| cleifer | yeah i forgot about subfieldbase |
| cleifer | luckily django's docs kick ass |
| cleifer | *plug* |
| fabiant7t | hi! |
| fabiant7t | anyone knows of an existing app providing me with sth. like an if_app_installed template tag, if_app_intalled decorator and an is_app_installed method? |
| atoi | is there any way to eagerly load certain connections along a foreign key? That is... is there a way to User.objects.filter(x=y) and have the extra relation loaded up so when I memcache the resulting set the relation is cached too? |
| Pentheus | Hello everyone. I have a really large app with a bunch of "app/models/__init__.py" files that load each model in the models directory so that they're picked up by syncdb and such. This is causing a huge issue with circular imports since an import from app.models.file.FileClass results in hitting the __init__.py which triggers an import * basically |
| bparker06 | atoi: select_related() |
| atoi | bparker06, awesome, I'll search the docs. :) Thanks. |
| Pentheus | Is there something I can do to get django to pick up all these files in the models directory without creating an __init__ file spelling out an import for each model class within each model directory |
| Pentheus | (which I believe is the cause of my circular import issue) |
| subsume | hrmz |
| dankles | Pentheus: you mean your app's code is doing the import from app.models.file.FileClass ? |
| Pentheus | Yes |
| subsume | if __init__ is importing everything and nothing is impotring __init__, then there shouldn't be circs. |
| Pentheus | I do like so: |
| Pentheus | from app.models.file import FileClass |
| Pentheus | which (from the traceback) |
| Pentheus | appears to trigger the __init__ in that directory |
| atoi | "Note that, by default, select_related() does not follow foreign keys that have null=True." |
| dankles | So what's the actual error? |
| fabiant7t | Pentheus: why do you need to import * in your __init__.py? |
| atoi | I wonder if there's a way to change that default behavior. |
| Pentheus | I have "from file import FileClass" for each file within the __init__.py file in order to get django to see all the models |
| Pentheus | for syncdb, etc. |
| fest | this problem has been bothering me as well- I just created a huge models.py file as a temporary workaround |
| fest | and as we know- nothing is more permanent than temporary solutions :/ |
| fest | Pentheus, you might try to structure your apps so that no two applications depend on each other's models |
| Pentheus | Thats impossible for me though |
| subsume | seems like poor design then. |
| Adys | or, smart use of python which you haven't thought about? |
| Adys | I hate people classifying everything as poor design because it's not the intended use |
| Pentheus | This is an example of the Traceback, showing the __init__'s triggering imports leading to circular imports |
| Pentheus | http://dpaste.com/170154/ |
| subsume | yeah. I classified everything as poor design. No dude. I classified one thing as poor design. |
| Adys | that said, you should look into using a proxy abstract class living elsewhere, and subclassing it once for each of them |
| Adys | subsume: you classified something as poor design without knowing what the design actually is |
| subsume | Whatever you say. |
| subsume | Pentheus: nobody needs to see a traceback about your circular imports. What you need to do is take a comb to that nasty project. |
| Pentheus | And what would this comb do? |
| subsume | Stop making things depend on one another. Its a basic thing to avoid in python. |
| subsume | I don't see how this is even related to you __init__.py stuff. |
| subsume | you/your |
| Pentheus | I never had circular dependency issues before working with Django, this seems to be a pink elephant in the room that everyone ignores |
| hoink | wheel-reinvention prevention: simple contact form design pattern?: I'm noobing with Django, creating a textarea-and-send-button contact. Any urls for Known Good ways to do this? |
| Pentheus | Some people don't want agiant models.py |
| bparker06 | I never had to put anything in an __init__.py |
| subsume | Pentheus: well, you can reference other models by using a string. |
| dankles | hoink: ubernostrum has one |
| Pentheus | Only when they are in the same file, Subsume |
| subsume | Pentheus: Wrong. |
| Pentheus | Ok, tell me how? |
| dankles | hoink: http://bitbucket.org/ubernostrum/django-contact-form/ |
| subsume | Pentheus: ForeignKey('youjust.Do') |
| bparker06 | Pentheus: you can use 'appname.somemodel' |
| Pentheus | I don't understand what that buys me |
| subsume | heh. |
| bparker06 | no circular dependencies |
| subsume | righton buddy. |
| Pentheus | As soon as I do that Django complains that the class (youjust.Do) is not later defined |
| subsume | Is that a string?? |
| Pentheus | I'm saving a bit on the typing |
| Pentheus | I know about quoting FKs |
| subsume | Hmm. Never heard of it. |
| Pentheus | "asset.networkportcloud: 'node' has a relation with model Node, which has either not been installed or is abstract." |
| Pentheus | surprise. |
| BrianHV | why would a url field give me a "This URL appears to be a broken link" error even though I can access the link through a browser? |
| hylje | Pentheus: works fine for me, cross-app or not |
| subsume | Pentheus: no idea what you're talking about. paste models. |
| bparker06 | Pentheus: you are still referring to 'node' by importing it, and not via string |
| Pentheus | No, this is pure FK stringage |
| subsume | paste. |
| Sonderblade | what does "IntegrityError: current transaction has been aborted, all commands ignored until the end of the transaction" mean and how do you end the transaction? |
| subsume | BrianHV: cause your pattern is off? |
| zerok | BrianHV: is perhaps the dns on the server not configured? |
| subsume | oh duh. probably that. |
| Pentheus | http://dpaste.com/170160/ |
| zerok | BrianHV: if you want to disable that check, set verify_exists=False in the field definition |
| subsume | Pentheus: typically when you paste, you actually include what the person told you to apply. |
| Pentheus | What am I missing subsume? |
| subsume | the app label? |
| bparker06 | all the other models? |
| subsume | the whole point? |
| bparker06 | lol |
| BrianHV | zerok: I can wget the link from the server... but I'll try verify_exists |
| Pentheus | sigh |
| intranation | Pentheus: you want server = models.ForeignKey('appname.models.ServerCloud') |
| visik7 | anyone know how to add a zc.recipe.egg:custom into the extra-paths of djangorecipe ? |
| intranation | Pentheus: basically anything that'll pass the conditions for __import__, here: http://effbot.org/zone/import-confusion.htm |
| Pentheus | Just tried it with the app label |
| BrianHV | zerok: verify_exists worked. thanks. |
| zerok | BrianHV: wierd. django only tried to open the url with urllib2 :-/ |
| Pentheus | It was difficult to weed the actual help out of the snide remarks |
| Pentheus | Thank you subsume, all the same :) |
| Pentheus | and et al |
| subsume | No problemo. =). |
| Pentheus | works perfectly |
| BrianHV | zerok: aah, that gives me a clue. urllib2.HTTPError: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop. |
| zerok | ah ^_^ |
| phretor | hi, why does ModelForm.clean() does not get called from AdminModel subclasses? |
| machrider | is there a django-esque way to implement a job queue (like, sending out emails asynchronously)? |
| visik7 | solved |
| subsume | phretor: did you connect it to the modeladmin? |
| subsume | machrider: cron ? |
| SilverSiR | Hey guys how can i specify which django version an app uses. I have two on my system 1.0 and 1.1.1. Right now it's defaulting to 1.1.1 but I want it to use the 1.0 version |
| phretor | subsume: the clean? |
| intranation | machrider: at my work we use RabbitMQ with a Django management command |
| intranation | YMMV |
| bparker06 | I agree there is lots of 'superior ego' flying around here usually |
| subsume | SilverSiR: in dev server |
| subsume | SilverSiR: ?? |
| SilverSiR | yes |
| SilverSiR | just running python manage.py runserver |
| subsume | lol. I am far from superior but I know how to link a model via a string pretty goddamn reliably. |
| machrider | subsume: ideally something that would work on win32 too |
| bparker06 | but that's a common theme with open source people |
| machrider | intranation: thanks, i'll take a look |
| bparker06 | subsume: and others don't |
| subsume | SilverSiR: PYTHONPATH=/home/you/whatever/ python manage.py shell where whatever contains your alternate django |
| bparker06 | which is why they come here for help |
| bparker06 | not to get yelled at |
| zerok | machrider: there are a couple, but probably the most robustness you'll get out of some combination with some amqp server libe rabbitmq. celery offers a nice interface for that |
| machrider | related question: can django handle two threads accessing the ORM simultaneously? |
| machrider | producer consumer style |
| intranation | machrider: dumb/easy way would be to have a model which stores commands and fetch the jobs out of that |
| subsume | bparker06: well yeah, but when they don't listen and tell you 'they know' they need a chop down. |
| phretor | is there any special way to implement a ModelForm's clean() for use in an AdminModel subclass? |
| bparker06 | subsume: I still don't agree with how you handle most people's questions |
| bparker06 | I think it's completely rude |
| bparker06 | unnecessarily |
| subsume | Whatsamatter with a little good cop bad cop |
| bparker06 | it makes people /quit |
| bparker06 | lol |
| subsume | haha, yeah right. I really doubt I've ever chased anyone off their problem. |
Popular searches: