2008-8-3

23:10 FunkyBob
well, I would expect a pattern something like BEGIN ; INSERT INTO foo VALUES ( ( SELECT MAX(id)+1 FROM foo ) .... ) ; COMMIT;
23:10 PhantomsDad
django 0.96.2 Errors on the call to form.save()
23:10 FunkyBob
PhantomsDad: using which database?
23:10 javagamer_
How am I supposed to be able use admin.site.register? At the moment I have it at the bottom of my models.py, but when I import models.py it gets called and again and it gives me this error "AlreadyRegistered: The model StationMapping is already registered". How should I handle this?
23:11 PhantomsDad
FunkyBob: mysql
23:11 FunkyBob
ah, Mysql
23:11 mattmcc
javagamer_: Are you using autodiscover?
23:12 davidcramer_
FunkyBob: ya thats what I would have done, but i need to return the id as well
23:12 javagamer_
mattmcc: No, I was loosely following the tutorial and I didn't see any mention to autodiscover. How should I be using it?
23:12 jonesy
Is there some reason I cannot extend the ErrorList class in django.forms.util?
23:13 javagamer_
mattmcc: Now I see it. Thanks.
23:13 jonesy
I am using a Model Form and I want to get back text only errors, no bs ul/li list
23:14 mattmcc
jonesy: The Form class takes an error_class argument.
23:14 jonesy
this is what I have setup: registrationform = RegistrationForm(request.POST, error_class=DivErrorList)
23:14 javagamer_
mattmcc: Wait. I have admin.autodiscover() in urls.py. Is there something else I should do/somewhere else I should put it?
23:14 jonesy
it calls my function which extends the ErrorList class
23:20 blips
http://mysite.com/admin gives a 404 but .../admin/ works. why?
23:20 spool
hi, I'm getting a really strange error from code that used to work: http://dpaste.com/69221/
23:20 javagamer_
Add a / to the end
23:20 spool
blips: check your urls.py
23:21 mattmcc
blips: Have you set APPEND_SLASH to False in your settings?
23:21 blips
mattmcc: aah maybe
23:21 javagamer_
Whenever I try to import an object from models.py I get "AlreadyRegistered: The model StationMapping is already registered". What does this mean and how do I prevent it?
23:22 blips
mattmcc: im using the default install.. should I add append_slash = false to my settings.py?
23:22 spool
javagamer_: it might have to do with registering for the admin site
23:23 mattmcc
blips: No, if you don't have it set, the default is True. Which means it would redirect requests that don't end with a slash, unless you don't have the common middleware enabled.
23:23 blips
mattmc: what can I do then?
23:23 javagamer_
spool: The code is almost exactly from the tutorial, could it be related to my import statement "from models import StationMapping" in views.py?
23:24 spool
javagamer_: no that should be fine. registering is not the same as importing
23:24 spool
javagamer_: sorry I haven't looked at the new version of the tutorial, (since major changes have recently been applied) what page are you on?
23:25 blips
http://dpaste.com/69222/ here is my apache <location> thingy, and my urls.py am I doing something wrong?
23:26 spool
javagamer_: have you added
23:26 spool
javagamer_: mmm ok hold on
23:26 javagamer_
spool: Well, I just remade my app and refollowed the tutorial up to page 3, at which point I just copied over the bits of code which looked like they hadn't changed.
23:26 rozwell
javagamer_: that can happen as a result of importing your models in multiple places using different import paths
23:26 rozwell
javagamer_: such as relative imports
23:27 javagamer_
rozwell: So, do they all have to be absolute? Or can I just change any absolute paths to relative paths?
23:27 rozwell
javagamer_: always use absolute paths
23:27 jonesy
this is fucked up. Some of my fields come back as text like they should and other default to the standard ul/li
23:27 javagamer_
rozwell: Alright. I just thought that relative paths would give me more flexibility. Thanks.
23:28 rozwell
javagamer_: they can lead to trouble down the road
23:28 spool
rozwell: would that explain a registering problem?
23:28 rozwell
spool: yes
23:28 javagamer_
rozwell: Thanks for the advice.
23:29 spool
rozwell: fair enough... is this where the magic of admin.autodiscover() comes into play?
23:29 javagamer_
rozwell: It works now. :)
23:29 rozwell
spool: admin.autodiscover() tries to import an admin module from all INSTALLED_APPS
23:30 rozwell
spool: and usually admin.py contains the admin.site.register(blahblah)
23:30 rozwell
spool: which would "magically" register the modeladmin with your admin site
23:31 spool
rozwell: so why do you need admin.site.register _and_ autodiscover?
23:31 rozwell
spool: so you don't have to explicitly register modeladmins
23:31 rozwell
spool: that is on a per-project basis
23:32 spool
rozwell: I guess I'm asking why would you use admin.site.register and autodiscover at the same time (as suggested in the tutorial)?
23:32 rozwell
anyway, the alreadyregistered bit comes into play if you keep the admin.site.register bits in your models.py
23:32 SmileyChris
spool: you don't *need* autodiscover - it's just a convenience rather that putting the "register" commands in your models.py (helps keep it a bit more loosely coupled, too)
23:33 rozwell
spool: because if you didn't you'd have to import the model admins and register them for each 3rd party app and your own apps somewhere in your project
23:33 rozwell
spool: autodiscover looks for the admin module of each installed app package so you don't have to explicitly import it
23:34 spool
rozwell: ahhh, so I can take it out of __init__ like I used to?
23:34 rozwell
it's generally best to keep modeladmin registering out of your models.py and certainly out of your __init__
23:34 rozwell
keep them in the admin module of your app package
23:34 spool
rozwell: no, I used to import admin in __init__
23:35 rozwell
i don't know why the tutorial tells you to put the register bit in models.py
23:35 rozwell
i guess to keep it simple
23:35 rozwell
anyway, the exception has to do with how python imports/namespaces work
23:36 rozwell
and you can run into similar problems with registering signal handlers with the dispatcher for example
23:36 spool
rozwell: before nfa landed you had to import admin.py somewhere, and originally they suggested doing it in __init__
23:36 rozwell
so it's best to learn how python imports/namespaces work
23:36 keseldude
for determining whether the menu item is active, should I create an inclusion tag and pass the current page name?
23:36 rozwell
spool: i see
23:37 spool
rozwell: but autodiscover seems to have fixed that problem
23:37 rozwell
keseldude: if it just results in style changes i would just do it with css
23:38 keseldude
if I wanted to show the current page's menu item in a different color, I could do that in just css?
23:38 rozwell
keseldude: certainly, just give the body element a class
23:38 rozwell
keseldude: and use descendant selectors appropriately
23:38 spool
rozwell: incidentally... do you have any ideas for my problem? http://dpaste.com/69221/
23:38 keseldude
oh yeah
23:38 rozwell
keseldude: i usually have a block for the body class which i override as needed
23:39 mattmcc
Or an id, since it'll be unique.
23:39 keseldude
hm, thank you :)
23:40 rozwell
mattmcc: not necessarily
23:41 rozwell
spool: not really, other than an integer field is getting set to an empty string
23:41 rozwell
spool: at least that's what it looks like on first glance
23:41 spool
rozwell: yeah, that's what I was afraid of
23:41 spool
rozwell: thing is, that code worked a week ago
23:43 rozwell
spool: well work through the traceback
23:43 rozwell
spool: or use pdb
23:46 blips
ADMIN_MEDIA_PREFIX = "/media/ where does this lead to? user/mysite/media/ or user/media/
23:48 webar7
is there a django based on line spreadsheet/db manager sort of thingie like dabbleDB?
23:48 spool
rozwell: yeah I've been trying to use pdb. Thing is I'm only calling the save method on a new object, so of course the id should be null.
23:48 marcos_
blips: that leeds to /path/to/trunk/django/contrib/admin/media/
23:48 webar7
I was reading about how such an application would be bundled in django ?!?!?
23:49 wmealing1
webar7: url ?
23:49 spool
rozwell: so I'm not sure what to look for
23:49 spool
rozwell: if it makes a difference: http://dpaste.com/69223/
23:50 webar7
for dabble? ?
23:50 webar7
the summer of code 2006 suggestions page had : "add dabbledb (http://dabbledb.com/utr/) like functionality to the django admin. e.g. create a project and super user with one command line statement, fire up the development web server, and import/create/refine your model using live data from directly within the django auto admin."
23:51 webar7
23:51 blips
marcos_ : i dont understand?
23:52 webar7
I think dabble uses another easy build web app framework based on smalltalk or something
23:54 webar7
wmealing1, mentioned on http://code.djangoproject.com/wiki/SummerOfCode... just wondered if someone did that :)
Page 24 of 25   ← Previous  Next →(2,426 total)