Re: Django Produces Python?

2017-03-26 Thread Ed Sutherland




I now understand the purpose and worth of Django. What, then, are 
the questions I need to ask potential hosts? I'm leaning toward Linode, but 
would also like affordable managed hosting. On Sun, 26 Mar 2017 04:16:52 
-0400  Lachlan Musicman wrote If you take James' answer 
and expand it a little, take a look at a Python micro-framework like Pylons 
http://pylonsproject.org/It's smaller than Django and is a useful tool for a 
different type of website.For instance take Authentication and Authorization - 
logins. Not every site needs one. Django has it by default. If you don't need 
it, maybe Pylons is a better fit. But be aware - when you have to actually 
write some code that makes user accounts and logins happen in Pylons, that's 
when you will discover that Django's "batteries included" philosophy really 
works for some style of projects.cheersL.--The most dangerous phrase in the 
language is, "We've always done it this way."- Grace Hopper On 26 March 2017 at 
15:52, James Bennett  wrote:Python is a programming 
language. You can use it to write many types of programs. For example, you can 
use it to write web applications (which run on a web server, respond to HTTP 
requests, store their data in a database, render HTML templates for output, 
etc.). But doing this from scratch would require you to write many modules of 
Python code yourself, in order to handle all the common and necessary parts of 
a typical web application.Django provides those things for you, already 
written, so that you do not need to write them yourself. Instead, you can write 
only the things which are truly unique to your specific application, and let 
already-written modules from Django handle the rest.--  You received this 
message because you are subscribed to the Google Groups "Django users" group. 
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com. To post to this group, send email 
to django-users@googlegroups.com. Visit this group at 
https://groups.google.com/group/django-users. To view this discussion on the 
web visit 
https://groups.google.com/d/msgid/django-users/CAL13Cg9n4Mk6W2QEG51yoY5cXn1tQ_N9ORhvv3k7GGCdW2Ob3A%40mail.gmail.com.
 For more options, visit https://groups.google.com/d/optout. --  You 
received this message because you are subscribed to the Google Groups "Django 
users" group. To unsubscribe from this group and stop receiving emails from it, 
send an email to django-users+unsubscr...@googlegroups.com. To post to this 
group, send email to django-users@googlegroups.com. Visit this group at 
https://groups.google.com/group/django-users. To view this discussion on the 
web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiO9QJ9N9%3DCj%2BsEnCsEn%2B02nwindxbzoYaxTY%2BV16vp%2BPQ%40mail.gmail.com.
 For more options, visit https://groups.google.com/d/optout. 






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15b0b36f07b.1074fa8d511956.6981836782800680358%40tburgnews.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Produces Python?

2017-03-25 Thread Ed Sutherland
Wow. I had thought Django as an assistant to build python projects. If I need 
the framework along with whatever language, it seems like immense code-bloat. 
What, then, is the purpose of using frameworks?







 On Sat, 25 Mar 2017 23:30:45 -0400 Lachlan Musicman 
data...@gmail.com wrote 




It will needs the Django as well. Think of them as layers - at the bottom is 
the OS, then there is python. Django sits on Python. Your project sits on 
Django. Can't remove a layer.


cheers


L.




--

The most dangerous phrase in the language is, "We've always done it this way."



- Grace Hopper







On 26 March 2017 at 14:19, Ed Sutherland e...@tburgnews.com wrote:









--

 You received this message because you are subscribed to the Google Groups 
"Django users" group.

 To unsubscribe from this group and stop receiving emails from it, send an 
email to django-users+unsubscr...@googlegroups.com.

 To post to this group, send email to django-users@googlegroups.com.

 Visit this group at https://groups.google.com/group/django-users.

 To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiMJo1ER7TFH2%3DGTLtvO%3Ds8ETKEGpYsUFCpVFOD_k_h4dA%40mail.gmail.com.

 For more options, visit https://groups.google.com/d/optout.




Forgive me if this question is too basic, but I'm a relative newbie to 
programming frameworks. As I understand it, a framework is built to abstract 
common tasks within the native language (Python, PHP, Ruby, etc.) When 
development using a framework is complete, will the production version of the 
app still require the framework? For instance, would an app developed with 
Django need only Python, or the entire programming framework? (I haven't seen a 
suitable answer after searching.)











--

 You received this message because you are subscribed to the Google Groups 
"Django users" group.

 To unsubscribe from this group and stop receiving emails from it, send an 
email to django-users+unsubscr...@googlegroups.com.

 To post to this group, send email to django-users@googlegroups.com.

 Visit this group at https://groups.google.com/group/django-users.

 To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15b089fd407.b63a65c5111765.2626315058617697641%40tburgnews.com.

 For more options, visit https://groups.google.com/d/optout.





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15b08efd9bb.fb7e1aec112788.7061965930651567288%40tburgnews.com.
For more options, visit https://groups.google.com/d/optout.


Django Produces Python?

2017-03-25 Thread Ed Sutherland
Forgive me if this question is too basic, but I'm a relative newbie to 
programming frameworks. As I understand it, a framework is built to abstract 
common tasks within the native language (Python, PHP, Ruby, etc.) When 
development using a framework is complete, will the production version of the 
app still require the framework? For instance, would an app developed with 
Django need only Python, or the entire programming framework? (I haven't seen a 
suitable answer after searching.)








-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15b089fd407.b63a65c5111765.2626315058617697641%40tburgnews.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations

2017-03-10 Thread Ed Sutherland
I certainly do. After a serious migration foul-up, I restarted the project. I'm 
now hoping there won't be a repeat. I wish there was a better way.





 On Fri, 10 Mar 2017 15:17:11 -0500 Matthew Pava 
matthew.p...@iss.com wrote 




Does anyone else get a migraine when working migrations?




--

 You received this message because you are subscribed to the Google Groups 
"Django users" group.

 To unsubscribe from this group and stop receiving emails from it, send an 
email to django-users+unsubscr...@googlegroups.com.

 To post to this group, send email to django-users@googlegroups.com.

 Visit this group at https://groups.google.com/group/django-users.

 To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/41f9ad6271964c208f3726a4fa28bfff%40ISS1.ISS.LOCAL.

 For more options, visit https://groups.google.com/d/optout.






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15aba027491.b0f3915884552.3533620237900856580%40tburgnews.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Migrations?

2017-03-01 Thread Ed Sutherland




The problem surrounded a textfield that had no default. I added the 
default string and migrate complained it was an int. I changed the string and 
migrate still complains of the int default that no longer exists. On Wed, 
01 Mar 2017 15:50:07 -0500  Melvyn Sopacua<m.r.sopa...@gmail.com> wrote  On 
Wednesday 01 March 2017 13:27:37 Ed Sutherland wrote: > I am a relatively new 
Django coder. I'm building a small custom CMS. > Whenever I get deep into 
development, I run into a migration problem: > an old error keeps halting newer 
migrations. I long ago fixed the > original error, but the migration continues 
to stop due to a now > non-existent error. I know I can rollback the migration 
to the last > successful attempt, but how do I prevent this in the first place? 
  Rolling back is destructive, so never a solution for production. How you can 
eliminate the error is largely depending on the error. --  Melvyn Sopacua-- 
 You received this message because you are subscribed to the Google Groups 
"Django users" group. To unsubscribe from this group and stop receiving emails 
from it, send an email to django-users+unsubscr...@googlegroups.com. To post to 
this group, send email to django-users@googlegroups.com. Visit this group at 
https://groups.google.com/group/django-users. To view this discussion on the 
web visit 
https://groups.google.com/d/msgid/django-users/1571910.2OvDCcMPjQ%40devstation. 
For more options, visit https://groups.google.com/d/optout. 






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15a8c7a865f.bbc68ab230650.7609245323262500789%40tburgnews.com.
For more options, visit https://groups.google.com/d/optout.


Django Migrations?

2017-03-01 Thread Ed Sutherland
I am a relatively new Django coder. I'm building a small custom CMS. Whenever I 
get deep into development, I run into a migration problem: an old error keeps 
halting newer migrations. I long ago fixed the original error, but the 
migration continues to stop due to a now non-existent error. I know I can 
rollback the migration to the last successful attempt, but how do I prevent 
this in the first place? Thanks.








-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15a8b20a733.f97315d281257.942488383471437686%40tburgnews.com.
For more options, visit https://groups.google.com/d/optout.


Admin Portal Help (Django Tutorial)

2015-01-21 Thread Ed Volz
I've been following the Django tutorial and cannot get the Admin portal to 
work.  Django is running via passenger in a shared environment on a virtual 
env with Python 2.7.  The main page and admin portal load static resources 
(from static_url) just fine.  Logging in with correct credentials yields a 
new session, but an error code of:

ERR_EMPTY_RESPONSE

An incorrect login yields the same error without a session.  Users are 
is_active and is_staff (verified through shell).  Any ideas?

settings.py 

passenger_wsgi.py 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9c8e8198-fe1a-42fe-acd5-3ecd04e75ae3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Strange Behavior from the Django Admin (following tutorial on a shared server)

2015-01-21 Thread Ed Volz
Hi all,

New to Django so I was following along with the tutorial and can get to the 
point of logging into the Administration portal (the main page works as 
well).  Django is running with passenger in a virtualenv (python 2.7) on a 
shared host.  I immediately receive a ERR_EMPTY_RESPONSE   when I click log 
in, regardless of whether or not the credentials are correct.  The db 
records a session on a correct log in even though the ERR_EMPTY_RESPONSE 
remains.  I've confirmed the user is both is_active and is_staff using the 
shell.  

What's puzzling me is that the log in page loads the css files from the 
STATIC_URL just fine, but there's nothing once served up the form is 
submitted.  Any help would be appreciated.

settings.py file 

passenger_wsgi.py file:
#!/usr/bin/env python2.7
import sys,os
# Tell Passenger to run our virtualenv python
INTERP = "/home//djangoenv/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
# Set up paths and environment variables
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = 'mynewsite.settings'
# Set the application
import django.core.handlers.wsgi
# Use paste to display errors
from paste.exceptions.errormiddleware import ErrorMiddleware
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
application = ErrorMiddleware(application, debug=True)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1d1bebac-af1a-4953-b088-73c2333d2a26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CSRF Failing after server upgrade.

2014-12-16 Thread Ed Rahn
Hello,
I get CSRF 403 errors intermittently while logging in. If I remove just the 
cookies for the site, it doesn't fix it. If I remove all the cookies on the 
browser or start in an incognito mode tab it works. Also some first time 
users get the error
Only my clients seem to be getting this, I have not been able to reproduce 
it locally.

This started happening after I upgraded from Ubuntu 14.04 to 14.10.

Can anyone help me debug this?

thanks
Ed


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cfcc3ed3-3d71-488b-9f8e-7f69ecf73997%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where does django store auth migrations?

2014-11-10 Thread Dr Ed
Hi Markus,

I don't really think it's the Custom model that's at fault here - this 
migration was created months ago. The point is that auth migrations are 
stored in, to my mind, the wrong place (in /Users//.virtualenvs/
/lib/python2.7/site-packages/django/contrib/auth/) and a separate problem 
revealed this to me. I've included a stack trace below though.

Cheers,

Ed

Running migrations:
  Applying 
auth.0002_customer_payingcustomer_projectmanager_staff...Traceback (most 
recent call last):
  File "./manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 385, in execute_from_command_line
utility.execute()
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/base.py",
 
line 288, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/base.py",
 
line 338, in execute
output = self.handle(*args, **options)
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
 
line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 63, in migrate
self.apply_migration(migration, fake=fake)
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 91, in apply_migration
if self.detect_soft_applied(migration):
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 135, in detect_soft_applied
apps = project_state.render()
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/state.py",
 
line 67, in render
model.render(self.apps)
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/state.py",
 
line 311, in render
body,
  File 
"/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/models/base.py",
 
line 155, in __new__
raise TypeError("%s cannot proxy the swapped model '%s'." % (name, 
base_meta.swapped))
TypeError: PayingCustomer cannot proxy the swapped model 
'emailcustomuser.User'.



On Monday, 10 November 2014 09:35:29 UTC+1, Markus Holtermann wrote:
>
> Hey Ed,
>
> you certainly don't have to copy the virtualenv over to production!
>
> Can you share some insights on your custom user model and your settings. A 
> complete traceback, if you have any, helps too.
>
> /Markus
>
> On Monday, November 10, 2014 9:00:04 AM UTC+1, Dr Ed wrote:
>>
>>
>>
>> On Sunday, 9 November 2014 14:50:54 UTC+1, Daniel Roseman wrote:
>>>
>>> On Sunday, 9 November 2014 13:40:12 UTC, Dr Ed wrote:
>>>>
>>>> Okay, I'm confused. I found it, in here:
>>>> /Users//.virtualenvs//lib/python2.7/site-
>>>> packages/django/contrib/auth/migrations
>>>>
>>>> Why are app related migrations being stored in this location?
>>>>
>>>> Cheers,
>>>>
>>>> Ed
>>>>
>>>
>>> What? Migrations related to Django's auth app are, not surprisingly, 
>>> stored alongside the code to that app. Why does this puzzle you? 
>>>
>>
>> I guess it's because I thought that we could build migrations on the 
>> development machines and then update the project on the production machine 
>> and apply the migrations. Obviously this assumption was wrong and we need 
>> to distribute the entire .virtualenv too... 
>>
>> Fine, if that's the way it is, that's the way it is, but to me this seems 
>> odd because everything else in there is just something you 'pip install' 
>> and I would not expect to mix 'user data' with 'installed packages' like 
>> this. It actually seems like an unfortunate design decision since it forces 
>> you - unless you try to be clever - to put django etc into the 
>> repository... we did this before and shifting to 1.7 was more painful as a 
>> result).
>>
>> Anyway, thanks for the reply!
>>
>> Cheers,
>>
>> Ed
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e03ee265-a97c-4680-9160-c39417c5885b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where does django store auth migrations?

2014-11-10 Thread Dr Ed
Yep, agreed. This is what I've done.

Thanks for the reply!

Cheers,

Ed


