logo
IRC Archive / Freenode / #django / 2009 / December / 13 / 1
gasull
djszapi: I don't know about django-piston, but if you export to JSON you will be able to put it back in any DB.
djszapi
what's the problem with south ?
tiglionabbit
how do I run a python script in the django environment?
apollo13
django has no environment?!
al you need todo
is set DJANGO_SETTINGS_MODULE correctly
gasull
After fixing several problems I'm back to my original one: I'm adding a new application to my project but syncdb isn't adding it. It's in my apps directory and it's in INSTALLED_APPS. What am I missing? Thank you.
Powerplay
guys anybody familiar with haystack / whoosh? Just installed it and it works fine. Though i want to use the code from the search template in another template but the tags {{ form.as_table }} fails to display
gasull
how do you add django_extensions to INSTALLED_APPS in settings_local
?
ericholscher
gasull, INSTALLED_APPS += ('django_extensions')
gasull
ericholscher: NameError: name 'INSTALLED_APPS' is not defined
ericholscher
gasull, you need to import it
gasull, there should be blog posts showing how to do this
gasull
ericholscher: I'm using the method explain in the Django wiki
ericholscher: I have this at the end of my settings.py: http://dpaste.com/132561/
ericholscher: So I cannot import settings from settings_local because there would be an import loop
ericholscher
gasull, with that approach you can only override the previous settings
gasull
ericholscher: I got it from here: http://code.djangoproject.com/wiki/SplitSettings Do you advise any other approach?
ericholscher: How do you split the settings?
PhreeStyle
have a question about legacy db integration. My db has almost every table's primary key mapped to a varchar field, yet it also had autoincrement fields for every table and all the tables refer to each other with the varchar primary keys, not the autoincrement field. Django won't let me set models up to use the varchar primary fields, so I told it that the auto increment fields were the primary keys. How would I go about defining t
^robertj
is ther a way to register more than one ModelAdmin per model?
sako
which package had shell_plus
gasull
sako: django_extensions
andre_pl
when defining a field for use in a modelform, where is the code which actually puts the database value into the field when the form is bound?
i have defined a custom ModelChoiceField which when given an integer, uses a strange convoluted means of finding the correct model instance (its not the PK) when saving a new modelform with this, it looks it up correctly and populates the ForeignKey Field in the model with the correct PK (not the value the user entered), but when using the modelformset giving it a queryset which it uses to populate the forms, it is putting the value in
somedavid
i created a function that checks if a form field has certain illegal characters, is there a way to add that to all my form fields without having to define a bunch of clean_<field> methods
ideally, i would just be able to pass a variables with the field definition that lists the illegal characters for that field
and be able to define a custom error message using the same error_messages
oban
how can i get the filename of an uploaded image from a form?
i have image = request.FILES['image']
name = image['filename'] raises an error
'InMemoryUploadedFile' object is unsubscriptable
digilord
When using a model that is based on a ContentType model how do you do a filter?
oban
oh it's image.name
digilord
Does anyone work with ContentType models?
nemith
what the recommend way of doing a rest api? Anyone have a favorite app?
EntityReborn
Erm, is this right? page = Wikipage.objects.get(cleantitle=title, id=pid)
i want BOTH fields to match
digilord
EntityReborn: Yeah that would do it
EntityReborn
Well, apparently it's not working.
in my app, I am using urls such as http://localhost/wiki/edit/Who_are_we_:3/ where Who_are_we_ is the sanitised title, and 3 is the DB id.
Right now, I can change 3 to any number, and it shows the same page.
digilord
I don't think a : is valid in a URL
EntityReborn
good point.
digilord
http://localhost/wiki/edit/Who_are_we_/3/ is prob what you want
nemith
you can use ;
EntityReborn
I'll change that :P
digilord
BAH! I am so bloody close!
EntityReborn
<digilord> http://localhost/wiki/edit/Who_are_we_/3/ is prob what you want
thats exactly what I'm going to do
phretor
is ubernostrum around?
I am looking for someone to discuss Chapter 11 of Practical Django Projects and, in general, about how to maintain, deploy django-powered websites in painless way.
groken
i'm trying to use has_changed() on a form to see if the initial data that was provided to the form has been modified and should be saved again but it appears that has_changed() is always true if the form is not empty. my view is here: http://dpaste.com/132593/
lastk
wich the best and more easy webserver to use with django? the server inclused himself dont work for access of another Ip
digilord
lastk: I use Apache with Django
EntityReborn
K, I have a link in my template, <a href='{{ page.editurl }}'>Edit this page</a>. in my model I have said function, editurl(self) that contains return "/wiki/edit/" + self.cleantitle + "/" + self.id + "/". Yet, when said template is rendered, the url is not what editurl returns
lastk
digilord : there is conflit with apache+php? another thing.. using apache I need extra config for serve static files?
EntityReborn
lastk, the docs mention serving static content fairly clearly
digilord
lastk: I have PHP on the same server with no ill effects. http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ is what I used to setup Apache
EntityReborn
look up deployment
saikatc
if i have a standalone python script that runs as a daemon, do I need to manually cleanup objects that access my database using django? I've been noticing that my program is leaking memory, but if i just remove areas where i update database rows, the leaks go away.
or at least, the leaks get lesser
lastk
EntityReborn : I'm reading it now
pax-
I'm using letting users submit content using tinymce, it outputs html, is there a good way of makeing sure only "safe" html tags gets written in the template? I don't want to use |safe
nemith
you can probably call the same "safe" method on your models save method
lastk
digilord : I was thinking in use a lighthttp instead apache, is more 'light' lol, but apache is good too
pax-
nemith: what?
nemith: that won't stop users submitting bad html code?
EntityReborn
any ideas into the problem I mentioned?
nemith
from django.utils.safestring import mark_safe
pax-: no it won't
ahjoht
hi, anyone know if it's possible to sort an InlineAdmin by a certain column?
don't think the internal class has a parameter for this
ethereal
anyone? here have an opinion on dream host?
phretor
how do you manage to install applications that do not provide setup.py ?
digilord
I have http://paste.debian.net/53844. I have tried a number of things and can't seem to get the filter to be built. I know the code as it stands doesn't work unless I hardcode in the filter. Can anyone help me?
pax-
nemith: so, do you understand my problem? i want to specify what which html tags that the template should write as html and which it should escape
-what
ethereal
say phretor install where?
phretor install where?
gah
how embarrassing
phretor
ethereal: I mean, how do you work on Django apps/sites in general?
pax-
ethereal: sudo python setup.py install
ethereal
yeah,
can you do that with dreamhost
?
pax-
have you got root access?
phretor
pax-: that's not easily reproducible and will require a lot of deployment efforts.
ethereal
where should i host then?
webfaction seems nice
but its in the uk
wrong continent
phretor
virtualenv + pip would be lot better - I am trying to find a good combination of hg + virutalenv + pip + fabric to manage it all automatically.
ethereal
pip?
obscure
ethereal: webfaction has servers throughout the US as well.
ethereal
easy install replacement
phretor
hg to version the code, virtualenv to create self-contained and reproducible environments, pip to install packages in a clean way, fabric to deploy remotely.
ethereal
hmm
jezdez
ethereal: http://pypi.python.org/pypi/pip
obscure
I have a webfaction account too, dreamhost pretty much sucked for me.
slow
obscure: webfaction is great imho
ethereal
ive never heard a bad review of webfaction, how is this possible?
obscure
yep
phretor
ethereal: they are very good indeed.
ethereal
so your using fabric to automate your deployments
what does that have over doing raw file operations?
phretor
ethereal: not yet, because I haven't found a good way to layout my django applications. Note that I am trying to move towards a project-less development. I.e., a django project is actually an application.
ethereal: I found the ubernostrum book's Chapter 11 illuminating about this.
ethereal
oh, so everything will be an app under one django instance
i was thinking about that
phretor
ethereal: no, say that you are about to create a site with django.
ethereal
say phretor and then...
phretor and then...
phretor
then you create a virtualenv, you pip-install your requirements and then you create one app per piece of your site. Then each of those apps are installed as requirements into your virtualenv and so forth...
lastk
hey, I'm trying to configure the django with lighttpd and I have a question: " "socket" => "/home/user/mysite.sock", " this file should be changed to my project dir?
JohnnyL
while trying ### render_to_response("index.html", {'clients': Client.objects.get referrer__iexact=request.user.get_profile().referrer)}) ###i get: Exception Value: (1054, "Unknown column 'credit_borobeatsiteprofilerecord.referrer_id' in 'field list'") Where does the extra _id come from?
lastk
*line
mattmcc
It's the field that holds the FK reference in your model.
So, since it's missing, your table and model are probably out of sync.
JohnnyL
FKs *have* to end in _id?
mattmcc
No, that's just the default behavior.
It's a very old DB design practice.
JohnnyL
I feel like Marcellus Wallace after he gets raped... Nah man.. there ain't no more django.db.models.Q and you. And if you _id me, you stay gone.. or.. you be gone.. DEAL?
pjs
hahah
groken
how do i set the initial data on a bound form so that has_changed tells me if the form data is different that the initial values?
pjs
classic scene in a great movie
mattmcc
You're being more absurd than usual.
JohnnyL
I can't wait until SQL gets back in style.
mattmcc
Don't hold your breath.
The next step for DBs will be non-relational storage, which SQL isn't any use for.
Besides, even when it was 'in style' SQL still sucked.
JohnnyL
mattmcc thats where we agree to disagree.
mattmcc
In any case, nothing stops you from doing all your DB interaction with raw SQL in Django.
1.2 will even make it easier with raw()
JohnnyL
ok
thats good.
ยป
mattmcc
http://docs.djangoproject.com/en/dev/topics/db/sql/#topics-db-sql
JohnnyL
happy happy!
pax-
I need to modify data that users are saving, is a custom save() method or the pre/post_save signal the way to go?
I was thinking either of these, but run into problems with both: http://dpaste.com/132617/
erm, line 5 and 6 should be self. and not id.
EntityReborn
hm
I'm getting <bound method Wikipage.url of <Wikipage: sstest>> in my urls
I have a url function in my model, and call it like return HttpResponseRedirect(page.url)
mattmcc
Then you probably want to call the method.
EntityReborn
how so?
mattmcc
Well, right now you're passing a reference to the method itself to HttpResponseRedirect.
EntityReborn
oh
well, adding a () to the end gives me a TypeError coercing to Unicode: need string or buffer, int found
and using a variable instead of directly calling it in HttpRR doesn't change anything
mattmcc
Sounds like an unrelated problem, but most likely you have a __unicode__ method that isn't returning a string.
EntityReborn
def __unicode__(self):
return self.title
title = models.CharField(max_length=30)
thats in the model
mattmcc
The traceback would probably be informative.
EntityReborn
gimme a sec
http://pastebin.com/d739ed4fd
url is defined as such:
def url(self):
return '/wiki/' + self.cleantitle + '/' + self.id + '/'
ah
would I need to convert the id?
yes, thats what it was
mattmcc
Yes, you can't concatenate strings and ints. But you should use string formatting anyway, not concatenation.
This isn't PHP, after all.
EntityReborn
:P
Point
how would I do string formatting?
gasull
Hi. Debugging my view with ipdb I get this error: http://dpaste.com/132618/ Why form.id_valid() but I have no form.clean_data? Thank you.
EntityReborn
As I've mentioned, I'm fairly new to python
mattmcc
'/wiki/%s/%d/' % (self.cleantitle, self.id)
EntityReborn
oh
thanks :)
mattmcc
Dive Into Python is a good read.
airstrike
mattmcc: just don't say that in #python or someone might eat you alive
mattmcc
Well, that's their problem.
EntityReborn
mattmcc, that actually explained other problems I was having with templates, as well
thanks :)
gasull
If form.is_valid() is True, then form.clean_data should exist, right?
mountainswhim1
is it possibly to perform an outer join in django without resorting to raw sql
sontek
what are some of the best blogs to read for django stuff?
I have Leah Culver, Surfing in Kansa, Jannis Leidel, Eric Florenzano, and mountylounge right now
mattmcc
sontek: I would just keep your eye on the aggregator, and see who you find interesting.
ubernostrum
(Action) should write something.
sontek
mattmcc: is there an rss feed for the full /community/ setion?
I didn't see a link for it
section*
ubernostrum
Yes.
http://www.djangoproject.com/community/
Has an autodiscovery link.
sontek
yeah, chrome doesn't know how to use those so I usually hope the site has a link, i'll just grab it from the source
ubernostrum
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss/community/" />
Chrome needs to learn how to use them.