|
Seconding fabric, and I know with apache + mod_wsgi in daemon mode, you just have to touch the .wsgi file for your changes to go live (which can easily be done via a fabric command). That said I'm thinking about moving from apache + mod_wsgi to nginx + uwsgi, since I'm already using nginx for my front-end server and I'm seeing occasional load spikes and memory issues that I blame on mod_wsgi (and I've read every last bit of documentation on it and tweaked every setting I can find for it).
|
# ? Dec 17, 2010 23:26 |
|
|
# ? May 31, 2024 06:51 |
|
Puppet + nginx -> apache -> mod_wsgi. The proxy might be overkill, but I worry less about killing things overall when I restart one particular site.
|
# ? Dec 17, 2010 23:40 |
|
Oh poo poo Fabric looks awesome as hell. Exactly what I was looking for, thanks!
|
# ? Dec 19, 2010 04:09 |
|
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).
|
# ? Dec 19, 2010 12:44 |
|
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
|
# ? Dec 19, 2010 20:43 |
|
Cross-posting this with the Python thread: I'm trying to dynamically load a class from a specific module (called 'commands') and the code runs totally cool on my local setup running from a local Django server. This bombs out though when I deploy to Google App Engine. I've tried adding the commands module's parent module to the __import__ as well with no avail (on either setup in that case). Here's the code: code:
Edit: and the clarify, it doesn't bomb out on the commands module. If I have a command like 'commands.cat' it can't find 'cat'. Ferg fucked around with this message at 17:50 on Dec 20, 2010 |
# ? Dec 20, 2010 17:46 |
|
I have a library i use for generating images, I am using it to display images in one of my views. It seems like django is caching the object created in the view, because when i send a request that should redraw the image completely there is old cruft from previous redraws around. E.g. in my views.py I have: code:
|
# ? Dec 31, 2010 22:48 |
|
unixbeard posted:I have a library i use for generating images, I am using it to display images in one of my views. Try this code:
|
# ? Jan 1, 2011 06:17 |
|
thank you, that didnt help but made me realize the problem was probably elsewhere. what i had was: code:
code:
i hadnt noticed it before because i had only been using it in separate programs that only ran once
|
# ? Jan 1, 2011 18:18 |
|
unixbeard posted:thank you, that didnt help but made me realize the problem was probably elsewhere. For what it's worth, this is because bar is a class variable in your example, you shouldn't put variables directly under the class def unless they are supposed to stay the same for every instance of the class.
|
# ? Jan 1, 2011 18:57 |
|
Profane Obituary! posted:For what it's worth, this is because bar is a class variable in your example, you shouldn't put variables directly under the class def unless they are supposed to stay the same for every instance of the class. yes thank you i had forgotten and was never quite clear on the difference. So would you say as a rule of thumb all per-instance variables should be declared & set up in __init__ ? also i thought class variables were normally accessed through Drawing.bar, and that if i was using self.bar it would be instance level? unixbeard fucked around with this message at 19:26 on Jan 1, 2011 |
# ? Jan 1, 2011 19:13 |
|
As a rule of thumb yea instance level variables should be assigned in __init__. I think (and on this i may be wrong), but ClassName.attribute vs self.attribute depends on how you want to access the data. ClassName.attribute will only ever get the attributes defined directly under the class whereas self.attribute will first access any instance attributes that may have been named the same, and then the class attributes. code:
This is a great trick for keeping a list of all instances of a certain class. code:
Profane Obituary! fucked around with this message at 20:17 on Jan 2, 2011 |
# ? Jan 2, 2011 19:22 |
|
how do you import models from an app in the management command folder? in appname/management/commands/something.py I want to import a model that is located in /app/models.py. Right now I'm doing from ..appname.models import MyModel. It looks ugly and was wondering how other people do this.
|
# ? Jan 5, 2011 11:52 |
|
code:
|
# ? Jan 5, 2011 11:55 |
|
I am working on a Django app at my company that is going to be using Generic Relations, are there libraries/resources that add functionality to the Django Admin with regards to Generic Relations? I found this but I was wondering if there was anything else? Also, anyone have experience with EAV-Django?
|
# ? Jan 5, 2011 22:15 |
|
I have a bit of a dilemma that I've been working on all morning. I have a Django app (displays statuses of many of our systems) that needs to interface with an external database updated by another application (Nagios). I wrote a controller that shims between this external DB and the rest of the app and mediates all access to it, and it generally works well. The problem arises in the admin interface when you want to add a new host or service for display in my app. The list of hosts was originally built as a choices on the CharField like so: code:
I first tried to fix it by subclassing ChoiceField into LazyChoiceField from a Django snippet I found that was supposed to cause the list to be lazily evaluated and moving the part where it generates the list into a ModelForm for the Host class, but that didn't actually change anything. The list is still generated fine, it just doesn't update when Nagios does: code:
code:
|
# ? Jan 10, 2011 19:43 |
|
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.
|
# ? Jan 10, 2011 20:27 |
|
Last page there was some discussion about automated tasks. I've been using django-chronograph for some fairly simple things and I like it. You set up a cronjob to hit chronograph admin command once a minute. Then it acts as a controller for other commands that you schedule via the admin web interface.
|
# ? Jan 13, 2011 22:05 |
|
Anyone ever encountred this. Happens the same in MySQL or Postgres (or more or less. Some sort of bitch-out about character lengths)code:
FWIW Heres my models: code:
|
# ? Jan 15, 2011 08:52 |
|
duck monster posted:Anyone ever encountred this. Happens the same in MySQL or Postgres (or more or less. Some sort of bitch-out about character lengths) Run "./manage.py sql" to create the SQL commands for all of the tables involved and you can see which one has a limit of 50.
|
# ? Jan 15, 2011 17:42 |
|
Captain Capacitor posted:Run "./manage.py sql" to create the SQL commands for all of the tables involved and you can see which one has a limit of 50. None of them code:
|
# ? Jan 16, 2011 00:58 |
|
I don't see anything wrong, but have you tried commenting out everything, and uncommenting and syncdbing them a couple at a time?
|
# ? Jan 16, 2011 09:51 |
|
I would guess the problem is the table code:
code:
According to django snippets, from a long time ago, you can try and run create_permissions from the shell with the following: code:
(The reason this is occuring, if it is the problem, is because as I recall, syncdb emits a signal for updating content types and permissions for new models) (Edit: confirmed for myself that auth's Permission model has a CharField which is 50 characters maximum) Yay fucked around with this message at 13:13 on Jan 16, 2011 |
# ? Jan 16, 2011 13:08 |
|
Bingo! By shortening the name of that table to the super descriptive 'DAIM' the migrations all run sanely without making GBS threads themselves. What a *stupid* bug. Its been reported to hell and back on the django bug tracker, but I see no evidence at all of it being either fixed or that there is any desire to fix it. Apparently it might break older code SOMEHOW. vv All I could really find was a cobwebbed bug tracker, and some douchebag developers pouring piss and venom on some poor newbie that tripped over it. duck monster fucked around with this message at 05:07 on Jan 17, 2011 |
# ? Jan 17, 2011 05:01 |
|
duck monster posted:Bingo! By shortening the name of that table to the super descriptive Was there nothing to be found in your database log?
|
# ? Jan 17, 2011 16:30 |
|
sink posted:Last page there was some discussion about automated tasks. I've been using django-chronograph for some fairly simple things and I like it. You set up a cronjob to hit chronograph admin command once a minute. Then it acts as a controller for other commands that you schedule via the admin web interface. I could easily just have a cron job that touches the WSGI script file, but I'd like to avoid that because of the long delay in page response when the interpreter is restarting and loading the Django app again. My problem is that once the object is initialized and it obtains this list of hosts and services from the external DB, that sticks around until the interpreter's destroyed. I can't find a hook to run something every time the admin form is loaded; __init__() only runs the first time the admin form is created. I really wish there were an equivalent to validate() that ran on form load so that I could stash the retrieval in there. I'll look into django-chronograph and see if I can schedule some way of doing it, but I'm not feeling real hopeful.
|
# ? Jan 18, 2011 20:31 |
|
chutwig posted:[...] I can't find a hook to run something every time the admin form is loaded; __init__() only runs the first time the admin form is created. Assuming the calls to the python nagios module you're using aren't cached, but are instead generated anew each time, could you not add the functionality to one of the ModelAdmin methods? I can't remember the method names, but I know you can override the change_form (or whatever) methods etc and add your required code, before calling super to render the original modeladmin stuff. That suff should get called each time, so might work. Could be kind of hacky, though. YMMV.
|
# ? Jan 18, 2011 21:40 |
|
Yay posted:Assuming the calls to the python nagios module you're using aren't cached, but are instead generated anew each time, could you not add the functionality to one of the ModelAdmin methods? I can't remember the method names, but I know you can override the change_form (or whatever) methods etc and add your required code, before calling super to render the original modeladmin stuff. I came across http://docs.djangoproject.com/en/1.2/ref/forms/api/#django.forms.Form.initial so I'm going to try implementing it that way. I may have also hosed up before when I was trying to insert the list into self.fields['name'].choices, so that's another option. I just need to steel myself enough to go back into the code and look at it.
|
# ? Jan 18, 2011 22:08 |
|
Mulozon Empuri posted:Was there nothing to be found in your database log? Nope!
|
# ? Jan 19, 2011 03:35 |
|
I am trying to create a simple blog application and I want to list all my blog posts along with all the categories that entry is associated with. My "Entry" model has a ManyToMany field called "categories" to make the connection. When I list my Entries using Entries.objects.all(), it will hit the database once PER ENTRY.. even if I have already obtained that category elsewhere. I understand why this is happening, but surely I can cache the results somehow? If I am showing 100 entries on a page, hitting the database 100 times to get each posts categories seems rather excessive. My actual query looks like this: "Entry.objects.all().select_related('author')" since I am also showing the authors information, and adding Entry.objects.all().select_related('author', 'categories') doesn't seem to help... it'd also be one hell of a query! Anyone have an ideas as to how I could improve on this?
|
# ? Jan 19, 2011 11:26 |
|
duck monster posted:Nope! Crazy. And you would think they would be able to change the exception msg without breaking anything.
|
# ? Jan 19, 2011 19:26 |
|
Hanpan posted:I am trying to create a simple blog application and I want to list all my blog posts along with all the categories that entry is associated with. My "Entry" model has a ManyToMany field called "categories" to make the connection. Querysets are supposed to be lazily evaluated, enabling you to stack various filters/etc before the db actually gets queried but I wonder if the order in which you are applying select_related could be causing it to not function as expected... So, just for grins: have you tried code:
code:
|
# ? Jan 21, 2011 01:00 |
|
Those 2 are equivilant in every way. You can't select_related a many to many (or any multivalued relationship).
|
# ? Jan 21, 2011 04:15 |
|
So my only real option is to create a dict of all the categories first and then obtain the data from that. Saves on a fair few queries so must be worth it.
|
# ? Jan 21, 2011 12:17 |
|
Is there any obvious way to get the GeoDjango map widget to display in a template. Everything I can find on Google at the moment seems to be about showing the wiget in an Admin panel. As the client put it; "Requiring customers to get full time employment to view the map is not exactly what we are aiming to do here!" Surely with this wiget being in there, theres an easy way to convince django to do this.
|
# ? Feb 1, 2011 07:52 |
|
I just learned that you can use custom queries to filter the list presented on a Model's Admin Change List view. Such as, code:
code:
So I have a two questions: 1) Is it possible for http requests like the one above to run through a custom ModelManager? 2) Regardless of the answer to #1, what section of the Django source is involved building QuerySets for responses to http requests like the one above? Fake edit: If '2) tell me what line teh codez is on' is too LMGTFY, any suggestions on how I should start looking for that section of code?
|
# ? Feb 2, 2011 00:13 |
|
Any comments on django-invitation versus django-privatebeta?
|
# ? Feb 2, 2011 00:35 |
|
This just in: tastypie kicks so much rear end compared to django-piston, I think I've found my weapon of choice when it comes to building apis.
|
# ? Feb 2, 2011 20:49 |
|
Mulozon Empuri posted:This just in: tastypie kicks so much rear end compared to django-piston, I think I've found my weapon of choice when it comes to building apis. Hell yes! I spent all morning wrestling with trying to fix a Piston bug. So sick of it.
|
# ? Feb 2, 2011 21:48 |
|
|
# ? May 31, 2024 06:51 |
|
Mulozon Empuri posted:This just in: tastypie kicks so much rear end compared to django-piston, I think I've found my weapon of choice when it comes to building apis. This actually looks a lot nicer than Piston, I'll most likely use it the next time I need to build an API.
|
# ? Feb 2, 2011 22:11 |