On Sunday, 9 November 2014 15:16:51 UTC+1, Cal Leeming [iops.io] wrote:
>
> Sounds like a bit of a weird edge case, I've had all sorts of problems 
> previously when moving to custom user models from an app with existing 
> migration data.
>
> Personally I'd say get rid of the migration data for that specific model 
> and re-initialize, it's just not worth trying to figure out why the magic 
> is broken (imho).
>
> Cal
>
> On Fri, Nov 7, 2014 at 8:50 AM, Dr Ed <edward...@gmail.com > 
> wrote:
>
>> Hi all,
>>
>> I feel a bit embarrassed even asking this question, because it must have 
>> an obvious answer... but when I do "./manage.py migrate -l" I see:
>>
>>
>> *admin*
>>
>>  [X] 0001_initial
>>
>> *auth*
>>
>>  [X] 0001_initial
>>
>>  [X] 0002_customer_payingcustomer_projectmanager_staff
>>
>>  [X] 0003_auto_20141107_0803
>>
>> *contenttypes*
>>
>>  [X] 0001_initial
>>
>> *portal*
>>
>>  [X] 0001_initial
>>
>>  [X] 0002_auto_20141008_2032
>>
>>  [X] 0003_auto_20141008_2058
>>
>>  [X] 0004_auto_20141008_2100
>>
>>  [X] 0005_auto_20141008_2102
>>
>>  [X] 0006_auto_20141008_2259
>>
>>  [X] 0007_project_project_video_url
>>
>> *sessions*
>>
>>  [X] 0001_initial
>>
>>
>>
>> *Where do I find the auth migrations?* I've used grep, find and 
>> Spotlight... I've searched the repository. I just can't find them! What am 
>> I missing?
>>
>> As a bit of background - the reason I'm doing this is we want to migrate 
>> to custom user models (removing username and just using email). However 
>> when I do this, I get "TypeError: Staff cannot proxy the swapped model 
>> 'emailcustomuser.User'.
>> "
>>
>> We don't actually need the proxy users, so I tried deleting them, but 
>> this didn't change anything (possibly because of these migrations I can't 
>> find). 
>>
>> Cheers,
>>
>> Ed
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ce688047-4e81-4ad8-bd71-115e9ca05ef9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/ce688047-4e81-4ad8-bd71-115e9ca05ef9%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11aafa31-25f9-4e80-9e81-8c0db57a8751%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where does django store auth migrations?

2014-11-10 Thread Dr Ed


On Sunday, 9 November 2014 14:50:54 UTC+1, Daniel Roseman wrote:
>
> On Sunday, 9 November 2014 13:40:12 UTC, Dr Ed wrote:
>>
>> Okay, I'm confused. I found it, in here:
>> /Users//.virtualenvs//lib/python2.7/site-
>> packages/django/contrib/auth/migrations
>>
>> Why are app related migrations being stored in this location?
>>
>> Cheers,
>>
>> Ed
>>
>
> What? Migrations related to Django's auth app are, not surprisingly, 
> stored alongside the code to that app. Why does this puzzle you? 
>

I guess it's because I thought that we could build migrations on the 
development machines and then update the project on the production machine 
and apply the migrations. Obviously this assumption was wrong and we need 
to distribute the entire .virtualenv too... 

Fine, if that's the way it is, that's the way it is, but to me this seems 
odd because everything else in there is just something you 'pip install' 
and I would not expect to mix 'user data' with 'installed packages' like 
this. It actually seems like an unfortunate design decision since it forces 
you - unless you try to be clever - to put django etc into the 
repository... we did this before and shifting to 1.7 was more painful as a 
result).

Anyway, thanks for the reply!

Cheers,

Ed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62a63805-1677-4979-814c-44388666b870%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where does django store auth migrations?

2014-11-09 Thread Dr Ed
Okay, I'm confused. I found it, in here:
/Users//.virtualenvs//lib/python2.7/site-
packages/django/contrib/auth/migrations

Why are app related migrations being stored in this location?

Cheers,

Ed


On Friday, 7 November 2014 09:50:47 UTC+1, Dr Ed wrote:
>
> Hi all,
>
> I feel a bit embarrassed even asking this question, because it must have 
> an obvious answer... but when I do "./manage.py migrate -l" I see:
>
>
> *admin*
>
>  [X] 0001_initial
>
> *auth*
>
>  [X] 0001_initial
>
>  [X] 0002_customer_payingcustomer_projectmanager_staff
>
>  [X] 0003_auto_20141107_0803
>
> *contenttypes*
>
>  [X] 0001_initial
>
> *portal*
>
>  [X] 0001_initial
>
>  [X] 0002_auto_20141008_2032
>
>  [X] 0003_auto_20141008_2058
>
>  [X] 0004_auto_20141008_2100
>
>  [X] 0005_auto_20141008_2102
>
>  [X] 0006_auto_20141008_2259
>
>  [X] 0007_project_project_video_url
>
> *sessions*
>
>  [X] 0001_initial
>
>
>
> *Where do I find the auth migrations?* I've used grep, find and 
> Spotlight... I've searched the repository. I just can't find them! What am 
> I missing?
>
> As a bit of background - the reason I'm doing this is we want to migrate 
> to custom user models (removing username and just using email). However 
> when I do this, I get "TypeError: Staff cannot proxy the swapped model 
> 'emailcustomuser.User'.
> "
>
> We don't actually need the proxy users, so I tried deleting them, but this 
> didn't change anything (possibly because of these migrations I can't find). 
>
> Cheers,
>
> Ed
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d890e5a-7016-40c2-94bf-ab66716fdb06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Where does django store auth migrations?

2014-11-07 Thread Dr Ed
Hi all,

I feel a bit embarrassed even asking this question, because it must have an 
obvious answer... but when I do "./manage.py migrate -l" I see:


*admin*

 [X] 0001_initial

*auth*

 [X] 0001_initial

 [X] 0002_customer_payingcustomer_projectmanager_staff

 [X] 0003_auto_20141107_0803

*contenttypes*

 [X] 0001_initial

*portal*

 [X] 0001_initial

 [X] 0002_auto_20141008_2032

 [X] 0003_auto_20141008_2058

 [X] 0004_auto_20141008_2100

 [X] 0005_auto_20141008_2102

 [X] 0006_auto_20141008_2259

 [X] 0007_project_project_video_url

*sessions*

 [X] 0001_initial



*Where do I find the auth migrations?* I've used grep, find and 
Spotlight... I've searched the repository. I just can't find them! What am 
I missing?

As a bit of background - the reason I'm doing this is we want to migrate to 
custom user models (removing username and just using email). However when I 
do this, I get "TypeError: Staff cannot proxy the swapped model 
'emailcustomuser.User'.
"

We don't actually need the proxy users, so I tried deleting them, but this 
didn't change anything (possibly because of these migrations I can't find). 

Cheers,

Ed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce688047-4e81-4ad8-bd71-115e9ca05ef9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.4 tutorial part 1 seems broken at the superuser creation stage.

2013-06-17 Thread Ed
Thank you very much, Tom, for pointing that out.

I had no idea django was looking for that environment variable. Following 
your direction, I checked, and discover that they are all indeed default to 
"undefined". I'm using OpenBSD 5.3 on macppc, which explains why they were 
not set, as opposed to on Linux.

$ python -m locale
Locale aliasing:

Locale defaults as determined by getdefaultlocale():

Language:  (undefined)
Encoding:  (undefined)

Locale settings on startup:

LC_NUMERIC ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_MESSAGES ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_MONETARY ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_COLLATE ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_CTYPE ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_TIME ...
   Language:  (undefined)
   Encoding:  (undefined)


Locale settings after calling resetlocale():

LC_NUMERIC ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_MESSAGES ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_MONETARY ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_COLLATE ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_CTYPE ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_TIME ...
   Language:  (undefined)
   Encoding:  (undefined)


Locale settings after calling setlocale(LC_ALL, ""):

LC_NUMERIC ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_MESSAGES ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_MONETARY ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_COLLATE ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_CTYPE ...
   Language:  (undefined)
   Encoding:  (undefined)

LC_TIME ...
   Language:  (undefined)
   Encoding:  (undefined)


Number formatting:

123456789 is 123456789
3.14 is 3.14
$ 




On Monday, 17 June 2013 04:02:43 UTC-7, Tom Evans wrote:
>
> On Sun, Jun 16, 2013 at 8:06 AM, Ed <draw...@gmail.com > 
> wrote: 
> > Hello Dear Django Group. 
> > 
> > My first day with Django, I just got it installed on my computer, and am 
> > trying to follow along with the first tutorial: 
> > https://docs.djangoproject.com/en/1.4/intro/tutorial01/ 
> > 
> > I have Django's development server up, and I'm able to see the "It 
> worked!" 
> > Django welcome page. Where I ran into the dead end is at the following 
> > section: 
> > 
> > "The syncdb command looks at the INSTALLED_APPS setting and creates any 
> > necessary database tables according to the database settings in your 
> > settings.py file. You’ll see a message for each database table it 
> creates, 
> > and you’ll get a prompt asking you if you’d like to create a superuser 
> > account for the authentication system. Go ahead and do that." 
> > 
> > Up to this point, I've followed the tutorial line by line. However, 
> after I 
> > ran the command "python manage.py syncdb", I got the error message 
> below, 
> > and it seems to be an internal error to Django. Has anyone else 
> encountered 
> > this issue, and how did you resolve it? Any feedback or insight is 
> > appreciated. Thank you! 
> > 
> > 
> > $ python manage.py syncdb 
> > Creating tables ... 
> > Creating table auth_permission 
> > Creating table auth_group_permissions 
> > Creating table auth_group 
> > Creating table auth_user_user_permissions 
> > Creating table auth_user_groups 
> > Creating table auth_user 
> > Creating table django_content_type 
> > Creating table django_session 
> > Creating table django_site 
> > 
> > You just installed Django's auth system, which means you don't have any 
> > superusers defined. 
> > Would you like to create one now? (yes/no): yes 
> > Traceback (most recent call last): 
> >   File "manage.py", line 10, in  
> > execute_from_command_line(sys.argv) 
> >   File 
> > 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
>
> > line 443, in execute_from_command_line 
> > utility.execute() 
> >   File 
> > 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
>
> > line 382, in execute 
> > self.fetch_command(subcommand).run_from_argv(self.argv) 
> >   File 
> > "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
&g

Django 1.4 tutorial part 1 seems broken at the superuser creation stage.

2013-06-16 Thread Ed
Hello Dear Django Group.

My first day with Django, I just got it installed on my computer, and am 
trying to follow along with the first 
tutorial: https://docs.djangoproject.com/en/1.4/intro/tutorial01/

I have Django's development server up, and I'm able to see the "It worked!" 
Django welcome page. Where I ran into the dead end is at the following 
section:

"The 
syncdb
 command looks at the 
INSTALLED_APPS
 setting and creates any necessary database tables according to the 
database settings in your settings.py file. You’ll see a message for each 
database table it creates, and you’ll get a prompt asking you if you’d like 
to create a superuser account for the authentication system. Go ahead and 
do that."

Up to this point, I've followed the tutorial line by line. However, after I 
ran the command "python manage.py syncdb", I got the error message below, 
and it seems to be an internal error to Django. Has anyone else encountered 
this issue, and how did you resolve it? Any feedback or insight is 
appreciated. Thank you!


$ python manage.py syncdb   
   
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any 
superusers defined.
Would you like to create one now? (yes/no): yes
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 443, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
line 371, in handle
return self.handle_noargs(**options)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py",
 
line 110, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", 
line 189, in emit_post_sync_signal
interactive=interactive, db=db)
  File 
"/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", 
line 172, in send
response = receiver(signal=self, sender=sender, **named)
  File 
"/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
 
line 73, in create_superuser
call_command("createsuperuser", interactive=True, database=db)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 150, in call_command
return klass.execute(*args, **defaults)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File 
"/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
 
line 70, in handle
default_username = get_default_username()
  File 
"/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
 
line 105, in get_default_username
default_username = get_system_username()
  File 
"/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
 
line 85, in get_system_username
return getpass.getuser().decode(locale.getdefaultlocale()[1])
TypeError: decode() argument 1 must be string, not None
$ 



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django tutorial

2012-04-10 Thread Ed McLaughlin
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/usr/local/mysql/data/mysite',  #
Or path to database file if using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

