|
Yay posted:But much of the basics are the same (date oriented, facted content), only posts don't go in categories, they go in threads, and then the threads go in categories. Throw in multiple users, and you've got the rudimentary beginnings of a simple forum. You can probably get that far with the ORM and generic views. Right now I'm reading djangobook in the hope of being able to create something by myself at some point.
|
# ? Mar 7, 2011 21:22 |
|
|
# ? Jun 5, 2024 09:11 |
|
A couple of questions on how best to do things in django. I'm using model inheritance: code:
code:
Also there's some stuff that's on every page, like news articles in a sidebar. So I have code:
outside of a function in my views.py and just pass that into every render_to_response . Is there a better or more convenient way of doing that?
|
# ? Mar 12, 2011 13:56 |
|
Jabab posted:Also there's some stuff that's on every page, like news articles in a sidebar. So I have [...] outside of a function in my views.py and just pass that into every render_to_response . Is there a better or more convenient way of doing that?
|
# ? Mar 12, 2011 16:31 |
|
Jabab posted:
If you want to avoid raw sql, I believe you can name the child's ptr as such: code:
code:
http://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns Basically it would look something like this in your template code:
|
# ? Mar 12, 2011 17:09 |
|
Wulfeh posted:Basically it would look something like this in your template (I ignored the question about how to improve the view originally, as I was focusing on the SQL and what it'd return, rather than what it was actually used for. Sorry!)
|
# ? Mar 12, 2011 17:33 |
|
Thanks Yay, I ended up defining get_absolute_url in Article, NewsArticle, and Review.code:
code:
code:
code:
code:
|
# ? Mar 13, 2011 18:12 |
|
quote:Is there a one liner for: adding to a python dict object is just as easy as you thought code:
|
# ? Mar 13, 2011 18:21 |
|
Wulfeh posted:adding to a python dict object is just as easy as you thought Weird, I thought I tried this and the context only contained the 'updated' stuff. I must have mixed up variable names, because I tried it again and it works fine! EDIT: Also I got rid of my raw SQL using select_related Jabab fucked around with this message at 22:38 on Mar 13, 2011 |
# ? Mar 13, 2011 18:30 |
|
I'm needing a little help setting up a django site for public consumption. The project looks great accessed on my machine via the built in webserver, but I'm having trouble viewing it on my hosting server. I have hosting through lithium hosting and I think their instructions are a little out of date. I set up the .htaccess file in the appropriate directorycode:
However when I navigate to myurl/mysite1 I get an error: code:
|
# ? Mar 14, 2011 00:40 |
|
I've never used mod_python (it's deprecated and rubbisher), but I'm assuming [...]/django-code/ has a folder called 'mysite1' beneath it, with appropriate __init__.py?
|
# ? Mar 14, 2011 19:49 |
|
yea I'm not sure. I just went ahead and switched hosting to one that officially supports django to save myself a headache.
|
# ? Mar 15, 2011 23:13 |
|
code:
|
# ? Mar 18, 2011 20:59 |
|
nbv4 posted:
I believe it's because the queryset, unless you tell it otherwise, will add the model's default Meta.ordering to its query, and behind the scenes whatever fields are in the Meta.ordering will be added to the query and thus to the DISTINCT clause and you won't get the results you expect. Try: code:
|
# ? Mar 21, 2011 15:20 |
|
Whats peoples vibe on using passenger for serving django? The site seems to claim its a bit dicky, but people seem to be having good times with it too. Thoughts?
|
# ? Mar 23, 2011 09:15 |
|
Wouldn't touch it. Just use mod_wsgi or gunicorn behind nginx and be happy. ps: 1.3 is out
|
# ? Mar 23, 2011 17:12 |
|
duck monster posted:Whats peoples vibe on using passenger for serving django? The site seems to claim its a bit dicky, but people seem to be having good times with it too. Thoughts? Reasonably sure the only people using Passenger for its WSGI capabilities are those who want a single backend server running both Rails and Django child processes. Which probably isn't a ton of folks (Not zero...just not many.)
|
# ? Mar 23, 2011 18:39 |
|
I'm having an issue with logging -- anything emitted from views (normal circumstances, Apache + mod_wsgi) get's a duplicate entry. If I open a manage.py shell and manually import logging and issue a logger.info I only get one entry. My logging configuration is here: http://dpaste.com/525571/ Again, it's only for things that happen through apache -> mod_wsgi -> django that get duplicated.
|
# ? Mar 25, 2011 19:08 |
|
I want to get a Django intro book with some good, hands-on examples and walkthroughs. A little like Mining the Social Web by O'Reilly. I'm just about to pull the trigger on Django 1.0 Website Development. It's supposed to have some great examples, but I don't really know where to go for book feedback. Basically all Django books have so few reviews that they may as well all have been written by friends of the author. djangobook.com and all of those were too generic for my taste. They were good for installing everything, though, but the tone was incredibly tedious. And then there are the problem with obsolescence ... ufarn fucked around with this message at 22:59 on Mar 27, 2011 |
# ? Mar 27, 2011 22:51 |
|
I really enjoyed this one: http://www.amazon.com/Definitive-Guide-Django-Development-Right/dp/143021936X/ref=dp_ob_title_bk Lots of examples, good explanations.
|
# ? Mar 28, 2011 04:57 |
|
I'm sorta stumped. I just began building a work order system in Django, and for some reason every time I attempt to access the admin (in this case, at /manage), Django throws this error: ImproperlyConfigured at /manage/ Module "django.core.context_processors" does not define a "static" callable request processor django.core.context_processors.static is set in TEMPLATE_CONTEXT_PROCESSORS in my settings.py file. Anybody else seen this / any additional info I need to provide for diagnosis?
|
# ? Mar 28, 2011 23:05 |
|
Where the hell does the Django communities bizzare boner for Postgres come from? I'm having to use it due to postgis stuff, and good grief I've never encountered such a fragile database, and I've used many. Or is this fragile "look at it the wrong way and it explodes" thing just a postgis thing? Also anyone know wtf this error means? code:
It turns up all over the place, syncdb (which works with mysql flawlessly. However geodjangos mysql driver doesnt do distance_lte queries so its actually not useful for anything)does it, Trying to copy data with navicat does it, whenever theres postgis stuff. It just gets depressing after a while because I can't figure out, and rather than my nice south migration history that I used putting this together on the dev server, I'm fighting this loving thing tooth and nail. Django really needs to rethink its hostile attitude to mysql. At least it works. duck monster fucked around with this message at 08:28 on Mar 29, 2011 |
# ? Mar 29, 2011 08:24 |
|
Putting MySQL in the working category, that's cute. Just try: referential integrity at the same time as full text search, actually useful GIS queries, deferred constraints, optimizing queries using IN, the list goes on... The error you're seeing is because you got an error in your transaction and ignored it, once a transaction enters an error state it must be rolled back.
|
# ? Mar 29, 2011 12:54 |
|
Not to mention the licensing issues with bundling MySQL with your application.
|
# ? Mar 29, 2011 16:12 |
|
duck monster posted:Where the hell does the Django communities bizzare boner for Postgres come from?. python programmers love postgres
|
# ? Mar 29, 2011 23:14 |
|
The progression from MySQL to PostgreSQL is like the progression from PHP to Python or Ruby. You won't know why you ever put up with what you used to.
|
# ? Mar 30, 2011 00:54 |
|
A A 2 3 5 8 K posted:The progression from MySQL to PostgreSQL is like the progression from PHP to Python or Ruby. You won't know why you ever put up with what you used to. Conversely you'll run into a lot of problems that stem from bad habits that MySQL lets you get away with.
|
# ? Mar 30, 2011 01:59 |
|
king_kilr posted:Putting MySQL in the working category, that's cute. To clarify;- "Isn't broken". quote:Just try: referential integrity at the same time as full text search, actually useful GIS queries, deferred constraints, optimizing queries using IN, the list goes on... syncdb is a black box. And for reference, I've tried putting DISABLE_TRANSACTION_MANAGEMENT = True in the settings.py It still implodes bitching about the transaction. quote:root@debian:/home/don/yacht# ./manage.py syncdb The SQL (and parameter tuple) is in there because I dropped in code in the cursor execute code to print the queries to the console while trying to find where in djangos code its imploding. For reference this happens on both the mac when I try and syncdb to an empty database, and on the debian box. The macs 8.3, debian box is 8.4. Both djangos are 1.3 Its using the geodjango code. The thing syncs perfectly on mysql AND spatialite, but neither appear to support distance queries as I need them. e: If anyone wants to have a look at this and fix it, I have money to spend and a client going loving batshit at me because I cant get this working on the server duck monster fucked around with this message at 05:13 on Mar 30, 2011 |
# ? Mar 30, 2011 04:39 |
|
Have you tried manually running that query to see if it's giving you an error message? edit: And just so you know, there is a good chance that mysql works just fine because mysql does not invalidate the current transaction when it encounters an error where postgres throws the error and do not run other query until the current transaction is not aborted. edit2: More information if you can provide it would be helpful, settings.py, models.py. I don't know what your app is exactly, and how much you can share but anything you can provide in that realm can help. Profane Obituary! fucked around with this message at 05:31 on Mar 30, 2011 |
# ? Mar 30, 2011 05:19 |
|
Do you have a module doing database interaction upon being imported during Django's bootstrapping? I'm p sure the syncdb management command is not generating the second query in your debugging output. If you have an empty database, then obviously that query is going to fail (thus causing the transaction to be aborted); the tables don't exist:code:
entr0py fucked around with this message at 05:48 on Mar 30, 2011 |
# ? Mar 30, 2011 05:36 |
|
entr0py posted:Do you have a module doing database interaction upon being imported during Django's bootstrapping? I'm p sure the syncdb management command is not generating the second query in your debugging output. If you have an empty database, then obviously that query is going to fail (thus causing the transaction to be aborted); the tables don't exist: FOUND IT. I had a bunch of registration code (content types + tagging) in the models.py (cos I dont know where else to put it), and that was busting its arse. But mysql/sqlite wasn't bitching cos it seems to be a silent failure, and msql/sqlite are not quite as paranoic about transaction integrity. Where SHOULD I put those?
|
# ? Mar 30, 2011 06:49 |
|
Depending on what exactly your registration code is doing you could make a function that does that, and call it from within urls.py that should work just fine.
|
# ? Mar 30, 2011 14:32 |
|
Apparently I have some sort of mental block that prevents me from understanding relational databases. Right now I have a model that looks like this: code:
Right now, a ModelForm is generated that shows a multiselect with a list of users in it, and I can submit the form and all that fun stuff great. However, I can't access the users. The User model is just Django's built in one. Any time I try to pull a list of users out of the database (e.g., code:
Trying to call "assigned_to_set" in any shape or form anywhere returns an error saying it doesn't exist too. I'm trying really hard to wrap my brain around it but so far this is the only major Django roadblock I've not been able to figure out myself. DICTATOR OF FUNK fucked around with this message at 18:07 on Mar 31, 2011 |
# ? Mar 31, 2011 18:04 |
|
root beer posted:problems So if you have an instance of your Order class, you can access its related users through the assigned_to attribute. code:
|
# ? Mar 31, 2011 19:46 |
|
EDIT: I am an idiot.
|
# ? Mar 31, 2011 19:57 |
|
^^^^^^^^ OK then
Lamacq fucked around with this message at 20:06 on Mar 31, 2011 |
# ? Mar 31, 2011 19:59 |
|
Lamacq posted:So if you have an instance of your Order class, you can access its related users through the assigned_to attribute. I'm using MySQL; I'm beginning to think that this might be a sign of a deeper problem. Any way this could be MySQL's fault? EDIT: I of course changed your code to fit mine. I didn't just copy and paste as-is
|
# ? Mar 31, 2011 20:12 |
|
Another thing! Using a Django 1.0 book. Things have obviously changed since. I am given this code: code:
I get that I need to include something CSRF-related, but I'm not sure about the details. (Especially considering that I'm at the very start of a Learning Django book. Help?
|
# ? Mar 31, 2011 20:22 |
|
root beer posted:I really appreciate this, and it helped my understanding, but it still doesn't work. some_order.assigned_to.all() is blank, and it looks like no matter how many work orders I create and assign (via my ModelForm), the orders_order_assigned_to table Django generated for the ManyToManyField stays blank with user_id and order_id columns. I guess I don't know what you mean by "blank". some_order.assigned_to.all() should at least return an empty list. Are you sure the order instance you're working with in the interactive interpreter is the same one you're updating via the form? (I'm assuming you're using "./manage.py shell" to play with your django models in the interactive interpreter)
|
# ? Mar 31, 2011 20:24 |
|
ufarn posted:Another thing! My advice is just to use RequestContext(request) on each of your render_to_response calls, like so: code:
|
# ? Mar 31, 2011 20:25 |
|
|
# ? Jun 5, 2024 09:11 |
|
ufarn posted:csrf problems http://docs.djangoproject.com/en/1.3/ref/contrib/csrf/ Long story short: add a {% csrf_token %} template tag inside your form element. e:f,b
|
# ? Mar 31, 2011 20:25 |