2009-7-27

22:21 andym
flaccid: show us the code
22:22 keithphilpott
trying to get django and mamp to work together on leopard for development. anyone know of a better guide than the first results on google?
22:22 andym
don't use mamp, everyone who's come on irc with it has had loads of trouble
22:22 visik71
using runserver ?
22:22 keithphilpott
ok
22:23 flaccid
andym here is my code http://dpaste.com/72143/
22:33 Fragsworth
how can you access a model field object, given a model?
22:33 Fragsworth
I mean the base class, I want to inspect the properties of the field
22:33 mattmcc
obj._meta.get_field_by_name('foo')[0]
22:33 Fragsworth
mattmcc: thanks
22:44 flaccid
im doing a widget = Widget.objects.get(unique_hash=hash) and then later on a success i do extra_context = { 'widget' : widget.values() } and it says 'Widget' object has no attribute 'values' . where am i going wrong on that i can't just do widget = Widget.objects.get(unique_hash=hash).values() because i need to use the object for another query on a related model?
22:45 mattmcc
flaccid: values() is a method of QuerySet, get() returns a single model.
22:45 mattmcc
Or were you thinking of the values method of a dictionary, which a model isn't?
22:45 flaccid
right well i'm wondering how i should be doing this..
22:46 flaccid
i query one model to get a result and then use that result object to query a related model and i need to export the values to the template
22:47 mattmcc
Which values?
22:48 flaccid
the first query's values, but if i do widget = Widget.objects.get(unique_hash=hash).values() i obviously can't use this for the second query
22:49 Navies
AlexanderSupertr: Says nothing thee
22:50 Navies
AlexanderSupertr: there*
22:52 AlexanderSupertr
Navies: i thought they talk abt modifying migrations there
22:54 AlexanderSupertr
basically you ahve to modify migrations by hand in that case
22:54 AlexanderSupertr
have*
22:55 AlexanderSupertr
that was the default method before v0.5
22:58 AlexanderSupertr
Navies: here the eg. http://dpaste.com/72149/
22:58 AlexanderSupertr
but why wouldn't you just use --auto??
22:59 flaccid
mattmcc could you point in me in the right direction
23:04 SmileyChris
flaccid: the first query will return a single dictionary containing the values of that one widget [which, by the way, is an annoying name to use because it makes djangoites think of form widgets] - how do you expect to be able to use this to query a related model?
23:05 SmileyChris
flaccid: it's hard for people to point you in the direction when you haven't clearly explained where you're going ;)
23:05 flaccid
i'll rename it to web widget then
23:05 SmileyChris
is this the actual name, or are you just confuscating the model name you are really using?
23:06 flaccid
the model is called Widget and i have WidgetHit, i want to query Widget with a condition then query the related model WidgetHit with that result object ie. a widget hit has a widget id. then i want to put the values of widget in context for template
23:06 SmileyChris
flaccid: you mean you want to put the widget instance into the context?
23:07 flaccid
well the widget values for use in templating
23:07 SmileyChris
flaccid: if you just pass the Widget instance, you'll have access to all it's fields
23:08 flaccid
yes but then how do i get that instances values to put in context for template
23:09 SmileyChris
flaccid: uh, {{ widget.your_field_name }} ?
23:10 flaccid
SmileyChris yes
23:11 SmileyChris
flaccid: what do you mean "that instance's values"?
23:11 flaccid
so are you saying in view, i can do widget = Widget.objects.get(unique_hash=hash) extra_context = { 'widget_foo' : widget.bar_field } ?
23:15 mib_mib
question - when i'm importing a javascript in my base.html, i use a relative src, i.e. src="media/js/global.js" -- i extend base.html in another template myprofile.html (which is at url /myprofile) but now looks for the source at /myprofile/media/js/global.js - why is it changing the relative path?
23:15 SmileyChris
flaccid: no, i'm saying you do extra_context = { 'widget' : widget }, then in the template you do {{ widget.bar_field }}
23:16 SmileyChris
mib_mib: because you're using a relative path
23:16 flaccid
doesnt like that SmileyChris, let me get the error
23:16 SmileyChris
mib_mib: so don't do that ;)
23:16 mib_mib
smileychris: so it isn't relative always to the root?
23:16 SmileyChris
mib_mib: no, that wouldn't be relative
23:16 mib_mib
weird, okay
23:16 mib_mib
i don't like hardcoding urls in there though
23:16 SmileyChris
mib_mib: so use {{ MEDIA_URL }}
23:17 mib_mib
SmileyChris: ah i like that - do i need to include anything to use that? RequestContext?
23:17 andym
mib_mib: perhaps you want to put a / at the front
23:17 SmileyChris
mib_mib: it's in request contexts by default
23:17 mib_mib
okay nice
23:18 mib_mib
andym: hmmm yeah there isn't one there...maybe that will solve it as well...
23:18 SmileyChris
mib_mib: i prefer to leave MEDIA_ROOT and MEDIA_URL for uploaded content and use custom STATIC_ROOT/URL settings for my static content
23:19 flaccid
SmileyChris ah my bad! the problem was that i was trying iterate through it with a for template tag in the templates because before i was using values() . sorry to waste your time there..
23:19 mib_mib
interesting - yeah i have nginx hosting the static content anyway - you just like to keep them seperated? any point to that?
23:19 mib_mib
or just keep it organized/
23:20 SmileyChris
mib_mib: i prefer two different urls, so you could move static elsewhere if you wanted
23:21 mib_mib
interesting....yeah nice
23:23 Waleed
Can anyone tell me how to customize users interface, based on logged in user?
23:23 Waleed
like Facebook, or my Space
23:24 Waleed
I mean just the idea of approaching it
23:24 jNash
{% if user.is_authenticated %}
23:25 andym
write a view that does what you want, but please tell me you aren't doing that to the admin interface
23:25 point9repeating
waleed: you can put a foreign key relationship on the User model from any of your custom models
23:26 Waleed
I see, and dont worry, no I am not doing that to the admin interface
23:27 flaccid
ok im all good now, except for the fact that with the .save() it is still saving two records - one with an id and one without
23:27 jNash
{% if user.is_authenticated %} : sorry, pasted at wrong place was meant for other window
23:27 Waleed
i just have many users, where there will be default applications, but once they log in, their personal applications should appears
23:29 mib_mib
Waleed: check if they are logged in, if they are logged in, get their applications in the view, and pass them to the template
23:30 joshuajonah
Guys, cant find info on getting the model_name of an object help
23:31 joshuajonah
I don't know if it's "model_name" but you know what i mean, likely a meta option
23:31 Waleed
Ok. Cool, thanks guys
23:31 Waleed
I'll try this
23:32 chyea
here's the full explanation of the issue i was trying to explain on here the other day. it may make more sense if you just read it like this: http://groups.google.com/group/django-users/bro...
23:35 point9repeating
joshuajonah: <object>.__class__
23:35 joshuajonah
thank you point9repeating, made my night
23:35 joshuajonah
was killing me
23:36 point9repeating
joshuajonah: np!, you can use isinstance for a boolean check as well
23:37 joshuajonah
wait, can you give me a doc or a quick explaination on that?
23:38 joshuajonah
point9repeating: ?
23:39 dahunter3
Is there some plugin or something that allows an admin to modify CSS file colors etc via /admin/?
23:40 FunkyBob
only if you change your CSS files to be served by Django...
23:40 joshuajonah
Well, you could store them in a table but what you need is the code coloring and fixed width fonts in admin
23:40 FunkyBob
(though they're eminently cachable :)
23:40 mattmcc
Plenty of JS color pickers out there.
23:40 FunkyBob
dahunter3: you don't mean to change Admin CSS... just CSS in general?
23:41 dahunter3
FunkyBob: Just CSS in general. I was looking at something like django-css that allows CSS compilers... but nothing seems to integrate it into the DB and Django admin.
23:43 O_4
Is enabling site-wide caching as simple as adding the two middleware classes in the right place and setting CACHE_BACKEND to an appropriate path?
23:44 O_4
The cache directory I specified has been created, so I assume something is working, but there are no files in it.
23:44 point9repeating
joshuajonah: isinstance(<object>, <class>) returns Boolean
23:45 O_4
(this is filesystem caching, by the way)
23:59 flaccid
im doing a save() and its saving the record with a null id, what could i have done wrong ?
Page 23 of 23   ← Previous  (2,294 total)