On Apr 10, 4:27 am, Ejah <ej.huijb...@gmail.com> wrote:
> Can you post the db part of your settings file?
>
> On 10 apr, 06:05, Ed McLaughlin <edmclaug...@gmail.com> wrote:
>
>
>
>
>
>
>
> > _mysql.so is in there. When I try using sqlite I get this:
>
> > Eds-MacBook-Air:mysite3 edmclaugh76$ python manage.py syncdb
> > Traceback (most recent call last):
> >   File "manage.py", line 10, in 
> >     execute_from_command_line(sys.argv)
> >   File "/Library/Python/2.7/site-packages/django/core/management/
> > __init__.py", line 443, in execute_from_command_line
> >     utility.execute()
> >   File "/Library/Python/2.7/site-packages/django/core/management/
> > __init__.py", line 382, in execute
> >     self.fetch_command(subcommand).run_from_argv(self.argv)
> >   File "/Library/Python/2.7/site-packages/django/core/management/
> > base.py", line 196, in run_from_argv
> >     self.execute(*args, **options.__dict__)
> >   File "/Library/Python/2.7/site-packages/django/core/management/
> > base.py", line 232, in execute
> >     output = self.handle(*args, **options)
> >   File "/Library/Python/2.7/site-packages/django/core/management/
> > base.py", line 371, in handle
> >     return self.handle_noargs(**options)
> >   File "/Library/Python/2.7/site-packages/django/core/management/
> > commands/syncdb.py", line 57, in handle_noargs
> >     cursor = connection.cursor()
> >   File "/Library/Python/2.7/site-packages/django/db/backends/
> > __init__.py", line 306, in cursor
> >     cursor = self.make_debug_cursor(self._cursor())
> >   File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/
> > base.py", line 281, in _cursor
> >     self._sqlite_create_connection()
> >   File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/
> > base.py", line 271, in _sqlite_create_connection
> >     self.connection = Database.connect(**kwargs)
> > sqlite3.OperationalError: unable to open database file
>
> > Any ideas? I really appreciate the help!
>
> > On Apr 9, 10:16 pm, Mario Gudelj <mario.gud...@gmail.com> wrote:
>
> > > Go to 
> > > /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-inte
> > >  l.egg/
> > > on your Mac and see if _mysql.so is int there. You may need to re-install
> > > MySQL_python connector. Maybe this can 
> > > helphttp://www.brambraakman.com/blog/comments/installing_mysql_python_mys...
>
> > > Otherwise, you can always use SQlite for dev environment until you go to
> > > production. I find it a lot easier to manage.
>
> > > On 10 April 2012 10:54, Ed McLaughlin <edmclaug...@gmail.com> wrote:
>
> > > > Hello! I am working through the Django tutorial (
> > > >https://docs.djangoproject.com/en/1.4/intro/tutorial01/) and I have
> > > > hit a roadblock in the 'database setup' portion of part 1. When I
> > > > enter the command 'python manage.py syncdb' I get the error below. I
> > > > believe I properly installed MySQL Community Server and mysqldb
> > > > Any help would be GREATLY appreciated.
>
> > > > Eds-MacBook-Air:mysite edmclaugh76$ python manage.py syncdb
> > > > Traceback (most recent call last):
> > > >  File "manage.py", line 10, in 
> > > >    execute_from_command_line(sys.argv)
> > > >  File "/Library/Python/2.7/site-packages/django/core/management/
> > > > __init__.py", line 443, in execute_from_command_line
> > > >    utility.execute()
> > > >  File "/Library/Python/2.7/site-packages/django/core/management/
> > > > __init__.py", line 382, in execute
> > > >    self.fetch_command(subcommand).run_from_argv(self.argv)
> > > >  File "/Library/Python/2.7/site-packages/django/core/management/
> > > > __init__.py", line 261, in fetch_command
> > > >    

Re: Django tutorial

2012-04-09 Thread Ed McLaughlin
_mysql.so is in there. When I try using sqlite I get this:

Eds-MacBook-Air:mysite3 edmclaugh76$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/
__init__.py", line 443, in execute_from_command_line
utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/
__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/
base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/django/core/management/
base.py", line 232, in execute
output = self.handle(*args, **options)
  File "/Library/Python/2.7/site-packages/django/core/management/
base.py", line 371, in handle
return self.handle_noargs(**options)
  File "/Library/Python/2.7/site-packages/django/core/management/
commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
  File "/Library/Python/2.7/site-packages/django/db/backends/
__init__.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
  File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/
base.py", line 281, in _cursor
self._sqlite_create_connection()
  File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/
base.py", line 271, in _sqlite_create_connection
self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file


Any ideas? I really appreciate the help!

On Apr 9, 10:16 pm, Mario Gudelj <mario.gud...@gmail.com> wrote:
> Go to 
> /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-inte 
> l.egg/
> on your Mac and see if _mysql.so is int there. You may need to re-install
> MySQL_python connector. Maybe this can 
> helphttp://www.brambraakman.com/blog/comments/installing_mysql_python_mys...
>
> Otherwise, you can always use SQlite for dev environment until you go to
> production. I find it a lot easier to manage.
>
> On 10 April 2012 10:54, Ed McLaughlin <edmclaug...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello! I am working through the Django tutorial (
> >https://docs.djangoproject.com/en/1.4/intro/tutorial01/) and I have
> > hit a roadblock in the 'database setup' portion of part 1. When I
> > enter the command 'python manage.py syncdb' I get the error below. I
> > believe I properly installed MySQL Community Server and mysqldb
> > Any help would be GREATLY appreciated.
>
> > Eds-MacBook-Air:mysite edmclaugh76$ python manage.py syncdb
> > Traceback (most recent call last):
> >  File "manage.py", line 10, in 
> >    execute_from_command_line(sys.argv)
> >  File "/Library/Python/2.7/site-packages/django/core/management/
> > __init__.py", line 443, in execute_from_command_line
> >    utility.execute()
> >  File "/Library/Python/2.7/site-packages/django/core/management/
> > __init__.py", line 382, in execute
> >    self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "/Library/Python/2.7/site-packages/django/core/management/
> > __init__.py", line 261, in fetch_command
> >    klass = load_command_class(app_name, subcommand)
> >  File "/Library/Python/2.7/site-packages/django/core/management/
> > __init__.py", line 69, in load_command_class
> >    module = import_module('%s.management.commands.%s' % (app_name,
> > name))
> >  File "/Library/Python/2.7/site-packages/django/utils/importlib.py",
> > line 35, in import_module
> >    __import__(name)
> >  File "/Library/Python/2.7/site-packages/django/core/management/
> > commands/syncdb.py", line 8, in 
> >    from django.core.management.sql import custom_sql_for_model,
> > emit_post_sync_signal
> >  File "/Library/Python/2.7/site-packages/django/core/management/
> > sql.py", line 6, in 
> >    from django.db import models
> >  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line
> > 40, in 
> >    backend = load_backend(connection.settings_dict['ENGINE'])
> >  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line
> > 34, in __getattr__
> >    return getattr(connections[DEFAULT_DB_ALIAS], item)
> >  File "/Library/Python/2.7/site-packages/django/db/utils.py", line
> > 92, in __getitem__
> >    backend = load_backend(db['ENGINE'])
> >  File "/Library/Python/2.7/site-packages/django/db/utils.py"

Django tutorial

2012-04-09 Thread Ed McLaughlin
Hello! I am working through the Django tutorial (
https://docs.djangoproject.com/en/1.4/intro/tutorial01/ ) and I have
hit a roadblock in the 'database setup' portion of part 1. When I
enter the command 'python manage.py syncdb' I get the error below. I
believe I properly installed MySQL Community Server and mysqldb
Any help would be GREATLY appreciated.

Eds-MacBook-Air:mysite edmclaugh76$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/
__init__.py", line 443, in execute_from_command_line
utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/
__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/
__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "/Library/Python/2.7/site-packages/django/core/management/
__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name,
name))
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File "/Library/Python/2.7/site-packages/django/core/management/
commands/syncdb.py", line 8, in 
from django.core.management.sql import custom_sql_for_model,
emit_post_sync_signal
  File "/Library/Python/2.7/site-packages/django/core/management/
sql.py", line 6, in 
from django.db import models
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line
40, in 
backend = load_backend(connection.settings_dict['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line
34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line
92, in __getitem__
backend = load_backend(db['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line
24, in load_backend
return import_module('.base', backend_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File "/Library/Python/2.7/site-packages/django/db/backends/mysql/
base.py", line 16, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.3-
py2.7-macosx-10.7-intel.egg/_mysql.so, 2): Library not loaded:
libmysqlclient.18.dylib
  Referenced from: /Library/Python/2.7/site-packages/
MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.so
  Reason: image not found
Eds-MacBook-Air:mysite edmclaugh76$

Thanks!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: foreign key select widget with "add" link

2012-01-25 Thread Ed
http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/ 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-SBv03JcdswJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: problem with BooleanField form

2011-07-22 Thread ed
Ok. That last one actually worked. Just needed to a browser refresh to
re-load the script.

That's a total noob mistake. My bad. Thanks all :)

On Jul 21, 10:49 am, ed <ed.agu...@gmail.com> wrote:
> You mean like this:
>
>         var data = {
>                 url: item.find("#id_url").val(),
>                 title: item.find("#id_title").val(),
>                 tags: item.find("#id_tags").val(),
>                 share: item.find("#id_share").val()
>         };
>
> Tried it. 'share' is still showing up false...
>
> On Jul 21, 1:29 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
>
>
>
>
>
>
>
> > On Thursday, July 21, 2011 4:00:55 AM UTC+1, ed wrote:
>
> > > I'm using the following javascript, so I can't check the HTML, can I?
> > > How would I go about debugging this?
>
> > > function bookmark_save() {
> > > var item = $(this).parent();
> > > var data = {
> > > url: item.find("#id_url").val(),
> > > title: item.find("#id_title").val(),
> > > tags: item.find("#id_tags").val()
> > > };
> > > $.post("/save/?ajax", data, function (result) {
> > > if (result != "failure") {
> > > item.before($("li", result).get(0));
> > > item.remove();
> > > $("ul.bookmarks .edit").click(bookmark_edit);
> > > }
> > > else {
> > > alert("Failed to validate bookmark before saving.");
> > > }
> > > });
> > > return false;
> > > }
>
> > > function bookmark_edit() {
> > > var item = $(this).parent();
> > > var url = item.find(".title").attr("href");
> > > item.load(
> > > "/save/?ajax=" + encodeURIComponent(url),
> > > null,
> > > function () {
> > > $("#save-form").submit(bookmark_save);
> > > }
> > > );
> > > return false;
> > > }
>
> > > $(document).ready(function () {
> > > $("ul.bookmarks .edit").click(bookmark_edit);
> > > });
>
> > But surely the problem is that you haven't supplied a value for  `share` in
> > your Ajax data.
> > --
> > DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: problem with BooleanField form

2011-07-21 Thread ed
You mean like this:

var data = {
url: item.find("#id_url").val(),
title: item.find("#id_title").val(),
tags: item.find("#id_tags").val(),
share: item.find("#id_share").val()
};

Tried it. 'share' is still showing up false...



On Jul 21, 1:29 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Thursday, July 21, 2011 4:00:55 AM UTC+1, ed wrote:
>
> > I'm using the following javascript, so I can't check the HTML, can I?
> > How would I go about debugging this?
>
> > function bookmark_save() {
> > var item = $(this).parent();
> > var data = {
> > url: item.find("#id_url").val(),
> > title: item.find("#id_title").val(),
> > tags: item.find("#id_tags").val()
> > };
> > $.post("/save/?ajax", data, function (result) {
> > if (result != "failure") {
> > item.before($("li", result).get(0));
> > item.remove();
> > $("ul.bookmarks .edit").click(bookmark_edit);
> > }
> > else {
> > alert("Failed to validate bookmark before saving.");
> > }
> > });
> > return false;
> > }
>
> > function bookmark_edit() {
> > var item = $(this).parent();
> > var url = item.find(".title").attr("href");
> > item.load(
> > "/save/?ajax=" + encodeURIComponent(url),
> > null,
> > function () {
> > $("#save-form").submit(bookmark_save);
> > }
> > );
> > return false;
> > }
>
> > $(document).ready(function () {
> > $("ul.bookmarks .edit").click(bookmark_edit);
> > });
>
> But surely the problem is that you haven't supplied a value for  `share` in
> your Ajax data.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: problem with BooleanField form

2011-07-20 Thread ed
I'm using the following javascript, so I can't check the HTML, can I?
How would I go about debugging this?

function bookmark_save() {
var item = $(this).parent();
var data = {
url: item.find("#id_url").val(),
title: item.find("#id_title").val(),
tags: item.find("#id_tags").val()
};
$.post("/save/?ajax", data, function (result) {
if (result != "failure") {
item.before($("li", result).get(0));
item.remove();
$("ul.bookmarks .edit").click(bookmark_edit);
}
else {
alert("Failed to validate bookmark before saving.");
}
});
return false;
}

function bookmark_edit() {
var item = $(this).parent();
var url = item.find(".title").attr("href");
item.load(
"/save/?ajax=" + encodeURIComponent(url),
null,
function () {
$("#save-form").submit(bookmark_save);
}
);
return false;
}

$(document).ready(function () {
$("ul.bookmarks .edit").click(bookmark_edit);
});

On Jul 20, 4:12 pm, SmileyChris  wrote:
> It should definitely be {'share': True} if you've checked the box and
> submitted the form.
>
> Have you ensured your checkbox inside the form tag you're submitting in
> HTML?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



problem with BooleanField form

2011-07-20 Thread ed
I'm learning Django by following the turorials in Django 1.0 Website
Development by Ayman Hourieh. I've been banging my head for a while on
this and I know it's probably something really simple that I'm
missing.

I'm using the following form:

class BookmarkSaveForm(forms.Form):

share = forms.BooleanField(
label=u'Share on the main page',
required=False
)


So when the form displays fine, but when I check the checkbox and
submit the form I get the following for form.cleaned_data:

{'share': False}

Shouldn't I be seeing "'share': True", not "'share': False"? Or am I
understanding this incorrectly?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django installation error: Cannot install Django in Python site-package

2011-07-06 Thread Ed Castano

You hit the nail on the head.  The command import django executed in
the Python interpreter.  Getting started seems like a giant uphill
battle, but fortunately I am quite determined.  It also helps to have
helpful people like you supporting my learning.

Thanks again!

-Ed


On Jul 6, 2:44 pm, Andre Terra <andrete...@gmail.com> wrote:
> Hello, Ed
>
> A few tips to get you going on the right track:
>
> 1) If *Python can't find Django*, it's because it's *not on your PYTHONPATH*.
> If you have multiple Python installs, it gets even more complex as *>
> manage.py* can yield different results from* > python manage.py*, depending
> on how your file associations are set up.
>
> 2) If you're getting '*access denied*', it's probably because your* not an
> admin* or *UAC is blocking you* (*windows 7, vista*). Try installing Python
> on *C:\Python27\ *instead (or something similar, depending on the version
> you're using).
>
> 3) *Never* copy packages to *site-packages directory directly*. Use a
> *virtualenv
> *instead.
>
> *Start from a fresh state* and try to follow the principles 
> behindhttp://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv...
> using
> *pip*, *repositories *and *virtualenv*.
>
> And last but not least,
>
> 4) *Try developing on linux*. It will make your life about a billion
> times *easier
> *and *more productive*!
>
> Once you get all that figure out, make sure you set up your own repository
> on *github*, *bitbucket*, *gitorious *or wherever else. Version control is
> *key* to speedy+organized development cycles.
>
> Cheers,
> André Terra (airstrike)
>
>
>
>
>
>
>
> On Wed, Jul 6, 2011 at 5:28 PM, Ed Castano <ed.cast...@gmail.com> wrote:
> > This is the error I get when trying to install Django:
>
> > error: could not create 'C:\Program Files\Python\Lib\site-packages
> > \django': Access is denied
>
> > Python 2.7 is installed.
> > I tried manually copy the django site-packages folder and while the
> > folder copies ok, django will still not run in python
>
> > Any help will be immensely appreciated.
>
> > Thanks,
> > Ed
> > I also tried manually changing the file permissions by unchecking
> > "Read only".
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django installation error: Cannot install Django in Python site-package

2011-07-06 Thread Ed Castano
This is the error I get when trying to install Django:

error: could not create 'C:\Program Files\Python\Lib\site-packages
\django': Access is denied

Python 2.7 is installed.
I tried manually copy the django site-packages folder and while the
folder copies ok, django will still not run in python

Any help will be immensely appreciated.

Thanks,
Ed
I also tried manually changing the file permissions by unchecking
"Read only".

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



GeoDjango issue with pysqlite

2011-06-15 Thread Ed
Hi,

I have followed the installation guide to the letter but am still
having issues when trying to syncdb.

I get the following error  "The pysqlite library does not support C
extension".

I have installed pysqlite with the following setup.cfg

[build_ext]
#define=
include_dirs=/Library/Frameworks/SQLite3.framework/unix/include
library_dirs=/Library/Frameworks/SQLite3.framework/unix/lib
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION

Operating System : Mac OS X 10.6 (Snow Leopard)

I really dont know what else to try.

Not sure if the following helps, but some version output information

>>> import sqlite3
>>> sqlite3.version_info
(2, 4, 1)
>>> sqlite3.sqlite_version_info
(3, 6, 12)
>>> from pysqlite2 import dbapi2 as sqlite3
>>> sqlite3.version_info
(2, 6, 0)
>>> sqlite3.sqlite_version_info
(3, 7, 4)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django News Site Resources

2011-04-08 Thread Ed Sutherland
Can anyone point me to some resources for building a Django-based news site?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Custom management commands from the admin interface

2010-12-24 Thread Ed
I am having difficulty getting my custom command to run on schedule. I'm 
using django-chronograph, but I can't seem to get it to run like it can 
(successfully) from the command line.  Before I go into the background of 
this problem, I will state my question: H*ow might I run a custom management 
command from the django admin graphical interface to prove that it can 
indeed be done?  Or rather, how can I make sure that custom management 
commands available from said interface?*

I'm just developing an app locally using django installed on Ubunutu.

I have a custom command that I use to clear out log entries that are greater 
than 30 days old. In order to test it repeatedly, I altered it so that it 
only deletes one somewhat arbitrary entry:

from datetime import datetime, timedelta
from hitcount.models import Hit
from django.core.management.base import BaseCommand, CommandError

class Command(BaseCommand):
args = ''
help = 'Clear out all Hits that occured over "days" days ago'

def handle(self, *args, **options):
list = Hit.objects.filter(created__lt = 
datetime.now()-timedelta(days=2) )
list[0].delete()

self.stdout.write('Hit deleted - %s' % list[0])

This command (del_hit.py) is located in the following structure:

/project_dir
   /app
  /management
 __init__.py
 /commands
__init__.py
del_hit.py

As I stated, I can successfully run this command from my project_dir

python manage.py del_hit
I tried installing django-chronograph. It seems very useful. It recognized 
my command and allowed me to select it from a drop down list. However, when 
it tries to execute the command, it gives me the following error in the log:

The job failed to run. The exception was :

Unknown command: u'del_hit'

Traceback (most recent call last):

File "/home/vadmin/development/python/my_proj/chronograph/models.py", line 
213, in handle_run
call_command(self.command, *args, **options)

File "/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", 
line 155, in call_command
raise CommandError("Unknown command: %r" % name)

CommandError: Unknown command: u'del_hit'

I traced this back to the __init__.py file of the django/core/management 
utility.  There seems to be some strange behavior going on.  When the server 
first comes up, a dictionary variable _commands is populated with the core 
commands (from django/core/management/commands).  Custom management commands 
from all of the installed apps are also pushed into the _commands variable 
for an overall dictionary of all management commands.  

Somehow, though between when the server starts and when django chronograph 
goes to run the job from the admin interface, the _commands variable loses 
the custom commands; the only commands in the dictionary are the core 
commands.  I'm not sure why this is.  Could it be a path issue?  Am I 
missing some setting?  Is it a django-chronograph specific problem?  *So how 
might I run a custom management command from the django admin graphical 
interface to prove that it can indeed be done?  Or rather, how can I make 
sure that custom management commands available from said interface?*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Override data validation on one django form element

2010-12-02 Thread Ed
I have a select list dropdown box on my form that is populated with
data from a Model (Directors). The value of this dropdown doesn't need
to be saved; it is really only used to dynamically trigger another
element of the form (a dropdown titled Films). So when the user
chooses a Director, it dynamically populates the second list with the
Films attached to that Director.

The first element of the first list is "All Directors." Instead of
filtering the Film List, it lets all Films be shown on the second list
because All Directors is chosen.

If the user chooses a specific Director and then a Film, the form
submits correctly. The problem is that if the user chooses All
Directors, and then selects a Film, when the form is submitted, it
tells me that my choice for Directors is not valid because it is not
one of the available choices. In this instance, an available choice (I
assume) is one of the existing Director.objects that is in the
database. But because I don't care about the Director, I don't need
this entry to be valid. I just need Film to be valid.

I'm using a ModelForm. How can I disable or override the data
validation on the Director form field so that it ignores the error
that that field generates?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Use Django's url template tag with special characters

2010-11-21 Thread Ed
I'm using django's url tag to move from one view to another:

Read more here

For most "items" this works perfectly. But I have an "item" with a /
character: Sci-Fi/Fantasy. In this instance, I get an error

Caught NoReverseMatch while rendering: Reverse for 'wiki_view' with
arguments '(u'Sci-fi/Fantasy',)' and keyword arguments '{}' not found.

My urls.py is defined as such:

url(r'^wiki/page/(?P[^/]*)/$', views.wiki_view, name =
'wiki_view'),

Is there a way for this to work with a "/" character in place like
this?  I was advised to use urlencode.

Read more here

This gives the same error.  I believe the dev version allows me to use
this:

Read more here

as discussed here: 
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#urlencode

but I'm on 1.3.0 alpha and I may want to go into production with some
of this code.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic user-filtered search

2010-11-15 Thread Ed
Ok, so I wrote some UNPROTECTED jquery/django code to pass filters to
the database.  Through a combination of drop down boxes and user input
boxes (exactly like you would see in iTunes), I am using jquery to
construct the filter.

As an example, let's say the user selects in the first drop down:
"Year".  For the second drop down: "is".  The last is an input box
where the user enters "2005."  This criteria is put into an array/
dictionary:

[
   {"includes": [["year__iexact", "2005"]],
"excludes": []},
   "all"
]

"includes"/"excludes" separates the criteria like "is", "is before"
from things like "is not"
"all" designates that the filter should "match all", not "match any"

This is converted to JSON:
[{"includes":[["year__iexact","2005"]],"excludes":[]},"all"]
and posted to django.

The view in django then puts the data into the filter:
incdict[ filter[0].encode('utf-8') ] = filter[1].encode('utf-8')

This becomes:
incdict[ 'year__iexact' ] = 2005

That is fed into the query:
query_set = Film.objects.filter(**incdict)

Ok, I hope that was clear.  What I ask now is how to protect against
the unscrupulous user who seeps to bypass/exploit the input.  Do I
need to escape special characters?  Data validation?  What is the best
way to protect the system?

Ed

On Nov 12, 7:27 am, Masklinn <maskl...@masklinn.net> wrote:
> On 2010-11-12, at 13:20 , Ed wrote:
>
>
>
> > It seems simple from a SQL point of view, but I'm wondering what the
> > best implementation would be from to go from a django form to MySQL.
> > The above is an example.  In practice, I would want to dynamically
> > populate the filter criteria/fields. Any suggestions on a starting
> > point?
>
> Create a strict translator (remember that your users can and will try to 
> bypass/exploit whatever you give them, including selects) from whatever your 
> form returns to a dict, which will be sent to .filter as a **kwargs?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic user-filtered search

2010-11-12 Thread Ed
Cool.  I'll to some work on this and check back to make sure it's not
insecure.

On Nov 12, 7:27 am, Masklinn <maskl...@masklinn.net> wrote:
> On 2010-11-12, at 13:20 , Ed wrote:
>
>
>
> > It seems simple from a SQL point of view, but I'm wondering what the
> > best implementation would be from to go from a django form to MySQL.
> > The above is an example.  In practice, I would want to dynamically
> > populate the filter criteria/fields. Any suggestions on a starting
> > point?
>
> Create a strict translator (remember that your users can and will try to 
> bypass/exploit whatever you give them, including selects) from whatever your 
> form returns to a dict, which will be sent to .filter as a **kwargs?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Dynamic user-filtered search

2010-11-12 Thread Ed
I'm brainstorming a search function for the user that is similar to
iTunes Smart Playlists. I can currently display all of the release
years for all of the films in the database. A user can pick a year and
see all of the films released in that year. Or I can show all of the
genres of movie. A user can choose a genre and see all of the movies
that match that criteria.

What I want is a form that the user can dynamically choose their own
criteria. So for instance "Release Date" "is after" "2000" AND "Genre"
"is not" "Horror" would return a filtered list. All of these choices
would be user supplied within a form that has dropdown choices.

It seems simple from a SQL point of view, but I'm wondering what the
best implementation would be from to go from a django form to MySQL.
The above is an example.  In practice, I would want to dynamically
populate the filter criteria/fields. Any suggestions on a starting
point?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Exclude form field when calling form from view

2010-11-09 Thread Ed
I'm still a bit confused, apologies.

This is the beginning of the view:

def upload_file(request, modelname, id):
if modelname == 'film':
form = UploadFileForm()
else:
form = UploadFileForm(show_title=False)
object = get_object_or_404(modelname, id__iexact=id)
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)

How would I pass in show_title correctly?  I tried rewriting the last
line: form = UploadFileForm(request.POST, request.FILES,
show_title=False) , but I got an error on submission: __init() got
multiple values for keyword argument 'show_title'

And in terms of correctly passing the variable, does it need to be
explicitly passed in the 3rd line above: form = UploadFileForm(), when
I want the title shown?  Or simply when grabbing the request.POST/
FILES?

Thank you for your help so far,
Ed

On Nov 9, 3:33 am, Knut Ivar Nesheim <knu...@gmail.com> wrote:
> The problem is here:
>
>  if request.method == 'POST':
>                form = UploadFileForm(request.POST, request.FILES)
>
> You need to make sure you always pass in show_title correctly when
> instantiating the form.
>
> Regards
> Knut
>
>
>
>
>
>
>
> On Tue, Nov 9, 2010 at 3:57 AM, Ed <edmund.rog...@gmail.com> wrote:
> > I can fall back on the subclassing suggestion.  But I'd like to give
> > this one more shot for a fix.  I think it has something to do with the
> > request.FILES that I need.  Here is my complete form:
>
> > class UploadFileForm(forms.Form):
> >        def __init__(self, show_title=True, *args, **kwargs):
> >                super(UploadFileForm, self).__init__(*args, **kwargs)
> >                if not show_title:
> >                        del self.fields['title']
>
> >        def clean_file(self):
> >                content = self.cleaned_data['file']
> >                content_type = content.content_type.split('/')[0]
> >                if content_type in settings.CONTENT_TYPES:
> >                        if content._size > settings.MAX_UPLOAD_SIZE:
> >                                raise forms.ValidationError(_('Please keep 
> > filesize under %s.
> > Current filesize %s') % (filesizeformat(settings.MAX_UPLOAD_SIZE),
> > filesizeformat(content._size)))
> >                else:
> >                        raise forms.ValidationError(_('File type is not 
> > supported'))
> >                return content
>
> >        title = forms.CharField(max_length=50)
> >        file = forms.ImageField(label='Select photo to upload')
>
> > And here is my complete view:
>
> > def upload_file(request, modelname, id):
> >        if modelname == 'film':
> >                form = UploadFileForm()
> >        else:
> >                form = UploadFileForm(show_title=False)
>
> >        object = get_object_or_404(modelname, id__iexact=id)
> >        if request.method == 'POST':
> >                form = UploadFileForm(request.POST, request.FILES)
> >                if form.is_valid():
> >                        file = request.FILES["file"]
> >                        filename = file.name
> >                        content = file.read()
>
> >                        # Assign unique name to file
> >                        new_image_name, extension = unique_name(filename, 
> > object,
> > modelname)
>
> >                        #FUTURE: Resize middle and resize remaining in 
> > background
> >                        #SMALL
> >                        #img_resizer(content)
> >                        u_small = new_image_name + '_small.jpg'
> >                        store_in_s3(u_small, img_resizer(content,250,250,90))
>
> >                        # Save thumbnail url to object
> >                        object.url_small = u_small
> >                        object.save()
>
> >                        # Grab Next param to determine where to redirect 
> > back to
> >                        redirect_to = request.GET.get('next', 
> > reverse('index_view'))
> >                        return HttpResponseRedirect(redirect_to)
> >                else:
> >                        # If form validation fails, use original reverse url
> >                        redirect_to = request.GET.get('next', 
> > reverse('index_view'))
>
> >        else:
> >                # If first loading form, grab referer and pass to form
> >                referer = request.META.get('HTTP_REFERER', None)
>
> >                # Pass original location in next url param
> >                if referer is

Re: Exclude form field when calling form from view

2010-11-08 Thread Ed
I can fall back on the subclassing suggestion.  But I'd like to give
this one more shot for a fix.  I think it has something to do with the
request.FILES that I need.  Here is my complete form:

class UploadFileForm(forms.Form):
def __init__(self, show_title=True, *args, **kwargs):
super(UploadFileForm, self).__init__(*args, **kwargs)
if not show_title:
del self.fields['title']

def clean_file(self):
content = self.cleaned_data['file']
content_type = content.content_type.split('/')[0]
if content_type in settings.CONTENT_TYPES:
if content._size > settings.MAX_UPLOAD_SIZE:
raise forms.ValidationError(_('Please keep 
filesize under %s.
Current filesize %s') % (filesizeformat(settings.MAX_UPLOAD_SIZE),
filesizeformat(content._size)))
else:
raise forms.ValidationError(_('File type is not 
supported'))
return content

title = forms.CharField(max_length=50)
file = forms.ImageField(label='Select photo to upload')


And here is my complete view:

def upload_file(request, modelname, id):
if modelname == 'film':
form = UploadFileForm()
else:
form = UploadFileForm(show_title=False)

object = get_object_or_404(modelname, id__iexact=id)
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
file = request.FILES["file"]
filename = file.name
content = file.read()

# Assign unique name to file
new_image_name, extension = unique_name(filename, 
object,
modelname)

#FUTURE: Resize middle and resize remaining in 
background
#SMALL
#img_resizer(content)
u_small = new_image_name + '_small.jpg'
store_in_s3(u_small, img_resizer(content,250,250,90))

# Save thumbnail url to object
object.url_small = u_small
object.save()

# Grab Next param to determine where to redirect back to
redirect_to = request.GET.get('next', 
reverse('index_view'))
return HttpResponseRedirect(redirect_to)
else:
# If form validation fails, use original reverse url
redirect_to = request.GET.get('next', 
reverse('index_view'))

else:
# If first loading form, grab referer and pass to form
referer = request.META.get('HTTP_REFERER', None)

# Pass original location in next url param
if referer is None:
redirect_to = reverse('index_view')
else:
try:
redirect_to = urlsplit(referer, 'http', 
False)[2]
except IndexError:
redirect_to = reverse('index_view')


return render_to_response('upload.html', {'form': form,'obj':
object,'redirect_to':redirect_to}, context_instance =
RequestContext(request))

If I remove the def __init__ from the form class, it works perfectly,
but always shows the title.  But with that in the form class, it
always says "This field is required."  For just the imagefield if the
title is suppressed or for both the title and the imagefield if the
title is not suppressed.

Suggestions?

On Nov 8, 3:47 pm, Knut Ivar Nesheim <knu...@gmail.com> wrote:
> Maybe you could just use subclassing instead of doing stuff at run-time:
>
> class UploadForm(forms.Form):
>     file = ...
>     # custom upload and validation code here
>
> class ThumbnailUploadForm(UploadForm):
>     pass
>
> class UploadFileForm(UploadForm):
>     title = ...
>
> As for your current approach, it looks correct. I've done the same
> several times and it works as expected. Make sure you are really
> really passing show_title correctly in your thumbnail case.
>
> Regards
> Knut
>
> On Mon, Nov 8, 2010 at 9:29 PM, Ed <edmund.rog...@gmail.com> wrote:
> > I have an image upload form that takes a title and a file for its
> > field. I have two uses for it. Most of the time I call it, I need both
> > a title and the image itself. But when I call it simply to grab a
> > thumbnail, I don't need the title. In fact, the form data is saved to
> > a different model that doesn't even have title as a field.
>
> > I wanted to suppress the "title" field when I call the form. I could
> > have created two

Exclude form field when calling form from view

2010-11-08 Thread Ed
I have an image upload form that takes a title and a file for its
field. I have two uses for it. Most of the time I call it, I need both
a title and the image itself. But when I call it simply to grab a
thumbnail, I don't need the title. In fact, the form data is saved to
a different model that doesn't even have title as a field.

I wanted to suppress the "title" field when I call the form. I could
have created two form classes in my forms.py, but this seemed
unnecessarily repetitious.

I included the following in my image form class:

def __init__ (self, show_title=True):
super (BaseClass, self).__init__()
if not show_title:
del self.fields['title']

This works great except for one thing. Now I'm getting validation
errors: "This field is required" whether I suppress the title field or
not. Any time I try to submit the form, it tells me I need to enter
data.  Any advice on how to do this correctly?

class UploadFileForm(forms.Form):
def __init__ (self, show_title=True):
super (BaseClass, self).__init__()
if not show_title:
del self.fields['title']

title = forms.CharField(max_length=50)
file = forms.ImageField(label='Select photo to upload')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Query field across multiple django models

2010-10-26 Thread Ed
Do you have further detail on how this looks?  I was intending to use
forms.changed_data, but I would much rather get an automatic list of
changed fields by comparing the new submission to the initial state.
How do I compare the initial to the post within a pre_save function?


On Oct 26, 12:18 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 26 oct, 15:48, Ed <edmund.rog...@gmail.com> wrote:
>
> > I do like this a lot.  If I use post_save, is there a way to grab the
> > field that is altered?
>
> Nope, you have to use "pre_save" for this, load another (yet
> unmodified) copy of your model instance, and diff both.
>
> > I know the admin page seems to be able to
> > determine the changed field. . .
>
> ModelForms do keep a copy of the initial state so they can tell what
> went modified.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Query field across multiple django models

2010-10-26 Thread Ed
I do like this a lot.  If I use post_save, is there a way to grab the
field that is altered?  I know the admin page seems to be able to
determine the changed field. . .

On Oct 26, 9:41 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 26 oct, 13:25, Ed <edmund.rog...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > I want to create a "What's New" section that lists all of the database
> > changes in the last day. I've added an "updated" field to my models:
>
> > class Film(models.Model):
> >    .
> >    .
> >    .
> >    updated = models.DateTimeField(auto_now=True)
>
> > class Actor(models.Model):
> >    .
> >    .
> >    .
> >    updated = models.DateTimeField(auto_now=True)
>
> > Now I want to query across all of my models to get a date-sorted list
> > of the most recent changes. How do I query the "updated" field across
> > multiple models? Is this the most efficient way to achieve the primary
> > purpose?
>
> > What if I wanted to be more specific and list the actual field that
> > was altered within each model?
>
> Another solution is to have a specific "LastChange" model with a
> GenericForeignKey on your other models (the ones you want to monitor)
> and hook into the appropriate signal (models.signals.pre_save or
> models.signals.post_save look like a good start) to feed it with
> relevant data.
>
> The neat points are that:
>
> 1/ you can monitor just any model, without having to add special
> fields
> 2/ you only have one table to query to build your "what's new" section
> (depending on what infos you store in LastChange, you may not need to
> get at the changed object at all)
>
> HTH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Query field across multiple django models

2010-10-26 Thread Ed
If there is no simpler way to do this, then I'm fine with this
method.  2 questions though.

Is there a concern about the size of the query required for the
big_honking_list?  I would probably be pulling a much larger dataset
than I need and can only truncate it after it's sorted by date.

Second, I'm not sure I understood the last part about getting the
field within each model.  So my example:

class Film(models.Model):
   title = models.CharField(max_length=50, unique = True)
   year = models.IntegerField()
   length = models.IntegerField()
   updated = models.DateTimeField(auto_now=True)

If I updated length, saved, then updated year, then saved, could I get
a list that would say:

What's new
Film Length: updated 2:15am
Film Year: updated 2:20 am
etc.

On Oct 26, 7:44 am, Scott Gould <zinck...@gmail.com> wrote:
> Maybe -- in fact, almost certainly not -- the best way, but this is
> how I do that kind of thing:
>
>         a_queryset = ModelA.objects.all()
>         another_queryset = ModelB.objects.filter.(by_something=True)
>         yet_another_queryset =
> ModelC.objects.exclude(by_something_else=False)
>
>         from itertools import chain
>         big_honking_list = list(chain(a_queryset, another_queryset,
> yet_another_queryset))
>         big_honking_list.sort(key=lambda x: x.updated)
>         big_honking_list.reverse()
>
> As to your last question, that is easy if you're doing a list.sort()
> -- just expose a method on each model that returns a sortable value
> that is consistent across all the models. (Or write a dedicated
> function to use instead of the lambda above, whichever makes more
> sense.)
>
> On Oct 26, 7:25 am, Ed <edmund.rog...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I want to create a "What's New" section that lists all of the database
> > changes in the last day. I've added an "updated" field to my models:
>
> > class Film(models.Model):
> >    .
> >    .
> >    .
> >    updated = models.DateTimeField(auto_now=True)
>
> > class Actor(models.Model):
> >    .
> >    .
> >    .
> >    updated = models.DateTimeField(auto_now=True)
>
> > Now I want to query across all of my models to get a date-sorted list
> > of the most recent changes. How do I query the "updated" field across
> > multiple models? Is this the most efficient way to achieve the primary
> > purpose?
>
> > What if I wanted to be more specific and list the actual field that
> > was altered within each model?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Query field across multiple django models

2010-10-26 Thread Ed
I want to create a "What's New" section that lists all of the database
changes in the last day. I've added an "updated" field to my models:

class Film(models.Model):
   .
   .
   .
   updated = models.DateTimeField(auto_now=True)

class Actor(models.Model):
   .
   .
   .
   updated = models.DateTimeField(auto_now=True)

Now I want to query across all of my models to get a date-sorted list
of the most recent changes. How do I query the "updated" field across
multiple models? Is this the most efficient way to achieve the primary
purpose?

What if I wanted to be more specific and list the actual field that
was altered within each model?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Expense of django query

2010-10-20 Thread Ed
Brilliant.  Thanks!

On Oct 20, 9:41 am, Javier Guerra Giraldez <jav...@guerrag.com> wrote:
> On Wed, Oct 20, 2010 at 7:59 AM, Ed <edmund.rog...@gmail.com> wrote:
> > what is the purpose of ifchanged?
>
> since the images are sorted by film, if you just show the film for
> every image it would be repeated.  with {% ifchanged %} it's only
> shown before all the images for this film, so the result is like this:
>
> film A
> image a.1
> image a.2
> film B
> image b.1
> image b.2
> image b.3
> film C
> 
>
> without {% ifchanged %} you would get:
> film A
> image a.1
> film A
> image a.2
> film B
> image b.1
> film B
> image b.2
> film B
> image b.3
> film C
> ...
>
> --
> Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Expense of django query

2010-10-20 Thread Ed
Thanks for the suggestion.  Javier's was exactly what I needed.  The
one question I have is why what is the purpose of ifchanged?  I'm
aware of the command but I don't see the purpose of it within a loop.


On Oct 20, 5:18 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Oct 19, 9:46 pm, Ed <edmund.rog...@gmail.com> wrote:
>
>
>
>
>
> > Thanks for the answers.  I thought that the view was already pulling
> > the data.  I didn't realize it gets pulled when called in the
> > template.  I was able to rewrite the view to provide the data more
> > efficiently.
>
> > I have another related question on the topic of query expense.  What
> > is the best practice as far as database table design?
>
> > I have 3 tables: studio, film, images.  If film has a foreign key to
> > studio, and images has a foreign key to film.  If I wanted to pull all
> > of the images for a particular studio, it would be more expensive to
> > pull:
>
> > all films (given studio), and then films.images_set
>
> > as opposed to:
>
> > including the studio in the image table and then pulling all images
> > (given studio).
>
> > But there is some data replication here.  Technically, I can discover
> > studio by following the link from image to film to studio.  But it I
> > need less queries given this particular need.  What is the best
> > practice in a scenario like this?
>
> Well, as you've realised, iterating through each film to get its
> images will fire off one query per film. But how to do it efficiently
> depends on what you're doing with the data. If you just need all
> images for one studio, and don't care about the films, then one query
> will suffice:
>
>     Image.objects.filter(film__studio=mystudio)
>
> If you need all studios and their related images, it's a bit more
> difficult. One way of doing it would be to use the queryset `extra`
> clause to add a studio ID to each image, group them by that ID, then
> studios appending the image list to each one. I can post some code if
> that's the sort of thing you need to do.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Expense of django query

2010-10-19 Thread Ed
Thanks for the answers.  I thought that the view was already pulling
the data.  I didn't realize it gets pulled when called in the
template.  I was able to rewrite the view to provide the data more
efficiently.

I have another related question on the topic of query expense.  What
is the best practice as far as database table design?

I have 3 tables: studio, film, images.  If film has a foreign key to
studio, and images has a foreign key to film.  If I wanted to pull all
of the images for a particular studio, it would be more expensive to
pull:

all films (given studio), and then films.images_set

as opposed to:

including the studio in the image table and then pulling all images
(given studio).

But there is some data replication here.  Technically, I can discover
studio by following the link from image to film to studio.  But it I
need less queries given this particular need.  What is the best
practice in a scenario like this?

On Oct 19, 4:17 pm, Daniel Roseman  wrote:
> On Oct 19, 4:43 pm, Tom Evans  wrote:
>
>
>
>
>
> > On Tue, Oct 19, 2010 at 4:16 PM, Daniel Roseman  
> > wrote:
> > > The solution here is to evaluate the queryset in your view first,
> > > before passing it to the template. You can do this by simply calling
> > > list() on it - eg instead of defining your context as {'actor_list':
> > > actor_list}, do {'actor_list': list(actor_list)}. Bear in mind though,
> > > if you're doing things like pagination, this will end up being less
> > > efficient, as it will evaluate the *whole* queryset rather than just
> > > the elements you need for the page you're on.
>
> > I'm 100% sure Daniel is aware of this, but it is good to explicitly
> > point it out: this will also require more memory, as instead of
> > iterating through the queryset and producing one object at a time, it
> > has to create and store a list of objects.
>
> > Cheers
>
> > Tom
>
> Well, to a certain extent. When iterating through a queryset, Django
> populates it in chunks of 100 items. So if the actor_list set is less
> than 100 - which is a pretty good bet seeing as it's not paginated -
> there'll be very little difference in terms of memory consumption.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Expense of django query

2010-10-19 Thread Ed
I have a table for Actor that I query and populate the result in
actor_list to pass to the template. I installed the Django Debug
Toolbar to check the queries hitting the database and found some
strange behavior. If I iterate through the actor_list, only one SQL
query is created, as expected:

{% for actor in actor_list %}
   {{ actor.id }}
{% endfor %}

But if I call a particular item in the list before the loop, that
additional call generates its own query, meaning the database is hit
twice.

{{ actor_list.0.id }}

{% for actor in actor_list %}
   {{ actor.id }}
{% endfor %}


Why is that?  Is there a way to do this that doesn't result in two
queries?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Forms and 'prefix' parameter

2010-08-05 Thread Ed Schofield
On Aug 5, 2:23 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Aug 5, 2010 at 12:10 AM, Ed Schofield <edschofi...@gmail.com> wrote:
> > Hi everyone,
>
> > I'm trying to use a view with multiple forms under Django 1.2.1. I'm
> > puzzled that the prefix parameter seems to screw up validation. Here's
> > a test case:
>
> > >>> from django import forms
>
> > >>> class MyForm(forms.Form):
> > >>>     field1 = forms.IntegerField(required=False)
> > >>>     field2 = forms.IntegerField()
>
> > >>> f1 = MyForm(data={'field1': 1, 'field2': 2})
> > >>> f2 = MyForm(data={'field1': 1, 'field2': 2}, prefix='p')
>
> > >>> f1.is_valid()
> > True
>
> > >>> f2.is_valid()
> > False
>
> > Can anyone explain why these are different?
>
> You need to include the prefix in the data dictionary keys for the form.
> See:http://code.djangoproject.com/ticket/13763#comment:3

I've done some more digging. It seems that the prefix on data
dictionary keys is required only when initializing the form, not when
accessing the form data:

>>> f1.cleaned_data
{'field1': 1, 'field2': 2}

>>> f2.cleaned_data
{'field1': 1, 'field2': 2}

rather than what I would now expect, given how the data argument is
processed:

{'p-field1': 1, 'p-field2': 2}

Isn't this oddly inconsistent?

-- Ed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Forms and 'prefix' parameter

2010-08-04 Thread Ed Schofield
On Aug 5, 2:23 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Aug 5, 2010 at 12:10 AM, Ed Schofield <edschofi...@gmail.com> wrote:
> > Hi everyone,
>
> > I'm trying to use a view with multiple forms under Django 1.2.1. I'm
> > puzzled that the prefix parameter seems to screw up validation. Here's
> > a test case:
>
> > >>> from django import forms
>
> > >>> class MyForm(forms.Form):
> > >>>     field1 = forms.IntegerField(required=False)
> > >>>     field2 = forms.IntegerField()
>
> > >>> f1 = MyForm(data={'field1': 1, 'field2': 2})
> > >>> f2 = MyForm(data={'field1': 1, 'field2': 2}, prefix='p')
>
> > >>> f1.is_valid()
> > True
>
> > >>> f2.is_valid()
> > False
>
> > Can anyone explain why these are different?
>
> You need to include the prefix in the data dictionary keys for the form.
> See:http://code.djangoproject.com/ticket/13763#comment:3

Thanks, Karen.

Could I request that a note about this be added to the docs? I suggest
here:

http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms

This would have saved me several hours (!) of head-scratching and
stepping line-by-line through Django's forms.py with pdb.

Cheers,
-- Ed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



NullBooleanField save error in Admin

2010-03-09 Thread Ed Hagen
Hi,

I have a model field defined thus:

benefit = models.NullBooleanField()

In django 1.1 and 1.2 pre-alpha, nulls were displayed with a "?" icon
in list view. In the Admin change form, a pop-up menu appeared with 3
options (Unknown, Yes, No). Setting to "Unknown" and saving did not
generate any errors.

I then updated to django 1.2  beta 1 SVN-12738. Nulls are now
displayed with "(None)". When I try and set this field to "Unknown"
using the popup menu, and then save in the Admin, I get the following
error:

"This field cannot be blank."

I get this same error when I try and add a new record in the Admin.

I am using python 2.5.1 on Mac OS X and sqlite3.

Any insights into what is going on and how I can fix this would be
greatly appreciated.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: showing user data in a view

2009-10-13 Thread Ed Kawas

Thanks,

I guess I made it out to be harder than it was.

Eddie

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Brian McKeever
Sent: October-12-09 1:20 PM
To: Django users
Subject: Re: showing user data in a view


You could write a wrapper around it if you wanted.

def x_edit(request, x_id):
x = X.objects.get(id = x_id)
if x.user != request.user:
return HttpResponseRedirect('/you cant edit that/')
return update_object(request, model = X, object_id = x_id,)


On Oct 12, 1:51 pm, "Ed Kawas" <ed.ka...@gmail.com> wrote:
> Ah, so there is no way to use 'create_object' when doing this, right?
>
> Thank you,
>
> Eddie
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
>
> On Behalf Of Brian McKeever
> Sent: October-12-09 12:50 PM
> To: Django users
> Subject: Re: showing user data in a view
>
> It's the same thing.
>
> Lets say this is your view:
> def x_edit(request, x_id):
>     x = X.objects.get(id = x_id)
>     if x.user != request.user:
>         return HttpResponseRedirect('/you cant edit that/')
>     if request.method == 'POST':
>         form = XForm(request.POST)
>         if form.is_valid():
>             #whatever you need to do to save an x object here
>             return HttpResponseRedirect('/thanks/')
>     else:
>         form = XForm()
>
>     return render_to_response('x_edit.html', {
>         'form': form,
>     })
>
> You can split that into multiple views if you want, but the idea is to
> do the check before saving the object.
>
> On Oct 12, 1:25 pm, "Ed Kawas" <ed.ka...@gmail.com> wrote:
> > That works for retrieving information, but how can I save information
too?
>
> > Thanks for your patience,
>
> > Eddie
>
> > -Original Message-
> > From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com]
>
> > On Behalf Of Brian McKeever
> > Sent: October-12-09 11:52 AM
> > To: Django users
> > Subject: Re: showing user data in a view
>
> > The easy way is to just check that the owner of X is the user logged
> > in.
> > I don't know that you can pass an argument to the decorator, but you
> > could certainly just use an if statement.
>
> >http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-...
> > in-users-that-pass-a-test
>
> > On Oct 12, 11:40 am, Ed <ed.ka...@gmail.com> wrote:
> > > Hi All,
>
> > > I am completely lost. I *think* that I have read most of the doc that
> > > i can find and I must be pretty dense, because I cannot figure this
> > > one out ...
>
> > > Let me outline what i have and where i want to go!
>
> > > model:
> > > # an X
> > > class X(db.Model):
> > >    user = models.ForeignKey(User, unique=True)
> > >    name = db.StringProperty(required=True)
>
> > > Form:
> > > class XForm(forms.ModelForm):
> > >     name = models.CharField(max_length=100)
> > >     class Meta:
> > >         model = X
> > >         fields = {'name'}
>
> > > views:
> > > def add_x(request):
> > >   return create_object(request,
> > >                                     form_class=XForm,
> > >                                     post_save_redirect=reverse
> > > ('myapp.views.show_x',
> > > kwargs=dict(key='%(key)s')))
>
> > > I am trying to allow authenticated users the ability to add X. I am
> > > trying to associate a user with a specific X so that only that user
> > > can modify it. How can I do this?
> > > Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: showing user data in a view

2009-10-12 Thread Ed Kawas

Ah, so there is no way to use 'create_object' when doing this, right?

Thank you,

Eddie

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Brian McKeever
Sent: October-12-09 12:50 PM
To: Django users
Subject: Re: showing user data in a view


It's the same thing.

Lets say this is your view:
def x_edit(request, x_id):
x = X.objects.get(id = x_id)
if x.user != request.user:
return HttpResponseRedirect('/you cant edit that/')
if request.method == 'POST':
form = XForm(request.POST)
if form.is_valid():
#whatever you need to do to save an x object here
return HttpResponseRedirect('/thanks/')
else:
form = XForm()

return render_to_response('x_edit.html', {
'form': form,
})

You can split that into multiple views if you want, but the idea is to
do the check before saving the object.

On Oct 12, 1:25 pm, "Ed Kawas" <ed.ka...@gmail.com> wrote:
> That works for retrieving information, but how can I save information too?
>
> Thanks for your patience,
>
> Eddie
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
>
> On Behalf Of Brian McKeever
> Sent: October-12-09 11:52 AM
> To: Django users
> Subject: Re: showing user data in a view
>
> The easy way is to just check that the owner of X is the user logged
> in.
> I don't know that you can pass an argument to the decorator, but you
> could certainly just use an if statement.
>
> http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-...
> in-users-that-pass-a-test
>
> On Oct 12, 11:40 am, Ed <ed.ka...@gmail.com> wrote:
> > Hi All,
>
> > I am completely lost. I *think* that I have read most of the doc that
> > i can find and I must be pretty dense, because I cannot figure this
> > one out ...
>
> > Let me outline what i have and where i want to go!
>
> > model:
> > # an X
> > class X(db.Model):
> >    user = models.ForeignKey(User, unique=True)
> >    name = db.StringProperty(required=True)
>
> > Form:
> > class XForm(forms.ModelForm):
> >     name = models.CharField(max_length=100)
> >     class Meta:
> >         model = X
> >         fields = {'name'}
>
> > views:
> > def add_x(request):
> >   return create_object(request,
> >                                     form_class=XForm,
> >                                     post_save_redirect=reverse
> > ('myapp.views.show_x',
> > kwargs=dict(key='%(key)s')))
>
> > I am trying to allow authenticated users the ability to add X. I am
> > trying to associate a user with a specific X so that only that user
> > can modify it. How can I do this?
> > Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: showing user data in a view

2009-10-12 Thread Ed Kawas

That works for retrieving information, but how can I save information too?

Thanks for your patience,

Eddie

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Brian McKeever
Sent: October-12-09 11:52 AM
To: Django users
Subject: Re: showing user data in a view


The easy way is to just check that the owner of X is the user logged
in.
I don't know that you can pass an argument to the decorator, but you
could certainly just use an if statement.

http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-logged-
in-users-that-pass-a-test

On Oct 12, 11:40 am, Ed <ed.ka...@gmail.com> wrote:
> Hi All,
>
> I am completely lost. I *think* that I have read most of the doc that
> i can find and I must be pretty dense, because I cannot figure this
> one out ...
>
> Let me outline what i have and where i want to go!
>
> model:
> # an X
> class X(db.Model):
>    user = models.ForeignKey(User, unique=True)
>    name = db.StringProperty(required=True)
>
> Form:
> class XForm(forms.ModelForm):
>     name = models.CharField(max_length=100)
>     class Meta:
>         model = X
>         fields = {'name'}
>
> views:
> def add_x(request):
>   return create_object(request,
>                                     form_class=XForm,
>                                     post_save_redirect=reverse
> ('myapp.views.show_x',
> kwargs=dict(key='%(key)s')))
>
> I am trying to allow authenticated users the ability to add X. I am
> trying to associate a user with a specific X so that only that user
> can modify it. How can I do this?
> Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



showing user data in a view

2009-10-12 Thread Ed

Hi All,

I am completely lost. I *think* that I have read most of the doc that
i can find and I must be pretty dense, because I cannot figure this
one out ...

Let me outline what i have and where i want to go!

model:
# an X
class X(db.Model):
   user = models.ForeignKey(User, unique=True)
   name = db.StringProperty(required=True)

Form:
class XForm(forms.ModelForm):
name = models.CharField(max_length=100)
class Meta:
model = X
fields = {'name'}

views:
def add_x(request):
  return create_object(request,
form_class=XForm,
post_save_redirect=reverse
('myapp.views.show_x',
kwargs=dict(key='%(key)s')))

I am trying to allow authenticated users the ability to add X. I am
trying to associate a user with a specific X so that only that user
can modify it. How can I do this?
Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database connection closed after each request?

2009-09-01 Thread Ed Menendez

Just to throw my two cents in. My background is high-traffic fantasy
sports websites (a different sort of geekness) and I've dealt with
connection pooling and connection persistence separately on other
ancient platforms. I will +1 Alex's observation that connection
pooling and persistent connections are two different things. This
problem also has little to do with high-traffic sites and all to do
with the normal use cases. I will also +1 that the default to require
reconnections is bad enough to be considered a bug. For reasons
already stated, this should never be the default longevity of
connections.

I implemented the connection pool hack (to get persistent connection)
with SQLAchemy using MySQL for an RBS Futbol Soccer game. And I think
it's a hack because basically, I had to buy the happy meal (pooling)
just to get the collectible toy (persistent connections).

Once we decouple connection pooling and persistent connections in our
heads... I think this becomes a simpler issue. If you had 50 web
threads going and each one had a connection to the database that stays
open forever, even at 1am when you have no users, that's not a
problem. Even those 50 threads sitting there is not a problem. As a
matter of fact, I much prefer to keep those 50 web threads open so
Python+Django+My Bloated Code isn't reinstantiated all the time.

If you have 1000 connections open, now you might want to have some
connection pooling. But that's a separate problem to be solved by a
separate package and discussed in a different forum.

I do understand this complicates the edge cases where you don't want
the connections to stay open and those who want to have connection
pooling, but since those are edge cases in my opinion, it should be a
little more difficult.

I believe the argument is being made that it's not Django's problem if
connections are kept alive. It's not a battery that needs to be
included. I would argue that this battery needs to be included as it's
a problem with moderate and low traffic sites. Including high traffic
sites in this discussion only confuses the issue since we're really
talking connection pooling for those cases.



On Jul 27, 4:43 pm, Glenn Maynard  wrote:
> On Sun, Jul 26, 2009 at 10:17 PM, Amitay Dobo wrote:
> > So to sum up: I vote up connection pooling. Where do I sign up?
>
> Thread hijacking.  Thanks, always appreciated.
>
> --
> Glenn Maynard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Watercrest - Technology Contractor Solutions

2009-07-20 Thread Ed

Good Afternoon DJango Users,
Hope everyone is well.  Came across your group while networking for a
contract position that we currently have open.  We need a strong
python developer with experience in Django, MySQL, and ideally JSP and
HTML/CSS as well.  It will probably be a 2 month contract to start
with an excellent chance of extension.  Location is downtown Toronto.
If it’s not for you, maybe someone you know?
Cheers,
Ed Rix
Resource Planning
Watercrest
"Bridging People with Technology"
(888) 244-7550 ext.110
e...@watercrest.net


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django + rest

2008-12-29 Thread Ed Summers

(my apologies if you already saw this question on django-developers,
I'm reposting here because it's more a users question)

I was wondering if anyone else on the list has layered a RESTful
service into their django applications. I'm adding an atompub
interface to an existing django project, and I'd like to offer the
ability to POST and PUT to URIs. Part of my problem is that this
service needs to handle large (many megabyte) file uploads, so the
POST and PUT message body needs to be streamed to disk, rather than
held in memory.

I took a look at the FileUpload functionality in
django.http.HttpRequest and
django.http.multipartparser.MultiPartParser, and it looked like I
could slot in custom handlers as long as the content was POSTed with a
mimetype of "multipart/form-data". Unfortunately I am wanting to allow
clients to POST and PUT arbitrary content (application/zip,
application/atom+xml, etc).

At the moment I'm rolling my own code to read from request.environ
['wsgi.input'] but I'm worried that I'm not handling everything
correctly, and am wondering if there exists middleware for handling
this sort of scenario in a cleaner way. Or perhaps there's a more
django-y way of doing it?

Any info/pointers/tips would be appreciated.

//Ed

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Specify that syncdb not create a table for a Model

2008-10-08 Thread Ed Anuff



On Oct 7, 6:32 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> >  On the roadmap?
>
> Yes. Should certainly be in 1.1. Probably land in a few weeks.

Awesome, couldn't ask for more, thanks :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Specify that syncdb not create a table for a Model

2008-10-07 Thread Ed Anuff

I reviewed this thread from March on whether it's possible to mark a
Model so that syncdb doesn't create the table for specific Models and
was wondering if there are any updates to this:

http://groups.google.com/group/django-users/browse_thread/thread/ba928abb39db2e31?tvc=2

I'm integrating with a legacy database schema which uses the single-
table-inheritance pattern for storing several different classes in a
single table with a single column discriminator, and since Django
doesn't support that, thought next best thing would be to create a set
of Models which used the same table, which works, but I also want to
eventually use syncdb to create the database and want it to be able to
handle the situation correctly.  Still not possible?  Something I can
easily hack Model to do myself?  On the roadmap?

Ed

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django web hosting

2008-09-03 Thread Ed Wong

Thanks all for your advice.  You have given me great info.  I too have
heard good things about webfaction.  I will research more into them.
Thanks again!  :)

On Sep 3, 11:57 am, "Abdallah El Guindy" <[EMAIL PROTECTED]>
wrote:
> Google app engine provides free hosting, with Django support
>
> Link:http://appengine.google.com/
>
> The only problem is that I haven't managed to make the db classes run, the
> google API provides some other mechanism.. If you can migrate to that then
> almost everything else will run.
>
> You can also purchase domain names for sites hosted on appengine.. but
> haven't tried that personally
>
> On Wed, Sep 3, 2008 at 6:05 PM, chr <[EMAIL PROTECTED]> wrote:
>
> > i can only recommend djangohosting.ch for small to medium django-based
> > websites (with a european audience). deployed four websites with
> > djangohosting now. support is helpful and fast. the config-panel is
> > amazing. also, a lot of python packages are installed by default. my
> > latest site was online within some 30 minutes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django web hosting

2008-09-02 Thread Ed Wong

hi all,

i am looking for a good web host for my django website.  does anyone
suggest a good host?  thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems Pickling Querysets

2008-07-18 Thread Ed Menendez

Ticket #7813. Let me know if I messed up the ticket report!! :-)

Thanks,

- Ed


On Jul 18, 11:43 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-07-18 at 09:34 -0700, Ed Menendez wrote:
> > I saw a previously closed ticket 7506 for a related (no pun intended)
> > problem. It seems like when we use select_related suddenly the
> > queryset can't be pickled. This used to work back in May sometime.
> > Currently using SVN 7944.
>
> Pickling should always work, so this is a bug. Can you open a ticket
> containing a small example showing the problem so we don't lose it,
> please?
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problems Pickling Querysets

2008-07-18 Thread Ed Menendez

I saw a previously closed ticket 7506 for a related (no pun intended)
problem. It seems like when we use select_related suddenly the
queryset can't be pickled. This used to work back in May sometime.
Currently using SVN 7944.

Here's the model:

class LeagueSeason(models.Model):
is_conference_used  = models.BooleanField(default=False)
is_division_used= models.BooleanField(default=False)

class LeagueConference(models.Model):
league_season   = models.ForeignKey(LeagueSeason)
name= models.CharField(max_length=50)
# slug is not unique by itself.
slug= models.CharField(max_length=50,
prepopulate_from=('name',), db_index=True)
sort_order  = models.SmallIntegerField(default=1)

class LeagueDivision(models.Model):
league_conference   = models.ForeignKey(LeagueConference)
name= models.CharField(max_length=50)
# slug is not unique by itself.
slug= models.CharField(max_length=50,
prepopulate_from=('name',), db_index=True)
sort_order  = models.SmallIntegerField(default=1)


# This works
ld = LeagueDivision.objects.all()
cache.set('test2', ld)

# This doesn't work
ld = LeagueDivision.objects.select_related('league_conference').all()
cache.set('test2', ld)

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\django\core\cache\backends
\memcached.py", line 35, in set
self._cache.set(smart_str(key), value, timeout or
self.default_timeout)
  File "C:\Projects\pyapps\memcache.py", line 437, in set
return self._set("set", key, val, time, min_compress_len)
  File "C:\Projects\pyapps\memcache.py", line 609, in _set
store_info = self._val_to_store_info(val, min_compress_len, key)
  File "C:\Projects\pyapps\memcache.py", line 581, in
_val_to_store_info
pickler.dump(val)
  File "C:\Python25\lib\copy_reg.py", line 71, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects

Is this supposed to be supported? Did we just get lucky when it used
to work in a previous version? Let me know if you need more info!

- Ed

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopg2

2008-06-25 Thread Ed McCaffrey
Even if it had the most beautiful site in the world, and that was enough to
get permission to use it, a responsible developer would write some unit
tests and check the items that he asked in his original question.

His highly-qualified scientists probably won't have any idea that a database
driver even exists; they will be more interested in the part of the system
that they actually interact with.  Highly-qualified programmers and computer
scientists won't care about the site or the language appearing on it, when
they see the passing test suite.

On Wed, Jun 25, 2008 at 4:01 PM, cbmeeks <[EMAIL PROTECTED]> wrote:

>
> I agree with Will on this one.  While it's not the site that makes the
> software, it sure as heck determines how many people (and companies)
> will take that first chance and use it.
>
> psycopg2 might be the best thing since sliced bread.  I've always used
> MS SQL and MySQL.  Recently, I've started learning Python and
> Postgres.  After setting up Django and deciding to ditch MySQL and go
> for Postgres, I too came to that rant of a page and wondered what the
> heck was going on.  Then I finally drilled down and found the
> download.
>
> I work for Corporate America.  Love it or hate it, Corporate America
> (CA) like big flashy sites with contacts, mission statements, blah
> blah blah.  My bosses don't care about open source.  Most people don't
> understand it.  Even if they did understand it, they don't care.  Only
> SOME programmers care about open source.  (and I am one of them).
>
> Bottom line is that Mr Senior Manager VP of Programming at CA pushes
> pencils all day making sure CA is compliant in every way with support
> contracts and lots of red tape.   Mr Sr Manager took a Cobol class
> back in 1982 so that qualified him as an expert in software
> development.  So he decides to audit all source code and libraries.
> But wait, he comes across psycopg2 and sees some "amateur" site with
> swear words and orders the minions to remove all "amateur" code.  "We
> only deal with good software like DB2, Oracle or MS".
>
> THAT is the opinion of 99.999% of CA.  And I don't mean the little two
> man webshop in San Fran running a "revolutionary" site on how to
> widgitize the mood swings of cats who have 2 million users using
> LAMP.  I mean the companies that FEED most of us code drones.
>
> That is what Will was trying to point out...I believe.
>
> Now, having said all of thatI DO believe FOSS is a great movement
> in the software world.  I AM using psycopg2 for my projects.  But the
> company I work for (5000 employees) have never even heard of Python,
> Django, Postgres and especially psycopg2.
>
> Now, should the creators of psycopg2 worry about some super site?
> Nah.  But if they put a "please help...we need a better site" title on
> their front page they might get a lot more support.  Django's site is
> beautiful.  That's not what matters...but it sure as hell helped me
> stick around and learn more.
>
> cbmeeks
> http://codershangout.com (the most BEAUTIFUL site in the world!!!
> hahahaah)
>
>
>
> On Jun 24, 10:07 am, Will <[EMAIL PROTECTED]> wrote:
> > I'm working on a project I'd like to use Django for, though my first
> > hurdle will be convincing a team of highly qualified scientists,
> > programmers and computer scientists that this is a good idea.
> >
> > Given we are most likely going to use PostgreSQL, This isn't
> > particularly inspiring:http://www.initd.org/
> >
> > Why should we trust psycopg2 to be a high quality piece of software?
> >
> > Will
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Will Django be upgraded to Python 3.0 after the 1.0 release?

2008-06-24 Thread Ed McCaffrey
Hello,

My project consists of a couple of stand-alone applications that gather and
process the data that the eventual Django-powered site will serve.  I'm
seeing at least 6-8 months until work on the site will begin.

Is there a plan for upgrading Django to Python 3.0?

Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem with forms with db access

2008-06-15 Thread ./ed

Hi
actually i did not go as smoothly as i expected :(
first ModelChoiceField is *really* implemented only on development
version (i was on the lastest release)
so i had to clean a lot of code
plus to obtain the first item on the list of choices (and not the
empty string) you need to set the the empty_label key as None

but now it works!

./ed


On Jun 15, 5:16 pm, "./ed" <[EMAIL PROTECTED]> wrote:
> Thanks a lot!
> i had the feeling it was a class/instance issue
> it should work fine now
>
> Thx again
>
> ./ed
>
> On Jun 15, 4:53 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > On Sun, Jun 15, 2008 at 7:58 AM, ./ed <[EMAIL PROTECTED]> wrote:
> > > the problem is that when i add an entry to the aModel table it does
> > > not update in the form (even with various reload scheme)
> > > it does update when I 'touch' the python file. So my guess is the
> > > problem lies in the 'compilation' chain or something like that.
>
> > Consider the following normal Python class:
>
> > import datetime
>
> > class BeforeAfterNoon(object):
> > time = datetime.datetime.now()
>
> > @classmethod
> > def before_noon(cls):
> > return cls.time.hour < 12
>
> > Now, suppose you import this class at 11:59, and call the
> > 'before_noon()' method. It will return True.
>
> > Suppose you leave the Python interpreter running and don't reload
> > anything; at 12:01, 'before_noon()' will still return True.
>
> > This is because -- when Python parsed the class definition -- the
> > current date and time were assigned to the attribute 'time' in the
> > class, the same as if a constant value had been assigned, and it won't
> > change until something forces the class definition to be completely
> > reloaded, at which point it will update to a new value and stick
> > *there* instead.
>
> > Assigning choices to a field in a form works the same way; even if the
> > choices come from calling a function, it still happens only once --
> > when the class is first loaded.
>
> > This deals with the general case of what you're seeing. For the
> > specific case of dynamically pulling choices for a form field from a
> > QuerySet, you want to take a look at the documentation:
>
> >http://www.djangoproject.com/documentation/newforms/#fields-which-han...
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem with forms with db access

2008-06-15 Thread ./ed

Thanks a lot!
i had the feeling it was a class/instance issue
it should work fine now

Thx again

./ed


On Jun 15, 4:53 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Sun, Jun 15, 2008 at 7:58 AM, ./ed <[EMAIL PROTECTED]> wrote:
> > the problem is that when i add an entry to the aModel table it does
> > not update in the form (even with various reload scheme)
> > it does update when I 'touch' the python file. So my guess is the
> > problem lies in the 'compilation' chain or something like that.
>
> Consider the following normal Python class:
>
> import datetime
>
> class BeforeAfterNoon(object):
> time = datetime.datetime.now()
>
> @classmethod
> def before_noon(cls):
> return cls.time.hour < 12
>
> Now, suppose you import this class at 11:59, and call the
> 'before_noon()' method. It will return True.
>
> Suppose you leave the Python interpreter running and don't reload
> anything; at 12:01, 'before_noon()' will still return True.
>
> This is because -- when Python parsed the class definition -- the
> current date and time were assigned to the attribute 'time' in the
> class, the same as if a constant value had been assigned, and it won't
> change until something forces the class definition to be completely
> reloaded, at which point it will update to a new value and stick
> *there* instead.
>
> Assigning choices to a field in a form works the same way; even if the
> choices come from calling a function, it still happens only once --
> when the class is first loaded.
>
> This deals with the general case of what you're seeing. For the
> specific case of dynamically pulling choices for a form field from a
> QuerySet, you want to take a look at the documentation:
>
> http://www.djangoproject.com/documentation/newforms/#fields-which-han...
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with forms with db access

2008-06-15 Thread ./ed

Hi,

I'm an experienced programmer in python but I discovered Django last
week and managed to deploy a full application in one day! That's a
piece of work.

I have a slight problem though. I want to have a form with a choice
list where items come from the database. For example :

## models.py
class aModel(models.Model):
 myfield = models.CharField()

## forms.py
class aForm(forms.Form):
 choicelist = [(obj.id,obj.myfield)  for obj in
aModel.objects.all()]
 mod = forms.ChoiceField(choice=choicelist)

that's not exactly the code because the choice list is computed in
another python file.

the problem is that when i add an entry to the aModel table it does
not update in the form (even with various reload scheme)
it does update when I 'touch' the python file. So my guess is the
problem lies in the 'compilation' chain or something like that.

As anyone an idea how I can fix this problem because I can't allow
users to 'touch' the python files

Thanks

./ed

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: building distributed systems with django?

2008-06-08 Thread Ed McCaffrey
Twitter isn't a good candidate for simply creating a cache and replicating
your database.  I'll just post a link, since it goes along with my own
thoughts.

http://ayende.com/Blog/archive/2008/06/03/Architecting-Twitter.aspx


On Sun, Jun 8, 2008 at 12:32 PM, lgr888999 <[EMAIL PROTECTED]> wrote:

>
> Pat: Im pretty sure you can build a twitter clone with django and make
> it scale pretty well with replication but you still have a single
> point of failure if the master db gets to much load.  Im thinking
> about simpleDB from amazon. I wonder if that would be a good platform
> to build something twitter-like on.
>
> On Jun 8, 10:42 am, Pat <[EMAIL PROTECTED]> wrote:
> > I'm not certain I understand what you're asking because high available
> > isn't exactly related to distributed systems.  I think you're asking
> > about sharding (partitioning of data across multiple databases).  If
> > that's your question, then the answer is yes, it can be done.  It's
> > just writing a custom backend, tweeking managers, etc.   The deep
> > truth is, however, that all you would be doing is building the Google
> > App. Engine.  The question is why not start there.
> >
> > As it turns out, twitter is not an example of decentralized
> > distributed system though ("We currently use one database for writes
> > with multiple slaves for read queries" ~
> http://blog.twitter.com/2008/05/its-not-rocket-science-but-its-our-wo...).
> > Their problems aren't really related to a lack of sharding as much as
> > they are querying on a many-to-many model I think.  There's a good
> > blog out there on the problem but I can't find the link.
> >
> > On Jun 7, 7:11 am, lgr888999 <[EMAIL PROTECTED]> wrote:
> >
> > > Im curious to hear if theres any django developer that has built any
> > > decentralized distributed system with help of django? I know building
> > > a website doesnt include any scaling problems in the beginning, im
> > > asking more out of personal interests in high availability. If you
> > > dont have any experience with it feel free to post your thoughts of
> > > how you would build a huge decentraliced system. Now of course it
> > > would depend on what the purpose of the system is so lets just take
> > > twitter as an example. :)
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there any Django module like ViewCV for svn repositories?

2008-06-03 Thread Ed McCaffrey
I don't know if Trac is Django powered, but you may be able to port parts of
it for what you need.

On Tue, Jun 3, 2008 at 11:52 AM, The Code Janitor <[EMAIL PROTECTED]>
wrote:

>
> I want to have a source code repository view on my Django site. I can
> not find any such module available. Mostly I want something like
> ViewCV with a couple of twists (user authentication, group permissions
> to view sections, tagging, etc.)
>
> In poking around I couldn't find any example python-svn
> implementations either. Of course then I rememberd "batteries built
> in" and sure enough there is a libsvn (although there are no docs or
> examples for this for this anywhere I can find even with google's
> help).
>
> Pointers, comments, suggestions?
>
> Thanks in advance!!
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How nicely does django play in a distributed environment?

2008-06-02 Thread Ed McCaffrey
I'm new to Django, as well, so don't take this reply as authoritative.

Chapter 20 of The Django book -- www.djangobook.com -- details various
deployment scenarios, including ones distributed among several servers.  It
suggests that it is relatively easy to scale Django across several tiers
(web tier, cache tier, database, etc..) and that each tier can consist of an
arbitrary number of servers.

One of the reasons that I am using Django for my current project is because
it looks easy to scale out across lots of inexpensive hardware as my usage
grows.


On Mon, Jun 2, 2008 at 8:06 AM, Phillip B Oldham <[EMAIL PROTECTED]>
wrote:

>
> I'm looking at using django to replace our current CMS application
> written in PHP. Currently we have two servers behind a load balancer,
> and everything's nice and stable. We're getting a consistent month-on-
> month traffic increase though and I'm looking at moving to a more
> distributed model - localised servers for uk/us/eu with replicated
> mysql instances.
>
> I'd just like to get the community's thoughts/experiences on running
> django in such an environment.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: American Idol game developed in Django

2008-02-18 Thread Ed Menendez

http://aigame.wwudo.com/

Seems like that other URL is not working for everybody...  Thanks
everyone for all the info (on the group and on the sites!). The
documentation for this framework really makes a difference.

On Feb 18, 12:41 pm, Ed Menendez <[EMAIL PROTECTED]> wrote:
> This was our first site in Django and also our intro to Python. We
> used to play this on a spreadsheet with friends but were able to
> develop the replacement in about a week with Django. Probably could
> have been done much quicker if we weren't newbies to the framework.
>
> http://aigame.digitalhaiku.com/
>
> Special thanks to Eric Florenzano who gave us our introductory class
> in Django. Hope this motivates some developers that are on the fence
> on using Django.
>
> - Ed
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



American Idol game developed in Django

2008-02-18 Thread Ed Menendez

This was our first site in Django and also our intro to Python. We
used to play this on a spreadsheet with friends but were able to
develop the replacement in about a week with Django. Probably could
have been done much quicker if we weren't newbies to the framework.

http://aigame.digitalhaiku.com/

Special thanks to Eric Florenzano who gave us our introductory class
in Django. Hope this motivates some developers that are on the fence
on using Django.

- Ed
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie: How to create different person models that share a profile model?

2007-08-25 Thread Ed Hagen


That will work -- assigning roles to Users makes sense. But, using
your setup, is there any way to enforce a single role per User? As it
is now, a single User could be assigned both a student and teacher
role.

Many thanks for your help.

Ed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Newbie: How to create different person models that share a profile model?

2007-08-24 Thread Ed Hagen


After finally realizing that in django one cannot subclass models, and
then reading as much as I could find on alternative approaches, I
think I am close to a solution to the following problem, but I can't
quite seem to get all the way there on my own:

In simplified terms, I want multiple types of persons in my app, e.g.,
faculty, students, and staff. Each requires a common set of 'profile'
fields (e.g., first_name, last_name, email), but each has some unique
fields (e.g., degree, adviser, supervisor). I want to be able to add
and edit these using the admin site. The basic strategy would seem to
be to create Faculty, Student, Staff and Profile models, and then
create links between the first three and the Profile model. First,
here's how the different models might look:

###

class Profile(models.Model):
First_name = models.CharField(max_length=30)
Last_name = models.CharField(max_length=30)
Email = models.EmailField()

class Faculty(models.Model):
Degree=models.CharField(max_length=10)
class Admin:
pass

class Student(models.Model):
Advisor = models.ForeignKey(Faculty)
class Admin:
pass

class Staff(models.Model):
Supervisor =  models.CharField(max_length=30)
class Admin:
pass

###

The different person types have the "class Admin" statement so they
show up in the admin site. Ideally, I would then somehow be able to
edit the fields of a unique Profile instance inline for each of the
person types. But if I add a unique ForeignKey statement to the person
types, like so:

class Faculty(models.Model):
Degree=models.CharField(max_length=10)
profile = models.ForeignKey(Profile, edit_inline=models.STACKED,
num_in_admin=1, unique=True)
class Admin:
pass

I link the models the way I want to with a unique ForeignKey (or at
least I think I do), but the inline editing is backwards and illogical
(and doesn't work anyway). That is, for each of the person types, I
want to edit the fields of a Profile instance inline, not the other
way around.

Does that make sense? If so, any suggestions on how to do what I want,
or how to rethink the problem?

Thanks in advance!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to preload all object fields for a QuerySet? (GenericForeignKey and select_related())

2006-11-29 Thread Ed

Hello, is there a way to force the django db model to load all fields
for a particular model _including_ any generic foreign keys (it doesn't
seem to do this by default).

Currently: Account.objects.select_related() will load all 'simple'
fields like IntegerField, CharField, etc, but not GenericForeignKey.

Another problem is that I find if I create a OneToOneField link to the
default django.contrib.auth.User model (from my Account model),
everytime I access request.user.account it is hitting the db to select
the account record.  How to avoid this/cache this.

Thanks for any input.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Wrapping dispatcher/signal functionality

2006-11-17 Thread Ed

Hi django users,
I'd like to write a decorator for connecting functions like such:

def connect(sender, signal):
  def _connect(fn):
dispatcher.connect(fn, signal=signal, sender=sender)
  return _connect

...

@connect(Account, signals.post_save)
def reset_account_balance(sender, instance, signal):
  instance.balance = 0
  instance.save()

This does not seem to work... is there a flaw in this implementation?
Thanks for any help.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Template inclusion tags, include once

2006-11-05 Thread Ed

Is it possible to create a constraint that only allows a template tag
to be used only once?

This would be useful for a template inclusion tag that includes inline
javascript.

Thanks,
Ed.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Returning an average from a Related Field.

2006-10-24 Thread Ed

Hi John, thanks for your introduction to django dispatchers.  I think
this is a greatly overlooked facility and has many applications.

> 1- signals. Benefits: it works with all dbs (supported by django), the
> fields are sortable using the api. Drawbacks: you can't use non-django
> code to do data manipulation, the data is not normalized.

What do you mean when you say that the data is not 'normalized'?
Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Using django.core.urlresolvers

2006-10-21 Thread Ed

The reverse(...) method seems to be what I'm looking for, as mentioned
by Don in my previous post
(http://groups.google.com/group/django-users/browse_thread/thread/dacbcbd7252564ab).
However, it doesn't seem to work when I use generic views, since the
reverse method lookups are based on the view.

So my question is how do I go about using the urlresolvers module with
generic views? Is it even possible, or should I not be using this
module at all?  thanks. Ed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Using django.core.urlresolvers

2006-10-21 Thread Ed

The reverse(...) method seems to be what I'm looking for, as mentioned
by Don in my previous post
(http://groups.google.com/group/django-users/browse_thread/thread/dacbcbd7252564ab).
However, it doesn't seem to work when I use generic views, since the
reverse method lookups are based on the view.

So my question is how do I go about using the urlresolvers module with
generic views? Is it even possible, or should I not be using this
module at all?  thanks. Ed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: URL generation, symbolic referencing possible?

2006-10-21 Thread ed chan
Thanks Don, I looked at urlresolvers.py and it is exactly the type of thing i'm looking for.  This thread was posted, as you said, several months ago.  Are there any plans to standardize this feature / implementation?
Ed.On 10/21/06, Don Arbow <[EMAIL PROTECTED]> wrote:
On Oct 21, 2006, at 1:47 PM, Ed wrote:>> Hello, currently url patterns are hard coded into urls.py, in the> templates, and in some cases the views which return redirects. This is> becoming a dangerous practice in our application development.  If one
> url needs to be changed due to an update in the application design, it> would break many pages/views.>> Is there a contrib module or do I need to roll my own URL helper class> that allows my developers to do something like the following in
> urls.py:In this thread from 6 months ago, Adrian hacked up some code thatwould allow you to dynamically generate a URL that points to a viewusing a template tag, see this thread for more info:
http://groups.google.com/group/django-developers/browse_thread/thread/a5d12bc4fb073f24/83d7e4cb5f35ed08There are other threads on this subject in both the dev and user
groups as well.Don
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django users" group.  To post to this group, send email to django-users@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---


URL generation, symbolic referencing possible?

2006-10-21 Thread Ed

Hello, currently url patterns are hard coded into urls.py, in the
templates, and in some cases the views which return redirects. This is
becoming a dangerous practice in our application development.  If one
url needs to be changed due to an update in the application design, it
would break many pages/views.

Is there a contrib module or do I need to roll my own URL helper class
that allows my developers to do something like the following in
urls.py:

URL_VIEW_RESPONSE = 1

urlpatterns += urlhelper.create(URL_VIEW_RESPONSE,
'^view/(?P\d+)/current/(?P\d+)/$', 'x_y_view')

Then in a template, refer to url as (using some fictional 'url'
templatetag):

link

Or in a view as:

return HttpRedirectResponse(urlhelper.get(URL_VIEW_RESPONSE, x.id,
y.id))

Please advise, thanks. Ed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: PostgreSQL Schemas.

2006-04-15 Thread Ed Epstein

Don Arbow wrote:
> I also didn't like the names that Django gave to my tables. But of
> course you can name them anything you'd like using the db_table field
> of the META inner class. A little more effort, but this comes in
> handy when using legacy databases.

Yes, that is an option, but it doesn't really solve potential namespace
conflicts within the database for multiple apps. Additionally, it
doesn't jive with what seems to be a goal of Django in general:
facilitating speedy development of apps with a minimum of code.

The larger issue here is that, one of the uses of schemas in Postgres
(and in general for other databases that support a similar feature),
you can create a logical separation of data within the same database
connection, and therefore within the same project. That falls well in
line with how applications in Django are structured.

What I'd like to know is, if I spend the time on this and do it
properly (so that it plays nice with other database backends, will work
easily with the old naming convention, etc) is there a chance that it
would be incorporated within the project or is there zero belief in the
usefulness of schemas? If the latter, why? I find them very useful.

--Ed


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: PostgreSQL Schemas.

2006-04-14 Thread Ed Epstein

Adrian Holovaty wrote:

> That's the big question -- should the schema be specified in the
> settings file or in the model? (Well, I've never used schemas, so
> maybe it's not as big of a question as I'm making it out to be. Maybe
> it doesn't make sense to put the schema in the model?)

Well here's the thing: I've not been using Django for very long, but
I've found the project / app dichotomy both useful and confusing. One
of the more confusing aspects of it is how the model table names are
constructed with the app name as a prefix. What you often end up with
(and I think this is in the tutorial) is something like "poll_polls"
and whatnot as table names. This doesn't seem very user-friendly to me.
What's worse, you can imagine a large project with several apps such
that in the public schema you have a huge number of tables with
convoluted names that are difficult to keep track of. If a user is
using Django with a database that needs to be accessed from more than
one type of service, this is not very pleasant to work with as well.

So...

It strikes me that one option for this, at least when using Postgres as
the database, (and really, why would you use anything else ;) might be
to have the actual postgres database hold the entire project, while
putting individual apps into their own schema. This alleviates the need
to use the app name as a prefix for table names because each app gets
its own namespace. Not only would this simplify table names, but it
would allow for more freedom in customisation within the database, if
you wanted to use stored procedures in a per-app way for example. It
would help delineate further the difference betweem apps and projects,
as well as provide a more robust logical separation of apps from each
other. It seems like it would provide more flexibility overall. What do
you think?

If the database isn't Postgres, I don't know if the other supported
database backends support a similar feature, but if they do it might
make sense to implement the same thing for those backends. However for
now I'd imagine if I go ahead and make these changes, the behaviour for
the other databases should probably stay the same for now. I haven't
looked at the code enough to see if this could be done easily without
breaking cross-database app support (ie migrating an  app from one
backend to another without any fancy dancing).

Does this seem like a plausible change? If I were to do this, it would
be in the magic-removal branch I think? I'll keep familiarising myself
with the codebase.

>
> I forgot to mention this ticket, which has a patch for adding schema support:
>
> http://code.djangoproject.com/ticket/1051
>
> That's on an older version of Django but may give you some ideas.

It did give me some ideas, but I really think that schemas should be a
per-app setting (which I suppose is more accurately called a per-model
setting), not a per-project setting.

--Ed


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: PostgreSQL Schemas.

2006-04-14 Thread Ed Epstein

Well I managed to get introspectdb working with schemas, but I don't
know if it's the right solution. What I'm doing right now is modifying
the schema search path.

If you think it's a good idea, I'd probably suggest looking at adding a
per project per app setting that specifies a schema. It would need to
add the create schema statement during the initsql process. For
subsequent accesses, we would set the default search path for the life
of connection to match the schema specifed in the settings. Is this
worth pursuing?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



PostgreSQL Schemas.

2006-04-14 Thread Ed Epstein

Hi. I searched the archives and could find no real mention of this, so
I thought I'd post.

Can I specify specific Postgres schemas (e.g. database.schema.table) in
Django? Can I specify specific schemas when using the inspectdb
feature?

I'll poke around in the code and see if I can figure out where these
sorts of calls are made, but this will be the first time that I've
looked at the Django source, so I thought I'd just ask in case I can
get an answer here sooner.

--Ed


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---