free blog   apache   shopping directory   php powered
airstrikeyou import the class, create an instance and then magic happens
ameobaSo, I'm looking at http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser and wondering how, under the hood, threads are handled.  Are they recycled or does each request get a new thread?
JohnnyLI get: >>> r = test_api.TestAPIUsage >>> r.test_aim_calls <unbound method TestAPIUsage.test_aim_calls> >>> r.test_aim_calls() Traceback (most recent call last):   File "<stdin>", line 1, in <module>TypeError: unbound method test_aim_calls() must be called with TestAPIUsage instance as first argument)
synicJohnnyL: you either have to create an instance of TestAPIUsage or declare the method as static
JohnnyLr is the instance
synicr isn't an instance
synicr is trying to capture the return value of the function
reesefrancishow can I unregister models from the admin site? I've created an admin.py and I have to unregister them
igorsreesefrancis: admin.site.unregister(MyModel)
jim---Couldn't you just remove them admin.py?
Powerplayandym, hmm tried the initial in the form without succes http://dpaste.com/150905/
andymPowerplay: you read the docs on this?
Powerplayandym, http://docs.djangoproject.com/en/1.0/ref/forms/fields/#initial
Powerplaythat[ what i read
andymwhich is completely different from your code :)
andymforms.ForeignKey?
Powerplayandym,  i think it's the ForeignKey field that gives the probnklem
Powerplayexactly
whatupderekis there a way to have an inline for a UserProfile?
Powerplaybut this is the model     blog = models.ForeignKey(blog)
whatupderekwhere UserProfile is an inline for User
Powerplayandym, what do you reckon for the primary key?
sachman64I thought I remember reading somewhere that you have to have both the project path and the project's parent path on sys.path to make things work. Is that true? I think I'm getting some weird behavior because of that
subsumedepends on how you set things up
subsumewhatupderek: an inline...... sure.
subsumePowerplay: what do you mean 'reckon'?
whatupderekit's saying something about nothing having a foreign key to the user model
subsumewhatupderek: well... does your userprofile have an FK to the user model?
whatupderekbecause the 3rd model is related to UserProfile
whatupderekyeah
subsumethird model?
whatupderekyeah
subsumethird model?
JohnnyLsynic thanks, I tried the following implementation but still have not had success... http://code.activestate.com/recipes/52304/ <--- is this even valid??
Powerplaysubsume, reckon as in think
subsumePowerplay: think what?
JontyDjango svn is complaining about a CSRF token not being there, but I've not turned on protection using middleware or decorators. What's going on?
apollo13JohnnyL: why not use @classmethod?
Powerplaysubsume, think about this 'hi what is the best way to pass a value from a view to a form? http://dpaste.com/150887/ '
subsumewhat's the best way to apss a value from a view to a form?
JohnnyLapollo13 not familiar with @classmethod, but I'll look into it. (can you guys recommend a good book on python?)
apollo13python in a nutshell by alex martelli
apollo13at least if you know another programming language
Powerplaysubsume, yup, or alternatively predefine a value in a form
apollo13it surely isn't a tutorial style book, more like a reference (but again not really a reference, somewhere between ;))
subsumePowerplay: why?
Powerplaysubsume,  to avoid bothering users with difficult questions
JohnnyLapollo13 looks good.
subsumePowerplay: ... can you explain what you're trying to do ?
Powerplaysubsume, so I'd like to create different html links and render the same form with predefined values
subsumeyour code snippets and your description make no sense.
subsumecreate different html links and render the form with predefined values makes no sense
Powerplayok
subsumeyou make no sense. try again.
Action: JohnnyL high fives apollo. thanks!
JohnnyLworks
Powerplaysubsume, well this is the model http://dpaste.com/150915/ and the forms works perfectly well. Though there is a dropdown for the posts to attach them to a blog
subsumeok
subsumeso exclude the fields you don't want
Powerplaysubsume, so i exclude 'blog' but it[ a required field :)
subsumeok, so pass in its value to the form and override form __init__ and set it manually in a save override
Powerplaysubsume, ok that makes sense
subsumewhen you make sense, I make sense.
mad_moseshi, i wrote a templatetag which returns a number, i can use it in my templateengine with {% mytemplatetag %}, but i want it in a if construction like {% if "3" > {% mytag %} %} but this throw an error, what can i do?
subsumenot that.
subsumeyou can update the template's context
mad_moses<- ?
subsumebasically you set the context dictionary key to be whatever value
subsumeand you can use it later in the template
subsumebut what is this mytag tihng returning?
subsumeas in, why does the templatetag have this value, but the view doesn't?
subsumewhy not just pass it in from view
mad_mosessubsume, becauce i use it on all pages and i wont edit all my views
subsumemaybe use a middleware then?
subsumewhat's the difference between editing all your views and editing all your templates?
mad_mosessubsume, i never write a middleware
subsumeok
subsumewelp, you do now.
mad_mosessubsume, i can put mytemplatetag into  my base.html and it will print on all pages
subsumewhat is this thing you want to print?
mad_mosessubsume, an attribute of a model
subsumemodel.get_attribute doesn't work?
subsume{{ model.some_method }}
subsume{% if "3" > model.some_method %} ....
mad_mosessubsume, good idea, i will try, thank you
eric6rmHi I have a question about deployment with nginx/apache using SSL
eric6rmI have nginx recognizing the SSL certificate and passing onto apache
eric6rmand on Apache, I'm using mod_python to serve Django
eric6rmI think I'm supposed to somehow pass information from nginx to django so it will pass a secure response
eric6rmbut I'm not sure how to do this
subsumedjango doesn't know or care if its SSL
eric6rmsubsume: I was under the impression that if it received a secure request, it would create a secure response
subsumeyour webserver is in charge of that
eric6rmsubsume:  what I'm assuming is that, in the Apache virtual host settings, I need to check if the request from nginx is secure, and then pass some info to Django
subsumeOh I heard you.
subsumethe answer is no
subsumeeven the virtual host doesn't care if its 'secure'. it just listens on 443
LiberumIs there a way to modify the queryset used in a ForeignKey field in the admin depending on the request?
eric6rmsubsume: maybe that's the problem?  I have nginx listening on 443 and passing the request to Apache listening on 8000
subsumeeric6rm: why this complex setup anyhow?
armorsmith42if I have a model with two foriegnkeys and I instantiate it with two instances of that model, is is supposed to automatically grab the keys of both, or just the first one.?  I seem to be observing the latter.
kennethlovei keep getting an error about django being unable to load a custom auth backend, but i've disabled that backend, restarted the server several times, and cleared all .pyc files. any help?
subsumearmorsmith42: ...huh?
eric6rmsubsume:  I am trying to make a Django site work with an SSL certificate, and the Django site uses nginx to serve files.  Is that particularly complex?
subsumeeric6rm: i don't understand the relationship between nginx and apache. and i don't understand why you're using mod_python
eric6rmsubsume:  here's the whole story:  I needed to move a Django site onto a Windows IIS server (yeah.. I know :( ).  The only way to get Django to work on Windows, afaik, is to use mod_python.  I use Apache to serve Django and nginx as a reverse proxy, serving static files and redirecting Django-related requests to Apache.
joerghi
subsumei see
armorsmith42I've instantiated this model  user_ing = UserHasIngredient(user=profile,ingredient=result) and, going through the server transation code in pdb I print user_ing.__dict__, which is {'user_id': 5, '_user_cache': <UserProfile:  >, 'amount': None, 'ingredient_id': None, '_ingredient_cache': <Ingredient: vodka>, 'time': datetime.datetime(2010, 1, 26, 17, 51, 31, 853970), 'units': None, 'id': None}
subsumewelp, that solves it then
joergis it easy to extend the admin interface?
armorsmith42hello joerg and welcome!
subsumearmorsmith42: maybe result is indeed None
joergI mean if I use different auth methods with django e.g. LDAP it would be nice if I could manage users there.....stuff like that
joergarmorsmith42, thanks ;)
armorsmith42that would indicate that the vodka, which does exist in the database, does not have an id
subsumearmorsmith42: result == None
joergI mean.....should I code a django app that can manage ldap users from scratch or try to somehow extend contrib.admin?
armorsmith42no,  result =  <Ingredient: vodka>
armorsmith42this would be tragic otherwise
subsumearmorsmith42: does it have a pk?
armorsmith42ah. no it does not. this indicates that the rabbit hole goes deeper. thank you
Powerplayis it possible to hide just one of the {{ foo_form|as_uni_form }} fields?
mattmccWhat do the uni-form docs say?
Powerplaymattmcc, no clear answer here http://github.com/pydanny/django-uni-form/blob/master/docs/usage.txt
LiberumDoes the exact functionality of ModelAdmin.formfield_for_foreignkey not exist for many-to-many fields?
Powerplaymattmcc, and this doesn't work http://dpaste.com/150930/ I know about the exclude in form option but I; m trying to avoid that and find a method in the template
rozwellLiberum: if you found that one, i'm not sure how you missed formfield_for_manytomany
Liberumrozwell: Heh, I guess ticket #11882 would explain - "Documentation missing for django.contrib.admin.ModelAdmin.formfield_for_manytomany" :) Thank you!
DjangoBothttp://code.djangoproject.com/ticket/11882
subsumeI've got a unit test which isn't loading a particular fixture, silently. what's probably wrong?
flagg0204im trying to test wether a transaction is an "UPDATE" or an "INSERT" in my django app.  I think I need to overwrite the save() method for my modelform.  But how can you test if something is an update/insert before calling the super(ModelForm, self).save()?
subsumeflagg0204: background?
flagg0204subsume - ??
subsumeor not.
flagg0204subsume - i dont understand the question
subsumepretend you do.
flagg0204subsume - and this is helpful why?
subsumewhat are you trying to do?
flagg0204i have a modelform and view to allow me to add and edit objects for that model.  I have a save() method in the modelform.  Im trying to figure out how to test whether a transaction is an update or an insert
synicflagg0204: if self.id is None, it's an INSERT
flagg0204synic - the model does not have an id column. it has a foreinkey to another table
synicoh wait, it's a ModelForm, nevermind.
flagg0204fk = domain
synicall models have an id column
mattmccobj.pk points at your PK field, whatever its name is.
flagg0204mattmc - ah isee
flagg0204so could you do if self.obj.id is None?
flagg0204for a test
subsumepk
subsumenot id
subsumebut yes.
flagg0204if self.obj.pk == None
flagg0204or if not self.obj.pk
flagg0204i guess either way works?
subsumeyou could do
mattmccEr, 'obj' is meant to be replaced with 'whatever your model object is'.
subsumeif self.pk in [None]
mattmccModelForms don't literally have an 'obj' attribute.
flagg0204mattmc - yeah i got that :)
flagg0204mattmc - just using it for an example.
flagg0204ill give that a shot.
flagg0204thanks
flagg0204interesting.  well bow django is complainging that my modelForm does not have an attribute pk
sachman64for adding apps to INSTALLED_APPS, can I do just 'app' instead of 'project.app'?
sachman64if the project dir is on sys.path
deorbitalhi
deorbitalcan someone please enlighten me how this should be used in a form? http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/
deorbitalfor the life of me i can't figure it out
cmwslwwouldn't it be taxing on the database to call something like Entry.objects.order_by('blog__name', 'headline')
cmwslwi'm guessing that in order to sort, the blog for every entry would have to be retrieved to get the name.
cmwslwor are databases fast at doing these sorts of things
olilandhow do you guys handle mobiles?
olilanddo you override your templates directory when someone arrives at your mobile site?
mattmcccmwslw: Depends on the table(s) and indexes.
cmwslwmattmcc: what if it was just a foreignkey to a model with an IntegerField? I'm deciding if I need to maintain copies of the integer in the model I want to sort to speed it up
cmwslwkeeping a copy is error prone and messy, but if my order_by is really slow it might have to be that way
mattmcccmwslw: Well, do an explain plan, see if it is slow.
mattmccAnd maybe indexing differently will help.
__machinewhat is currently the best way to replace or extend the User model? i don't just need to add different fields... i need to replace existing fields... username needs a longer max_length and to accept email addresses... and the other CharField should use a subclass of CharField that i have which when represented in a ModelForm will strip leading and trailing white space from the values before validation... ?
dfjoergAUTH_PROFILE_MODULE
mattmccA custom auth backend will allow you to authenticate users by email instead of username.
lawgonor by fingerprints
olilandor with social authentication
__machinemattmcc: so create my own User class with username, email, firstname, lastname and all other fields i need (using my subclassed CharField) and an fk back to django User model... and use custom auth backend to authenticate and return that user instead?
anteatersadoesn anyone know how to access request.user in models.py?
mattmccanteatersa: Generally, you don't.  Models shouldn't depend on the existence of an HTTP request to function.
mattmccThat's what views are for.
anteatersahmm, good point
anteatersawill put in admin.py, thanks
mattmcchttp://www.b-list.org/weblog/2008/dec/24/admin/
kennethloveis it possible to chain model managers? like i have active() that gets items marked as active and published before now. i'd like to have featured() that gets active items that are also featured w/o having to replicate the code of active(). is this possible?
anteatersaperfect cheers mattmcc
mattmcckennethlove: Well, do the functions return querysets?
kennethlovemattmcc: yes
mattmccSo, there you go.
symbioticsick post
kennethlovei'm sorry but i need a bit more than that. I've tried doing: return super(Model, self).get_query_set().active().filter(blah blah) but i get errors on get_query_set not having a method active().
mattmccWell, if your manager has methods active and published, and you want published to include the active filter, it'd just be 'def published(self): return self.active().filter(...)'
kennethlovehm, thought i had tried that but i'll give it another shot. thanks
Popular searches: opensolaris   install ekee ubuntu   how to change   opticon converter ttyusb0   alsa mixer inotify   

Generated by irclog2html.pl 2.1mg by Jeff Waugh - return