Re: Django Development Server Root URL...

2013-06-04 Thread Sam Solomon
Daniel is correct. One more point though, there are cases where you may want to use the full url instead of just "/django_project/", in which case, you should use settings.BASE_URL or {{ request.get_host }}. To use either of those in the template, the template would need to be rendered with a R

Re: current transaction is aborted, commands ignored until end of transaction block

2013-05-30 Thread Sam Solomon
Hmm, yeah, Ryan could be onto something, but that doesn't really help figure out the root cause (which likely was an error that existing before upgrading but just went ignored). What should help get to the root issue is checking out the postgresql log file (for me: /var/log/postgresql/postgresq

Re: [Bulk] Re: Template Inheritance doubt

2013-05-20 Thread Sam Solomon
If you are mainly using this for splitting stuff into multiple files, here is what we do to accomplish the same thing but keep it so that templates always inherit base.html instead of sidebar.html: base.html: {% extends 'header.html' %} {% block main %} {% endblock main %} header.html: {%

Re: unique not working as expected

2013-05-10 Thread Sam Solomon
My guess is that unique=True was added after the table was created using syncdb. I'm guessing that most companies that use Django professionally use South ( http://south.aeracode.org/) to make schema changes easier. Without South, you would have to keep the database in sync with the code manual

Re: Installing django-allauth

2013-05-02 Thread Sam Solomon
Hello, What version of allauth are you trying to install and where did you get it from? https://github.com/pennersr/django-allauth/tree/0.10.0/allauth/socialaccount/migrations is the most recent version on pypi and has more than 2 migrations. Could it be that you have another app installed th

Re: How do I display image in admin list?

2013-04-15 Thread Sam Solomon
Oh and I just noticed you added "Also, some images could be blank/None" Instead of 'if obj.id:' you can simply do 'if obj.id and obj.photo:' On Monday, April 15, 2013 10:52:11 AM UTC-7, Sam Solomon wrote: > > One small correction, in 'list_display'

Re: How do I display image in admin list?

2013-04-15 Thread Sam Solomon
One small correction, in 'list_display' it should be 'admin_photo' (or I'd probably put 'display_photo' (see #1 below)), not 'photo'. Some other tricks: 1) If you don't want to clog up your Model class, you can put the function in your ModelAdmin class. 2) If you add "readonly_fields = ('displa

Re: should we develop apps based on urls?

2013-04-12 Thread Sam Solomon
Yes, it's okay to just try stuff out locally, but one word of caution, after everything is working and before you deploy the code, it's probably a good idea to review any "lets see how this looks/works" code/decisions to make sure it still makes sense. Once a URL is in the wild, it's annoying t

Re: [SPAM] Implementing User login expiration

2013-04-09 Thread Sam Solomon
Depending on if the expiration is a temporary thing or if you actually want to permanently deactivate the user, this may be even simpler and database efficient (and is what we use to ban users): class DeactivateUserMiddleware(object): def process_request(self, request): if request.us

Re: Creating a admin-field, containing checkboxes. The data of this fields is stored in the string format

2013-04-08 Thread Sam Solomon
Not sure exactly what the issue is, but this may be handy (either as a replacement or as an example of doing something somewhat similar): https://github.com/disqus/django-bitfield I believe on most machines the maximum is 63 "flags" though so you will likely only be able to use it as an example

Re: I screwed up my django site using touch

2013-03-08 Thread Sam Solomon
Here is something that may help: import importlib from django.conf import settings for app in settings.INSTALLED_APPS: views_name = "%s.views" % app try: importlib.import_module(views_name) except ImportError: pass except: print "Could not import %s" % vie

Re: Extending the base file depending on User type

2013-03-06 Thread Sam Solomon
Tom Evans has probably the correct answer for you, but another thing that I've done (maybe not 100% applicable in this case) is to have a default base and then make it extendable from views when necessary: {% extends base_template|default:"base.html" %} This sounds like it isn't applicable in y

Re: StreamingHttpResponse into a Template

2013-02-28 Thread Sam Solomon
Not sure if this is what you meant by "we'll probably keep the javascript reloading to process junks, waiting for the support of celery", but one option without celery is to have the initial request save a bunch of "PendingEmail" objects in the database and then redirect you to a "send_queued_e

Re: Django and mod_wsgi serving different apps from separate virtual hosts on the same server

2013-02-07 Thread Sam Solomon
2073>), > so you never know. > > Thanks again. I appreciate your time. > - Rob > > On Feb 7, 2013, at 1:15 PM, Sam Solomon wrote: > > Regarding having WSGIDaemonProcess outside of vhosts, as explained in the > comment I added, it allows you to use the same process to handl

Re: Django and mod_wsgi serving different apps from separate virtual hosts on the same server

2013-02-07 Thread Sam Solomon
Regarding having WSGIDaemonProcess outside of vhosts, as explained in the comment I added, it allows you to use the same process to handle requests from multiple vhosts. As for the rest, I honestly don't remember why or where they came from, I just know that this is probably not all that common (m

Re: Django and mod_wsgi serving different apps from separate virtual hosts on the same server

2013-02-07 Thread Sam Solomon
Can't spot any issues but here is what we have to run multiple staging versions of our site: group_* names are more descriptive in the actual settings WSGIDaemonProcess group_1 processes=1 threads=100 display-name=%{GROUP} inactivity-timeout=30 #defining it out here allows you to use the same

Re: Insane sql logging

2013-01-15 Thread Sam Solomon
The word "Insane" caught my eye and lo and behold it was relevant to what we've done. We actually do this for security reasons and it does help with debugging sometimes (we actually log all queries, not just INSERT/UPDATE/DELETE). We also store fk to user (with a pre_delete hook to unattach use

Re: What's your opinion about nested apps?

2013-01-12 Thread Sam Solomon
I agree, the simple approach may be good for some things, but we have a highly complex tightly coupled main app that for us, we believe it's easiest to keep bundled together. If we add/write new, more generic apps to our site, we would obviously consider adding it as an app in the "project/" folder

Re: What's your opinion about nested apps?

2013-01-12 Thread Sam Solomon
We've not had any trouble and we have a very nested structure: project/main_app/sub_apps/ project has manage.py, main_app has main urls.py, etc. sub_apps have models/views/urls, etc. We also have: project/main_app/utils/other_apps/ with no issues (and utils and other_apps both have models, ev

Re: Django-MongoDb deployment at production servert

2012-12-11 Thread Sam Solomon
I'm guessing that the problem is there are many ways to deploy Django so it's hard for anyone to give a good one-size-fits-all answer and also hard to run down the complete list of possibilities, and I'm guessing that since this list is only viewed by a small percentage of Django users, that the

Re: Help with manage.py sql

2012-12-03 Thread Sam Solomon
I'm guessing that for some reason the classes in your app/models.py are not set up correctly, are you sure you inherit from models.Model in your class(es). Example: from django.db import models class MyModel(models.Model): rather instead of : class MyModel(): If it doesn't inherit models.Mod