Re: I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

2013-03-21 Thread hugh Manchu
CORRECTION;

I gave it a shot Bill an thanks for the reply btw ... this also id not work
I pasted what i did in the terminal. manage.py NOT settings.py is nested in
/home/lightning/Docments/django-works/mysite/manage.py. settings.py is one
down


On Thu, Mar 21, 2013 at 10:51 PM, hugh Manchu wrote:

> I gave it a shot Bill an thanks for the reply btw ... this also id not
> work I pasted what i did in the terminal. settings.py is nested in
> /home/lightning/Docments/django-works/mysite/manage.py. settings.py is one
> down
>
>
> On Thu, Mar 21, 2013 at 1:39 PM, Bill Freeman  wrote:
>
>> Setting an environment variable is done by saying something like:
>>
>> lightning@rigel5:~$ export DJANGO_SETTINGS_MODULE='mysite.settings'
>>
>> assuming that your settings.py file is in a directory named "mysite", in
>> turn in the current directory (your home directory, if I interpret your
>> prompt string correctly).  Then that command may work.
>>
>> But that's the painful way to do that.  Presumably there is a file named
>> manage.py either in the same directory as settings.py (older Djangos) or
>> one directory up (newer Djangos).  'cd' to the directory containing
>> manage.py and type:
>>
>> lightning@rigel5:pathToDirectoryContainingManage_py$ python manage.py
>> diffsettings
>>
>> If you look at manage.py with 'less' or with an editor, you will see that
>> it sets the DJANGO_SETTINGS_MODULE environment variable (though using
>> python code, rather than shell code) appropriately (for use from the
>> current directory) before doing other stuff.
>>
>> For my money, django-admin.py should only ever be used for its
>> startproject command.  Everything else should be done with manage.py after
>> cd'ing to the directory that contains it (or from a wsgi script, which also
>> sets the DJANGO_SETTINGS_MODULE environment variable and adjusts sys.path
>> to be sure that the directory containing manage.py is there, but that will
>> come much later for you, I think).
>>
>> Bill
>>
>> On Thu, Mar 21, 2013 at 1:13 PM, Lightning wrote:
>>
>>>
>>>
>>> On Wednesday, March 20, 2013 11:50:49 PM UTC-7, Lightning wrote:


 
 **

 [image: enter image description here]I need help configuring for a
 database. Is there a paper I can read that will give me an overview on this
 procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.

 ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
 class LazySettings(LazyObject):
 """
 A lazy proxy for either global Django settings or a custom settings 
 object.
 The user can manually configure settings prior to using them. 
 Otherwise,
 Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
 """


>>>
>>>
>>>  ImproperlyConfigured: Requested setting USE_I18N, but settings are not
>>> configured. You must either define the environment variable
>>> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
>>> settings.
>>>
>>> --
>>> 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?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/h7BncMwxH7E/unsubscribe?hl=en
>> .
>> To unsubscribe from this group and all its topics, 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

2013-03-21 Thread hugh Manchu
I gave it a shot Bill an thanks for the reply btw ... this also id not work
I pasted what i did in the terminal. settings.py is nested in
/home/lightning/Docments/django-works/mysite/manage.py. settings.py is one
down


On Thu, Mar 21, 2013 at 1:39 PM, Bill Freeman  wrote:

> Setting an environment variable is done by saying something like:
>
> lightning@rigel5:~$ export DJANGO_SETTINGS_MODULE='mysite.settings'
>
> assuming that your settings.py file is in a directory named "mysite", in
> turn in the current directory (your home directory, if I interpret your
> prompt string correctly).  Then that command may work.
>
> But that's the painful way to do that.  Presumably there is a file named
> manage.py either in the same directory as settings.py (older Djangos) or
> one directory up (newer Djangos).  'cd' to the directory containing
> manage.py and type:
>
> lightning@rigel5:pathToDirectoryContainingManage_py$ python manage.py
> diffsettings
>
> If you look at manage.py with 'less' or with an editor, you will see that
> it sets the DJANGO_SETTINGS_MODULE environment variable (though using
> python code, rather than shell code) appropriately (for use from the
> current directory) before doing other stuff.
>
> For my money, django-admin.py should only ever be used for its
> startproject command.  Everything else should be done with manage.py after
> cd'ing to the directory that contains it (or from a wsgi script, which also
> sets the DJANGO_SETTINGS_MODULE environment variable and adjusts sys.path
> to be sure that the directory containing manage.py is there, but that will
> come much later for you, I think).
>
> Bill
>
> On Thu, Mar 21, 2013 at 1:13 PM, Lightning  wrote:
>
>>
>>
>> On Wednesday, March 20, 2013 11:50:49 PM UTC-7, Lightning wrote:
>>>
>>>
>>> 
>>> **
>>>
>>> [image: enter image description here]I need help configuring for a
>>> database. Is there a paper I can read that will give me an overview on this
>>> procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.
>>>
>>> ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
>>> class LazySettings(LazyObject):
>>> """
>>> A lazy proxy for either global Django settings or a custom settings 
>>> object.
>>> The user can manually configure settings prior to using them. Otherwise,
>>> Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
>>> """
>>>
>>>
>>
>>
>>  ImproperlyConfigured: Requested setting USE_I18N, but settings are not
>> configured. You must either define the environment variable
>> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
>> settings.
>>
>> --
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/h7BncMwxH7E/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

2013-03-21 Thread hugh Manchu
ightning@rigel5:~$ cd /home/lightning/Documents/django-works/mysite/
lightning@rigel5:~/Documents/django-works/mysite$
pathToDirectoryContainingManage_py$ python manage.py diffsettings
pathToDirectoryContainingManage_py$: command not found
lightning@rigel5:~/Documents/django-works/mysite$
pathToDirectoryContainingManage_py
pathToDirectoryContainingManage_py: command not found
lightning@rigel5:~/Documents/django-works/mysite$
ightning@rigel5:pathToDirectoryContainingManage_py$
python manage.py diffsettings
ightning@rigel5:pathToDirectoryContainingManage_py$: command not found
lightning@rigel5:~/Documents/django-works/mysite$ cd /manage.py
bash: cd: /manage.py: No such file or directory
lightning@rigel5:~/Documents/django-works/mysite$ export
DJANGO_SETTINGS_MODULE='mysite.settings'
lightning@rigel5:~/Documents/django-works/mysite$ django-admin.py test
Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in 
management.execute_from_command_line()
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 453, in execute_from_command_line
utility.execute()
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 263, in fetch_command
app_name = get_commands()[subcommand]
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 109, in get_commands
apps = settings.INSTALLED_APPS
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py",
line 52, in __getattr__
self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py",
line 47, in _setup
self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py",
line 132, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?):
%s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'mysite.settings' (Is it on
sys.path?): No module named mysite.settings
lightning@rigel5:~/Documents/django-works/mysite$


On Thu, Mar 21, 2013 at 1:39 PM, Bill Freeman  wrote:

> Setting an environment variable is done by saying something like:
>
> lightning@rigel5:~$ export DJANGO_SETTINGS_MODULE='mysite.settings'
>
> assuming that your settings.py file is in a directory named "mysite", in
> turn in the current directory (your home directory, if I interpret your
> prompt string correctly).  Then that command may work.
>
> But that's the painful way to do that.  Presumably there is a file named
> manage.py either in the same directory as settings.py (older Djangos) or
> one directory up (newer Djangos).  'cd' to the directory containing
> manage.py and type:
>
> lightning@rigel5:pathToDirectoryContainingManage_py$ python manage.py
> diffsettings
>
> If you look at manage.py with 'less' or with an editor, you will see that
> it sets the DJANGO_SETTINGS_MODULE environment variable (though using
> python code, rather than shell code) appropriately (for use from the
> current directory) before doing other stuff.
>
> For my money, django-admin.py should only ever be used for its
> startproject command.  Everything else should be done with manage.py after
> cd'ing to the directory that contains it (or from a wsgi script, which also
> sets the DJANGO_SETTINGS_MODULE environment variable and adjusts sys.path
> to be sure that the directory containing manage.py is there, but that will
> come much later for you, I think).
>
> Bill
>
> On Thu, Mar 21, 2013 at 1:13 PM, Lightning  wrote:
>
>>
>>
>> On Wednesday, March 20, 2013 11:50:49 PM UTC-7, Lightning wrote:
>>>
>>>
>>> 
>>> **
>>>
>>> [image: enter image description here]I need help configuring for a
>>> database. Is there a paper I can read that will give me an overview on this
>>> procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.
>>>
>>> ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
>>> class LazySettings(LazyObject):
>>> """
>>> A lazy proxy for either global Django settings or a custom settings 
>>> object.
>>> The user can manually configure settings prior to using them. Otherwise,
>>> Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
>>> """
>>>
>>>
>>
>>
>>  ImproperlyConfigured: Requested setting USE_I18N, but settings are not
>> configured. You must either define the environment variable
>> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
>> settings.
>>
>> --
>> 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.

Im having trouble accessing irc.freenode.net

2013-03-21 Thread Lightning
 

'Where to get help:

If you’re having trouble going through this tutorial, please post a message 
to django-users  or drop by 
#django 
on irc.freenode.net  to chat with other 
Django users who might be able to help.'



I need help with django related issues, including this one,

Can someone please help me with this ? Thanks is advance

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can't store valid JSON in JSONField because of SubfieldBase/to_python issues

2013-03-21 Thread Brad Jasper
I ended up moving this to the Django bug tracker thinking it was an issue 
with Django itself: https://code.djangoproject.com/ticket/20090

Someone over there pointed me in the right direction: You need to subclass 
SubfieldBase and call your own method instead of to_python. You can pass 
the custom ModelField along with the value and check the state that way. 
This seems to have solved my problem pretty well.

For an example, check out what we used on 
django-jsonfield: 
https://github.com/bradjasper/django-jsonfield/blob/master/jsonfield/subclassing.py

On Thursday, March 14, 2013 11:23:21 AM UTC-4, Brad Jasper wrote:
>
> I maintain django-jsonfield, a project that allows you to store arbitrary 
> JSON objects in the database.
>
> It's having a problem with the way to_python is called while 
> using SubfieldBase. A full explanation of the problem is here (
> https://github.com/bradjasper/django-jsonfield/issues/33), but here's my 
> best attempt at a summary:
>
> - We're unable to tell whether the value passed in to_python is already 
> encoded JSON
> - Because of this we can't store certain types of JSON values that should 
> be valid
> - The issues seems to be with the fact that Django uses to_python for both 
> the serialized and original value
>
> This might be an issue that needs to be fixed with Django itself, but I 
> wanted to reach out here first and see if anyone had any suggestions on how 
> to solve this.
>
> Any help is appreciated.
>
> Thanks,
> Brad
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: memory leak in django 1.5

2013-03-21 Thread Craig de Stigter
Karen Tracey saves the day!

Thanks so much, seems likely that's it :)

Craig de Stigter

On Friday, March 22, 2013 2:25:04 PM UTC+13, Karen Tracey wrote:
>
> On Thu, Mar 21, 2013 at 9:00 PM, Craig de Stigter 
> 
> > wrote:
>
>> Hi everyone
>>
>> (cross-posted because this seems relevant to both django-users and 
>> developers, and both might have experienced this problem)
>>
>> We've noticed a gradual increase in memory usage for our apache processes 
>> since upgrading to django 1.5.
>>
>> Here is a graph  showing memory usage 
>> before and after we upgraded to django 1.5 on our web server. (the upgrade 
>> occurs at 12:30 on the graph).
>>
>> I'm hoping someone else has noticed a similar thing and is able to 
>> provide some insight.
>>
>
> https://code.djangoproject.com/ticket/19895#comment:6
>
> notes a memory leak due to a fix that went into 1.5. 
>
> The fix was reverted on the 1.5.x branch about two days ago, so one thing 
> to try would be to run current 1.5.x branch level rather than released 1.5.
>
> Karen
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: memory leak in django 1.5

2013-03-21 Thread Craig de Stigter
Karen Tracey saves the day!

Thanks so much, seems likely that's it :)

Craig de Stigter

On Friday, March 22, 2013 2:25:04 PM UTC+13, Karen Tracey wrote:
>
> On Thu, Mar 21, 2013 at 9:00 PM, Craig de Stigter 
> 
> > wrote:
>
>> Hi everyone
>>
>> (cross-posted because this seems relevant to both django-users and 
>> developers, and both might have experienced this problem)
>>
>> We've noticed a gradual increase in memory usage for our apache processes 
>> since upgrading to django 1.5.
>>
>> Here is a graph  showing memory usage 
>> before and after we upgraded to django 1.5 on our web server. (the upgrade 
>> occurs at 12:30 on the graph).
>>
>> I'm hoping someone else has noticed a similar thing and is able to 
>> provide some insight.
>>
>
> https://code.djangoproject.com/ticket/19895#comment:6
>
> notes a memory leak due to a fix that went into 1.5. 
>
> The fix was reverted on the 1.5.x branch about two days ago, so one thing 
> to try would be to run current 1.5.x branch level rather than released 1.5.
>
> Karen
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Automated Django benchmarking with New Relic

2013-03-21 Thread Alan Johnson
I've got a Django web app with a complicated data model that's experiencing 
performance issues. Using New Relic, I was pretty much instantaneously able 
to isolate what the problem to a particular query. But there are a number 
of different solutions I can try. What I'd like to do is be able to 
benchmark the efficacy of different solutions in various combinations. 

In my mind, one way of doing this by hand would be to make a Django model 
that stores configuration flags outside of my settings file, so I could 
change them through the admin instead of redeploying. Then I could monitor 
New Relic and record the metrics into a spreadsheet, or something. 

But I feel like that would be a poor reinvention of something people 
probably do all the time. Is there a good methodology for doing this 
without a whole bunch of manual labor? I'd prefer New Relic, since I 
already know how to measure my problem with it, but I'm open to other 
options.

(cross posted at 
http://stackoverflow.com/questions/15558728/django-new-relic-performance-benchmarking/15560582?noredirect=1#15560582,
 
in case anyone wants points)

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Inspecting form errors in a view

2013-03-21 Thread Aubrey Stark-Toller
On Thu, Mar 21, 2013 at 03:40:39PM -0700, Rainy wrote:
> I believe you can just set self.my_flag = foo in clean method and then 
> check for


Cheers for the reply.

I suspect my original mail could have clearer. Just setting attributes when
checks fail seems to me to be the best way to do this, but it does mean that
if I need to check if, say, an integer field is invalid as it contains a
string then I'd to reimplement this validation in the clean method so that it
sets the necessary attribute on the form, and so on for any other field clean
methods that I may need to use and check.

I realise this is a little beyond what Django's forms where meant for and I
might have to live without some of Django's built-in validation to get this
to work, but I'd thought I'd see if anyone here had any thoughts.

Aubrey

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Python problem

2013-03-21 Thread James
Hey there,

Did first Django app and everything worked find, however my computer 
crashed and after restoring it each time I try to execute any .py file in 
command prompt it says syntax error or that the module doesnt exist...

Would you know any reasons for this? Python is still installed and 
everything that was there before the crash is still there.

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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: memory leak in django 1.5

2013-03-21 Thread Karen Tracey
On Thu, Mar 21, 2013 at 9:00 PM, Craig de Stigter wrote:

> Hi everyone
>
> (cross-posted because this seems relevant to both django-users and
> developers, and both might have experienced this problem)
>
> We've noticed a gradual increase in memory usage for our apache processes
> since upgrading to django 1.5.
>
> Here is a graph  showing memory usage
> before and after we upgraded to django 1.5 on our web server. (the upgrade
> occurs at 12:30 on the graph).
>
> I'm hoping someone else has noticed a similar thing and is able to provide
> some insight.
>

https://code.djangoproject.com/ticket/19895#comment:6

notes a memory leak due to a fix that went into 1.5.

The fix was reverted on the 1.5.x branch about two days ago, so one thing
to try would be to run current 1.5.x branch level rather than released 1.5.

Karen

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




memory leak in django 1.5

2013-03-21 Thread Craig de Stigter
Hi everyone

(cross-posted because this seems relevant to both django-users and
developers, and both might have experienced this problem)

We've noticed a gradual increase in memory usage for our apache processes
since upgrading to django 1.5.

Here is a graph  showing memory usage
before and after we upgraded to django 1.5 on our web server. (the upgrade
occurs at 12:30 on the graph).

I'm hoping someone else has noticed a similar thing and is able to provide
some insight. I've spent two days trying to track down where the leak might
be but so far come up empty.

We are using modwsgi on ubuntu lucid. We were previously running a
pre-release (November) django 1.5a1 with no problems, so the bug must be
somewhere in
https://github.com/koordinates/django/compare/31e616521...e4ba16ce7 .

Unfortunately that's a big diff. I've been unable to reproduce the bug on a
dev server, and I'm not comfortable with doing `git bisect` on our
production box ;)

I've tried using Dozer to track down the leak but it appears to cause
apache to segfault with annoying regularity before finding anything of
consequence.

Any tips welcome

Thanks
Craig de Stigter

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Inspecting form errors in a view

2013-03-21 Thread Rainy


On Thursday, March 21, 2013 5:07:36 PM UTC-4, aub...@deepearth.co.uk wrote:
>
> Hello, 
>
> I have form class that has a relatively lengthy clean method which does 
> field 
> validation (as the validity of fields depends on the values of fields) as 
> well 
> setting error messages on the form itself. I also intend to be part of an 
> app 
> used in multiple views in a few projects. 
>
> I want to run certain actions (aside from the usual slew of validation 
> failure 
> messages) based upon 1) the view in the which the form is being used 2) 
> which 
> clean checks fail. These actions may also need to alter the http response, 
> possibly adding items to the context of the template to be rendered and 
> possibly changing which template to use all together. 
>
> I'm relatively new to the Django framework and I was wandering if anyone 
> had 
> ideas what might a good way to go about this. 
>
> Below are current thoughts on the problem: 
>
> + Have the validation function set variables on the form when validation 
>   checks fail and use these in the view to determine what action to run. 
>  The 
>   problem with this is would mean subclassing existing Django classes and 
>   altering them to set attributes when the built in validation checks 
> fail. 
>


I believe you can just set self.my_flag = foo in clean method and then 
check for
that.   -ak
 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




possible ModelMultipleChoiceField bug

2013-03-21 Thread Josh Cartmell
Today I noticed that while this breaks things complaining about an
unexpected kwarg empty_label:

some_field = forms.ModelMultipleChoiceField(
widget=forms.CheckboxSelectMultiple(),
queryset=SomeM2mField.objects.all(),
empty_label='empty')

doing the following in a form's init works (assuming some_field is the
same without the empty_label kwarg):

self.fields['some_field'].empty_label = 'empty'

This seems to be a bug to me, but I could be wrong, anyone have any
thoughts about it?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django split setting and environment variables

2013-03-21 Thread Mike Dewhirst

On 22/03/2013 7:58am, Alan Johnson wrote:

I think hardcoding local machine development passwords is fine, but it's
still better to store the production passwords in a key-value file that
stays out of source control and is permissioned such that only
authorized developers can directly access the server or the credential
file. Of course any developer with full access to the production servers
also has the password, but at that point, so what? Exactly how to set it
up depends on the hosting setup.


I agree. I like to use a callable to fetch the credentials from a 
non-versioned directory. I have a simple text file with a separate line 
for each item. All settings.py needs to do is something like this ...


dbhost = getcreds('db.host')
DATABASES = {
'default': {
'ENGINE':   'django.db.backends.postgresql_psycopg2',
'NAME': PROJECT,
'USER': dbhost[0],
'PASSWORD': dbhost[1],
'HOST': dbhost[2],
'PORT': dbhost[3],

... where

getcreds(pth='/somewhere/for/this/project', credfile)

This prevents accidentally broadcasting sensitive info when sharing 
settings.py or dropping it on the list when asking for help.





On Thursday, March 21, 2013 2:08:39 PM UTC-4, ke1g wrote:

Are you doing this for password security?  If so, note that, while
not quite as easy as scraping command line argument, your
environment is avilable via /dev/mem, and is trivially available to
any Trojan that an attacker can convince this shell or any of its
children (such as Django or any manage.py app) to execute.

Note, too, that, unless you are going to type this each time that
you start the server, you have to put it in a file somewhere, be it
.bashrc, .bash_profile, or some script file that you use to start
django and the management apps.  And if it's in a file, then it is
at least as good to have it in settings.py .

And if you are willing to type a password, either let settings.py
read it to use to decrypt a file with the full credentials, or use
one of the password manager apps that settings.py can talk to over
the D-bus (linux) or equivalent.

But note that security is hard, and most "simple" home grown
solutions, very likely including my suggestions above, end up by
reducing security.

On Thu, Mar 21, 2013 at 10:42 AM, demet8 > wrote:

I have a common.py, dev.py, and prod.py for my Django settings
files. All files inherit from common.py. I want to keep my
database passwords, database URL, etc stored as environment
variables. I have researched the topic but I am not sure If I
have a clear understanding of it. I am hoping I can get a more
comprehensive answer via this forum. This is what I have thus far:


*In your bash shell type:*

export SOMEAPP_DB_USER='someapp'
export SOMEAPP_DB_PASSWORD='1234'

*In my Django settings file type*:

DATABASE_USER = os.environ.get("SOMEAPP_DB___USER", ")
DATABASE_PASSWORD = os.environ.get("SOMEAPP_DB___PASSWORD", ")

So are my passwords stored in just a terminal session? or are
they being stored in something like my bash_profile?


A means whereby you have to type them to a shell is to type them as
above each time, then run python manage.py runserver, or maybe
better, exec python manage.py runserver (the shell that knows the
password goes away as a process in this case, so maybe you firist
start a secondary bash by typing "bash" at your shell prompt.  Note
that this DOES NOT help you in deployment, behind Apache/mod_wsgi,
for example, since it would be the shell that started Apache that
would have to have these environment variables.  You can add
environment variables in the Apache configuration, by the way, but
that's just another file that knows your password.


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...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com
.
Visit this group at
http://groups.google.com/group/django-users?hl=en
.
For more options, visit https://groups.google.com/groups/opt_out
.



--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




--
You

Inspecting form errors in a view

2013-03-21 Thread aubrey
Hello,

I have form class that has a relatively lengthy clean method which does field
validation (as the validity of fields depends on the values of fields) as well
setting error messages on the form itself. I also intend to be part of an app
used in multiple views in a few projects.

I want to run certain actions (aside from the usual slew of validation failure
messages) based upon 1) the view in the which the form is being used 2) which
clean checks fail. These actions may also need to alter the http response,
possibly adding items to the context of the template to be rendered and 
possibly changing which template to use all together.

I'm relatively new to the Django framework and I was wandering if anyone had
ideas what might a good way to go about this.

Below are current thoughts on the problem:

+ Have the validation function set variables on the form when validation
  checks fail and use these in the view to determine what action to run.  The
  problem with this is would mean subclassing existing Django classes and
  altering them to set attributes when the built in validation checks fail.

+ To have signals fired in the form clean method based upon which validation
  checks fail. This suffers from the same problem as the last approach
  (reimplementing Django internals) and as the actions to be taken may need
  to alter the http response the http response would probably have to be
  passed to the form and then to the signals. This may be a better approach
  than the last one, but it feels awkward having to kick a response object
  around and it doesn't seem right having the output built beyond the views
  control.

+ Subclassing the form, breaking up the clean method in the parent form and
  then stringing these clean methods together in the child child method while
  splicing the actions in.
  
  The downsides to this would be: all the child forms would have to be altered
  if the parent form changed (and worse the form could end up in an app used
  my multiple projects, which would mean changing child forms in a quite few
  places); chopping up the validation check isn't easy job and running all the
  checks actions and splicing in the actions in the child clean method would
  be fairly lengthy; it feels like the actions should not be the form's
  responsibility.

+ Using the error messages set on the form to determine what validation errors
  have occurred. I can't see how this approach would work as I would consider
  the error messages malleable, and worse localised, making it hard to 
  test against them. The only way I could see this working is if the messages
  where replaced with canonical messages and then use these to build humanized
  messages for display, but this seems messy.

Cheers
Aubrey

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Conditionally defined model field in abstract model

2013-03-21 Thread Alan Johnson
I've got an abstract model in my project that I want to use to define a 
field by default on concrete subclasses, but also to allow that field to be 
redefined as something other than the default dynamically.  All of this 
works right now:  

class classproperty(object):
"""
Decorator for making class properties
"""
def __init__(self, fget):
self.fget = fget

def __get__(self, owner_self, owner_cls):
return self.fget(owner_cls)

class BaseModel(models.Model):
class Meta(object):
abstract = True

@classproperty
def _special_attribute_field(self):
return getattr(self, '_bm_special_attribute_field', 'default')

@property
def bm_special_attribute(self):
return getattr(self, self._special_attribute_field)

...and then there are a bunch of methods that use the latter two functions 
to figure out which field to access.  

The problem is that right now, classes inheriting from `BaseModel` have to 
define the `default` field explicitly, even if they don't use 
`_bm_special_attribute_field` to specify something other than the default.  
What I'd like to do is programmatically define `default` on concrete 
submodels *only if* those models don't use `_bm_special_attribute_field` to 
change it to something else, in which case, they should bring their own 
field.  Is there a way to do this, perhaps with metaclasses or something?  
The key thing being that it has to not muck up the Django machinery.

(cross posted from 
http://stackoverflow.com/questions/15249306/django-conditionally-defined-model-field-in-abstract-model,
 
if you want to answer for points)

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django split setting and environment variables

2013-03-21 Thread Tim Cook
I just picked up a copy of "Two Scoops of Django".  It covers this
very, and much more in the area of project setup and management with
Django. Some great lessons learned in this book.  Well worth the
investment.  See the Django resources page for the link.

HTH,

--Tim

On Thu, Mar 21, 2013 at 11:42 AM, demet8  wrote:
> I have a common.py, dev.py, and prod.py for my Django settings files. All
> files inherit from common.py. I want to keep my database passwords, database
> URL, etc stored as environment variables. I have researched the topic but I
> am not sure If I have a clear understanding of it. I am hoping I can get a
> more comprehensive answer via this forum. This is what I have thus far:
>
>
> In your bash shell type:
>
> export SOMEAPP_DB_USER='someapp'
> export SOMEAPP_DB_PASSWORD='1234'
>
> In my Django settings file type:
>
> DATABASE_USER = os.environ.get("SOMEAPP_DB_USER", ")
> DATABASE_PASSWORD = os.environ.get("SOMEAPP_DB_PASSWORD", ")
>
> So are my passwords stored in just a terminal session? or are they being
> stored in something like my bash_profile?
>
> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread Alan Johnson
You don't have to have the databases set up at the same time for the 
django-extensions dumpscript method (nor for the dumpdata method). I 
haven't used it myself, but as I understand it, the script will contain the 
data you need. 

   1. Create the script with existing MySQL running
   2. Reconfigure settings for PostgreSQL
   3. Run the script
   
I'm not saying it's better than any other method, just throwing out the 
option.

On Thursday, March 21, 2013 3:49:33 PM UTC-4, Shawn Milochik wrote:
>
> On Thu, Mar 21, 2013 at 3:44 PM, Lachlan Musicman 
> > 
> wrote: 
> > Frocco, 
> > 
> > No, he's saying you can have two databases set up at the same time. 
> > You can have X databases (I presume). 
> > 
> > Cheers 
> > L. 
> > 
> > On 22 March 2013 01:13, frocco > wrote: 
> >> Hi Alan, 
> >> 
> >> so you are saying I should connect django to mysql first and then 
> generate 
> >> the script. 
> >> Then connect django to postgresql and do the import? 
> >> 
>
>
> Actually, I think that's exactly what he meant. If MySQL is working, 
> do the dumpdata commands. Save the output. Change your settings to use 
> Postgres. Then run the loaddata commands. At that point, you've 
> successfully replaced MySQL with Postgres. 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django split setting and environment variables

2013-03-21 Thread Alan Johnson
I think hardcoding local machine development passwords is fine, but it's 
still better to store the production passwords in a key-value file that 
stays out of source control and is permissioned such that only authorized 
developers can directly access the server or the credential file. Of course 
any developer with full access to the production servers also has the 
password, but at that point, so what? Exactly how to set it up depends on 
the hosting setup.


On Thursday, March 21, 2013 2:08:39 PM UTC-4, ke1g wrote:
>
> Are you doing this for password security?  If so, note that, while not 
> quite as easy as scraping command line argument, your environment is 
> avilable via /dev/mem, and is trivially available to any Trojan that an 
> attacker can convince this shell or any of its children (such as Django or 
> any manage.py app) to execute.
>
> Note, too, that, unless you are going to type this each time that you 
> start the server, you have to put it in a file somewhere, be it .bashrc, 
> .bash_profile, or some script file that you use to start django and the 
> management apps.  And if it's in a file, then it is at least as good to 
> have it in settings.py .
>
> And if you are willing to type a password, either let settings.py read it 
> to use to decrypt a file with the full credentials, or use one of the 
> password manager apps that settings.py can talk to over the D-bus (linux) 
> or equivalent.
>
> But note that security is hard, and most "simple" home grown solutions, 
> very likely including my suggestions above, end up by reducing security.
>
> On Thu, Mar 21, 2013 at 10:42 AM, demet8  >wrote:
>
>> I have a common.py, dev.py, and prod.py for my Django settings files. All 
>> files inherit from common.py. I want to keep my database passwords, 
>> database URL, etc stored as environment variables. I have researched the 
>> topic but I am not sure If I have a clear understanding of it. I am hoping 
>> I can get a more comprehensive answer via this forum. This is what I have 
>> thus far: 
>>
>>
>> *In your bash shell type:*
>>
>> export SOMEAPP_DB_USER='someapp'
>> export SOMEAPP_DB_PASSWORD='1234'
>>
>> *In my Django settings file type*:
>>
>> DATABASE_USER = os.environ.get("SOMEAPP_DB_**USER", ")
>> DATABASE_PASSWORD = os.environ.get("SOMEAPP_DB_**PASSWORD", ")
>>
>> So are my passwords stored in just a terminal session? or are they being 
>> stored in something like my bash_profile? 
>>
>
> A means whereby you have to type them to a shell is to type them as above 
> each time, then run python manage.py runserver, or maybe better, exec 
> python manage.py runserver (the shell that knows the password goes away as 
> a process in this case, so maybe you firist start a secondary bash by 
> typing "bash" at your shell prompt.  Note that this DOES NOT help you in 
> deployment, behind Apache/mod_wsgi, for example, since it would be the 
> shell that started Apache that would have to have these environment 
> variables.  You can add environment variables in the Apache configuration, 
> by the way, but that's just another file that knows your password.
>
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

2013-03-21 Thread Bill Freeman
Setting an environment variable is done by saying something like:

lightning@rigel5:~$ export DJANGO_SETTINGS_MODULE='mysite.settings'

assuming that your settings.py file is in a directory named "mysite", in
turn in the current directory (your home directory, if I interpret your
prompt string correctly).  Then that command may work.

But that's the painful way to do that.  Presumably there is a file named
manage.py either in the same directory as settings.py (older Djangos) or
one directory up (newer Djangos).  'cd' to the directory containing
manage.py and type:

lightning@rigel5:pathToDirectoryContainingManage_py$ python manage.py
diffsettings

If you look at manage.py with 'less' or with an editor, you will see that
it sets the DJANGO_SETTINGS_MODULE environment variable (though using
python code, rather than shell code) appropriately (for use from the
current directory) before doing other stuff.

For my money, django-admin.py should only ever be used for its startproject
command.  Everything else should be done with manage.py after cd'ing to the
directory that contains it (or from a wsgi script, which also sets the
DJANGO_SETTINGS_MODULE environment variable and adjusts sys.path to be sure
that the directory containing manage.py is there, but that will come much
later for you, I think).

Bill

On Thu, Mar 21, 2013 at 1:13 PM, Lightning  wrote:

>
>
> On Wednesday, March 20, 2013 11:50:49 PM UTC-7, Lightning wrote:
>>
>>
>> 
>> **
>>
>> [image: enter image description here]I need help configuring for a
>> database. Is there a paper I can read that will give me an overview on this
>> procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.
>>
>> ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
>> class LazySettings(LazyObject):
>> """
>> A lazy proxy for either global Django settings or a custom settings 
>> object.
>> The user can manually configure settings prior to using them. Otherwise,
>> Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
>> """
>>
>>
>
>
>  ImproperlyConfigured: Requested setting USE_I18N, but settings are not
> configured. You must either define the environment variable
> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
> settings.
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread Shawn Milochik
On Thu, Mar 21, 2013 at 3:44 PM, Lachlan Musicman  wrote:
> Frocco,
>
> No, he's saying you can have two databases set up at the same time.
> You can have X databases (I presume).
>
> Cheers
> L.
>
> On 22 March 2013 01:13, frocco  wrote:
>> Hi Alan,
>>
>> so you are saying I should connect django to mysql first and then generate
>> the script.
>> Then connect django to postgresql and do the import?
>>


Actually, I think that's exactly what he meant. If MySQL is working,
do the dumpdata commands. Save the output. Change your settings to use
Postgres. Then run the loaddata commands. At that point, you've
successfully replaced MySQL with Postgres.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread Lachlan Musicman
Frocco,

No, he's saying you can have two databases set up at the same time.
You can have X databases (I presume).

Cheers
L.

On 22 March 2013 01:13, frocco  wrote:
> Hi Alan,
>
> so you are saying I should connect django to mysql first and then generate
> the script.
> Then connect django to postgresql and do the import?
>
>
> On Thursday, March 21, 2013 9:58:37 AM UTC-4, Alan Johnson wrote:
>>
>> I want to echo the support for Postgres. I find it to be a bit more arcane
>> than MySQL, but even in an extremely DB intensive app, Django's ORM is so
>> slick that I rarely have to muck around in Postgres land. I think it's
>> slightly better supported by Django, if you need to use things like
>> distinct(), and other tiny little differences. Two Scoops of Django, which
>> someone mentioned earlier, has become like a holy book to me when it comes
>> to deployment, and they endorse Postgres as well. Navicat is indispensable
>> for getting out of the ORM and seeing what the hell is going on in your DB,
>> as I'm sure you already know. For another migration method, I'll also throw
>> out the option of djang-extensions dumpscript
>> (http://pythonhosted.org/django-extensions/dumpscript.html), which generates
>> the ORM commands to create your database, and can be used for migration.
>>
>>
>> On Monday, March 18, 2013 11:30:35 AM UTC-4, frocco wrote:
>>>
>>> Hello,
>>>
>>> What is the recommended database for django?
>>>
>>> I have used MySQL, but am interested in Postgres.
>>>
>>> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django split setting and environment variables

2013-03-21 Thread Bill Freeman
Are you doing this for password security?  If so, note that, while not
quite as easy as scraping command line argument, your environment is
avilable via /dev/mem, and is trivially available to any Trojan that an
attacker can convince this shell or any of its children (such as Django or
any manage.py app) to execute.

Note, too, that, unless you are going to type this each time that you start
the server, you have to put it in a file somewhere, be it .bashrc,
.bash_profile, or some script file that you use to start django and the
management apps.  And if it's in a file, then it is at least as good to
have it in settings.py .

And if you are willing to type a password, either let settings.py read it
to use to decrypt a file with the full credentials, or use one of the
password manager apps that settings.py can talk to over the D-bus (linux)
or equivalent.

But note that security is hard, and most "simple" home grown solutions,
very likely including my suggestions above, end up by reducing security.

On Thu, Mar 21, 2013 at 10:42 AM, demet8  wrote:

> I have a common.py, dev.py, and prod.py for my Django settings files. All
> files inherit from common.py. I want to keep my database passwords,
> database URL, etc stored as environment variables. I have researched the
> topic but I am not sure If I have a clear understanding of it. I am hoping
> I can get a more comprehensive answer via this forum. This is what I have
> thus far:
>
>
> *In your bash shell type:*
>
> export SOMEAPP_DB_USER='someapp'
> export SOMEAPP_DB_PASSWORD='1234'
>
> *In my Django settings file type*:
>
> DATABASE_USER = os.environ.get("SOMEAPP_DB_**USER", ")
> DATABASE_PASSWORD = os.environ.get("SOMEAPP_DB_**PASSWORD", ")
>
> So are my passwords stored in just a terminal session? or are they being
> stored in something like my bash_profile?
>

A means whereby you have to type them to a shell is to type them as above
each time, then run python manage.py runserver, or maybe better, exec
python manage.py runserver (the shell that knows the password goes away as
a process in this case, so maybe you firist start a secondary bash by
typing "bash" at your shell prompt.  Note that this DOES NOT help you in
deployment, behind Apache/mod_wsgi, for example, since it would be the
shell that started Apache that would have to have these environment
variables.  You can add environment variables in the Apache configuration,
by the way, but that's just another file that knows your password.

>
> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django on Mediatemple DV (4.0) in Virtualenv

2013-03-21 Thread Bill Freeman
Have you considered a reverse proxy to something like gunicorn?

The way that I know how to do this involves mod_rewrite - I don't know of
of the top of my head whether it also requires mod_proxy.  Are these
available to you.  I understand that gunicorn is to be preferred to
fastcgi, which I haven't used.  I haven't actually set up gunicorn, but
have done reverse proxy configuration for it (a skill acquired while
suffering under plone).

Another approach is your own separate Apache build, assuming you have
development tools and either the ability to run this in place of the
provided apache or the ability to proxy, as above, but this time to your
private Apache.

Still, if its true that the best these guys can provide is python2.4 and
mod_python, maybe it is time to switch.  I'm pretty happy with my linode.
For shared hosting I've deployed a lot of sites to webfaction, and have no
complaints.  EC2, if I recall, is a bit dear, but you can roll your own
distro for it, if necessary.  There's a big wonderful world out there.

Bill

On Thu, Mar 21, 2013 at 10:38 AM, Tim Walzer wrote:

> Thats what I was afraid of.  Unfortunately Media Temple DVs come
> pre-installed with Plesk which in turn comes pre-installed with weird
> versions of different software packages, none of which are mod_wsgi.  At
> this point I have not figured out a way to install mod_wsgi without
> breaking the entire thing.  Maybe its time to move on to a different host.
>
> On Thursday, March 14, 2013 3:37:22 PM UTC-6, Tim Walzer wrote:
>>
>> I am currently trying to install Django on a Mediatemple DV (4.0) server
>> and have the installation be within a virtualenv.  The django app will be
>> run from a subdomain, *parts.domain.com*, while the root domain *
>> domain.com* is serving a wordpress site.
>>
>> I have django installed inside the virtualenv at */var/www/vhosts/
>> domain.com/parts/env/* The virtual environment is *'env'.  *The server
>> is running python 2.4.3, but I needed at least 2.6, so I installed 2.6
>> inside the virtual env and that worked perfectly for setting up the initial
>> django site.  Now the problem comes with the running of django.
>>
>> I created a vhost.conf file under */var/www/vhosts/parts.domain.com/conf*
>> *
>> *
>> 
>>SetHandler python-program
>> PythonPath 
>> "['/var/www/vhosts/domain.com/**parts/env/bin',
>> '/var/www/vhosts/domain.com/**parts/env/store']
>> + sys.path"
>> PythonHandler virtualproject
>> SetEnv DJANGO_SETTINGS_MODULE store.settings
>> 
>>
>>  The path to virtualproject, referenced in the PythonHandler line, is *
>> /var/www/vhosts/domain.com/parts/env/bin/virtualproject.py.  *
>>
>> The contents of that file are:
>>
>> *activate_this = '/var/www/vhosts/domain.com/
>> parts/env/bin/activate_this.py'*
>> *execfile(activate_this, dict(__file__=activate_this))*
>> *
>> *
>> *from django.core.handlers.modpython import handler*
>> *
>> *
>> The activate_this.py file is the one that comes with the virtualenv
>> installation
>>
>> When I go to the site *parts.domain.com*, I get the following error in
>> the apache logs:
>>
>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>> virtualproject: Traceback (most recent call last):
>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>> virtualproject:   File "/usr/lib64/python2.4/site-**
>> packages/mod_python/apache.py"**, line 287, in HandlerDispatch\n
>>  log=debug)
>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>> virtualproject:   File "/usr/lib64/python2.4/site-**
>> packages/mod_python/apache.py"**, line 464, in import_module\nmodule
>> = imp.load_module(mname, f, p, d)
>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>> virtualproject:   File "/var/www/vhosts/domain.com/**
>> parts/env/bin/virtualproject.**py",
>> line 4, in ?\nfrom django.core.handlers.modpython import handler
>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>> virtualproject: ImportError: No module named django.core.handlers.modpython
>>
>> I can only think that this is happening because apache is attempting to
>> use the system default python2.4 instead of the one in my virtualenv where
>> django is installed.  How do I fix this?
>>
>  --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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

Re: I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

2013-03-21 Thread Lightning


On Wednesday, March 20, 2013 11:50:49 PM UTC-7, Lightning wrote:
>
>
> 
>  
> **
>
> [image: enter image description here]I need help configuring for a 
> database. Is there a paper I can read that will give me an overview on this 
> procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.
>
> ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
> class LazySettings(LazyObject):
> """
> A lazy proxy for either global Django settings or a custom settings 
> object.
> The user can manually configure settings prior to using them. Otherwise,
> Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
> """
>
>


 ImproperlyConfigured: Requested setting USE_I18N, but settings are not 
configured. You must either define the environment variable 
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
settings.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django problem:AttributeError:Manage isn't accessible via Link instances

2013-03-21 Thread Tom Evans
On Thu, Mar 21, 2013 at 7:49 AM, simon xue  wrote:
> Hi,When I read the book named "Learning Website Development With
> Django",step by step to doing the example,When I read to page 31,"To get an
> object by ID,type the following:>>>Link.object.get(id=1)   " I got this
> error: "Traceback :
> File "",line 1,in
> File"c:\python27\lib\site-packages\django\db\models\managers.py",line 232,in
> __get__
> raise AttributeError("manager isn't accessible via %s instances" %
> type.__name__)
> AttributeError: Manage isn't accessible via Link instances"
>
> How can I solve this problem?
>
> Thank U
>

You cannot access the 'objects' attribute through an instance of a
class, you must do it through the class method.

In addition to what Matt said ('objects', not 'object'), this could
happen if you typed exactly what you had said if you had redefined
what 'List' refers to. Eg:

>>> Link.objects.get(id=1)

>>> Link = Link.objects.get(id=1)
>>> Link.objects.get(id=1)
Traceback (most recent call last):
  File "", line 1, in 
  File "…/django/db/models/manager.py", line 219, in __get__
raise AttributeError("Manager isn't accessible via %s instances" %
type.__name__)
AttributeError: Manager isn't accessible via Link instances


If you are still having problems, copy and past your entire console
session so that we can see what you have done!

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django problem:AttributeError:Manage isn't accessible via Link instances

2013-03-21 Thread Matt Woodward
On Thursday, March 21, 2013 12:49:45 AM UTC-7, simon xue wrote:
>
> When I read to page 31,"To get an object by ID,type the following:
> >>>Link.object.get(id=1)


Unless this is just a typo that should be objects plural:
Link.objects.get(id=1)

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django split setting and environment variables

2013-03-21 Thread demet8
I have a common.py, dev.py, and prod.py for my Django settings files. All 
files inherit from common.py. I want to keep my database passwords, 
database URL, etc stored as environment variables. I have researched the 
topic but I am not sure If I have a clear understanding of it. I am hoping 
I can get a more comprehensive answer via this forum. This is what I have 
thus far: 


*In your bash shell type:*

export SOMEAPP_DB_USER='someapp'
export SOMEAPP_DB_PASSWORD='1234'

*In my Django settings file type*:

DATABASE_USER = os.environ.get("SOMEAPP_DB_USER", ")
DATABASE_PASSWORD = os.environ.get("SOMEAPP_DB_PASSWORD", ")

So are my passwords stored in just a terminal session? or are they being 
stored in something like my bash_profile? 

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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django on Mediatemple DV (4.0) in Virtualenv

2013-03-21 Thread Tim Walzer
Thats what I was afraid of.  Unfortunately Media Temple DVs come 
pre-installed with Plesk which in turn comes pre-installed with weird 
versions of different software packages, none of which are mod_wsgi.  At 
this point I have not figured out a way to install mod_wsgi without 
breaking the entire thing.  Maybe its time to move on to a different host.

On Thursday, March 14, 2013 3:37:22 PM UTC-6, Tim Walzer wrote:
>
> I am currently trying to install Django on a Mediatemple DV (4.0) server 
> and have the installation be within a virtualenv.  The django app will be 
> run from a subdomain, *parts.domain.com*, while the root domain *
> domain.com* is serving a wordpress site.
>
> I have django installed inside the virtualenv at */var/www/vhosts/
> domain.com/parts/env/* The virtual environment is *'env'.  *The server is 
> running python 2.4.3, but I needed at least 2.6, so I installed 2.6 inside 
> the virtual env and that worked perfectly for setting up the initial django 
> site.  Now the problem comes with the running of django.
>
> I created a vhost.conf file under */var/www/vhosts/parts.domain.com/conf*
> *
> *
> 
>SetHandler python-program
> PythonPath "['/var/www/vhosts/domain.com/parts/env/bin', 
> '/var/www/vhosts/domain.com/parts/env/store'] + sys.path"
> PythonHandler virtualproject
> SetEnv DJANGO_SETTINGS_MODULE store.settings
> 
>
>  The path to virtualproject, referenced in the PythonHandler line, is *
> /var/www/vhosts/domain.com/parts/env/bin/virtualproject.py.  *
>
> The contents of that file are:
>
> *activate_this = '/var/www/vhosts/
> domain.com/parts/env/bin/activate_this.py'*
> *execfile(activate_this, dict(__file__=activate_this))*
> *
> *
> *from django.core.handlers.modpython import handler*
> *
> *
> The activate_this.py file is the one that comes with the virtualenv 
> installation
>
> When I go to the site *parts.domain.com*, I get the following error in 
> the apache logs:
>
> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler virtualproject: 
> Traceback (most recent call last):
> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler virtualproject: 
>   File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 287, 
> in HandlerDispatch\nlog=debug)
> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler virtualproject: 
>   File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 464, 
> in import_module\nmodule = imp.load_module(mname, f, p, d)
> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler virtualproject: 
>   File "/var/www/vhosts/domain.com/parts/env/bin/virtualproject.py", line 
> 4, in ?\nfrom django.core.handlers.modpython import handler
> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler virtualproject: 
> ImportError: No module named django.core.handlers.modpython
>
> I can only think that this is happening because apache is attempting to 
> use the system default python2.4 instead of the one in my virtualenv where 
> django is installed.  How do I fix this?
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread frocco
Hi Alan,

so you are saying I should connect django to mysql first and then generate 
the script.
Then connect django to postgresql and do the import?

On Thursday, March 21, 2013 9:58:37 AM UTC-4, Alan Johnson wrote:
>
> I want to echo the support for Postgres. I find it to be a bit more arcane 
> than MySQL, but even in an extremely DB intensive app, Django's ORM is so 
> slick that I rarely have to muck around in Postgres land. I think it's *
> slightly* better supported by Django, if you need to use things like 
> distinct(), and other tiny little differences. Two Scoops of Django, which 
> someone mentioned earlier, has become like a holy book to me when it comes 
> to deployment, and they endorse Postgres as well. Navicat is indispensable 
> for getting out of the ORM and seeing what the hell is going on in your DB, 
> as I'm sure you already know. For another migration method, I'll also throw 
> out the option of djang-extensions dumpscript (
> http://pythonhosted.org/django-extensions/dumpscript.html), which 
> generates the ORM commands to create your database, and can be used for 
> migration.
>
>
> On Monday, March 18, 2013 11:30:35 AM UTC-4, frocco wrote:
>>
>> Hello,
>>
>> What is the recommended database for django?
>>
>> I have used MySQL, but am interested in Postgres.
>>
>> 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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




RE: Apache JQuery deployment advice

2013-03-21 Thread Sells, Fred
I do use CVS for source code control and have upgrading to git on my which 
list.   Changing from a binary build...deploy model to an ASCII deploy model 
does provide the opportunity to move out of the stone ages, just need to carve 
out some time/approval for git.

I'm still wrapping my head around staticfiles in django.  I guess I need to try 
it before I can ask intelligent questions.

Thanks for the eye opener.

Fred.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Michael Pimmer
Sent: Wednesday, March 20, 2013 6:34 PM
To: django-users@googlegroups.com
Subject: Re: Apache JQuery deployment advice

Have you ever worked with anything like SVN or GIT?

Templates are a very basic and useful thing, make sure you know what Django 
offers and why you don't want to use it.
As already mentioned: take a look at django South, too.



On 21/03/13 05:28, Sells, Fred wrote:
I'm converting a Java jnlp app with a tomcat backend to an HTML5/jQuery/AJAX UI 
with a Django/Apache backend.

This is an intranet application with <50 users and a very light workload.  Idle 
90% of the time and ~5 users active at a time.  There are only 2 or 3 pages in 
the entire project.  I don't think I need templates at all but can handle it 
with one static HTML page and AJAX, using jQuery's .load() function to assemble 
the "components" combined with a tabnavigator to change views.

While this application is not very "busy" it is very complex and the 
requirements change frequently.

My concern is coming up with a deploy strategy that makes it easy to manage 
upgrades and the occasional revert when an upgrade is buggy.  And yes I know it 
should be tested better, but there are internal issues that prevent that.

All my prior apps have used Adobe's Flex/Flash for client,  XML for data 
transfer and Apache/Django 1.3/MySQL for the server.  In those applications I 
would use a "daisy chain" of symlinks to point to the current deploy like this

Maindeploydir
/v001
   /v002
   ...
   /v099
   /current -> v099

Under htdocs and under my wsgi directory I would have symlinks that point to 
/home/maindeploydir/current/gui  and /home/maindeploydir/current/mydjangosite 
respectively

Thus a new deployment just involves changes the "current" symlink.

This seemed reasonable when the client was build using the Flex IDE and the 
server was built using Eclipse/PyDev.  But now that I'm abandoning Flex, I 
think there should be a better way.  Perhaps my lack of experience with 
staticfiles is a factor in not seeing the light, but I would appreciate some 
insight into a sound deployment strategy.

Thanks,

Fred.


--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread Alan Johnson
I want to echo the support for Postgres. I find it to be a bit more arcane 
than MySQL, but even in an extremely DB intensive app, Django's ORM is so 
slick that I rarely have to muck around in Postgres land. I think it's *
slightly* better supported by Django, if you need to use things like 
distinct(), and other tiny little differences. Two Scoops of Django, which 
someone mentioned earlier, has become like a holy book to me when it comes 
to deployment, and they endorse Postgres as well. Navicat is indispensable 
for getting out of the ORM and seeing what the hell is going on in your DB, 
as I'm sure you already know. For another migration method, I'll also throw 
out the option of djang-extensions dumpscript 
(http://pythonhosted.org/django-extensions/dumpscript.html), which 
generates the ORM commands to create your database, and can be used for 
migration.


On Monday, March 18, 2013 11:30:35 AM UTC-4, frocco wrote:
>
> Hello,
>
> What is the recommended database for django?
>
> I have used MySQL, but am interested in Postgres.
>
> 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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread frocco
Yes, I used pip

I get this error.

py-mysql2pgsql' is not recognized as an internal or external command

On Thursday, March 21, 2013 9:35:54 AM UTC-4, Patrick Craston wrote:
>
> I have found the py-mysql2pgsql to work without problems.
>
>  
>
> Did you install it using “pip install py-mysql2pgsql” (if you are using a 
> virtualenv make sure you are running it from there or have activated the 
> virtualenv)?
>
>  
>
> No command found suggests there is a problem with your path and it can’t 
> find the script.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *frocco
> *Sent:* 21 March 2013 13:06
> *To:* django...@googlegroups.com 
> *Subject:* Re: PostgresSQL or MySql with django?
>
>  
>
> Has anyone used this?
>
>  
>
> https://github.com/lanyrd/mysql-postgresql-converter/
>
>  
>
> I cannot get this working, says cannot find the file
>
> On Thursday, March 21, 2013 8:14:04 AM UTC-4, frocco wrote:
>
> I have not been able to get this to work.
>
> Says no command found.
>
>  
>
> I must say, porting Mysql data to Postgresql is a big pain on a mac.
>
> I am almost inclined to stay with mysql.
>
>  
>
> I googled for an easy solution, but could not find anything except 
> dbconvert for 100.00
>
>
>
> On Wednesday, March 20, 2013 10:20:19 AM UTC-4, Patrick Craston wrote:
>
> Alternatively, I've found this tool works very well: 
>
> https://pypi.python.org/pypi/py-mysql2pgsql 
>
> (only thing to look out for are Django IPAddressFields as they are 
> char(15) fields in MySQL and inet fields in Postgres - py-mysql2pgsql is 
> obviously not aware of this) 
>
> HTH 
>
> Patrick 
>
> -Original Message- 
> From: django...@googlegroups.com [mailto:django...@googlegroups.com] On 
> Behalf Of Tom Evans 
> Sent: 20 March 2013 14:12 
> To: django...@googlegroups.com 
> Subject: Re: PostgresSQL or MySql with django? 
>
> On Wed, Mar 20, 2013 at 1:54 PM, frocco  wrote: 
> > Hello, 
> > 
> > I know this is not django related, but can someone help me with the 
> > syntax to port mysql to postgresql? 
> > I tried the mysqldump command with the postgresql compatibility 
> > option, but I still cannot import the data. 
> > 
> > Thanks 
> > 
> > 
>
> Django itself has mechanisms for importing and exporting data in a 
> database independent format: 
>
>
> https://docs.djangoproject.com/en/1.5/ref/django-admin/#django-admin-dumpdata 
>
> If you are not dealing with huge amounts of data, this can be the simplest 
> way forward. 
>
> Cheers 
>
> Tom 
>
> -- 
> 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?hl=en. 
> For more options, visit https://groups.google.com/groups/opt_out. 
>
> -- 
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread Tom Evans
On Thu, Mar 21, 2013 at 1:06 PM, frocco  wrote:
> Has anyone used this?
>
> https://github.com/lanyrd/mysql-postgresql-converter/
>
> I cannot get this working, says cannot find the file
>

Why not use dumpdata as I suggested? Add your postgresql database
connection in Django as 'postgres', and do this:

python manage,py syncdb --database postgres
python manage.py dumpdata -a > data.json
python manage.py loaddata --database postgres data.json

Then edit settings.py, change the 'postgres' connection to be named
'defaut' and remove your existing mysql default.

This is much easier than messing around trying to get a script which
knows nothing about your database to convert everything correctly.

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




RE: PostgresSQL or MySql with django?

2013-03-21 Thread Patrick Craston
I have found the py-mysql2pgsql to work without problems.

Did you install it using "pip install py-mysql2pgsql" (if you are using a 
virtualenv make sure you are running it from there or have activated the 
virtualenv)?

No command found suggests there is a problem with your path and it can't find 
the script.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of frocco
Sent: 21 March 2013 13:06
To: django-users@googlegroups.com
Subject: Re: PostgresSQL or MySql with django?

Has anyone used this?

https://github.com/lanyrd/mysql-postgresql-converter/

I cannot get this working, says cannot find the file

On Thursday, March 21, 2013 8:14:04 AM UTC-4, frocco wrote:
I have not been able to get this to work.
Says no command found.

I must say, porting Mysql data to Postgresql is a big pain on a mac.
I am almost inclined to stay with mysql.

I googled for an easy solution, but could not find anything except dbconvert 
for 100.00


On Wednesday, March 20, 2013 10:20:19 AM UTC-4, Patrick Craston wrote:
Alternatively, I've found this tool works very well:

https://pypi.python.org/pypi/py-mysql2pgsql

(only thing to look out for are Django IPAddressFields as they are char(15) 
fields in MySQL and inet fields in Postgres - py-mysql2pgsql is obviously not 
aware of this)

HTH

Patrick

-Original Message-
From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of Tom Evans
Sent: 20 March 2013 14:12
To: django...@googlegroups.com
Subject: Re: PostgresSQL or MySql with django?

On Wed, Mar 20, 2013 at 1:54 PM, frocco 
mailto:far...@gmail.com>> wrote:
> Hello,
>
> I know this is not django related, but can someone help me with the
> syntax to port mysql to postgresql?
> I tried the mysqldump command with the postgresql compatibility
> option, but I still cannot import the data.
>
> Thanks
>
>

Django itself has mechanisms for importing and exporting data in a database 
independent format:

https://docs.djangoproject.com/en/1.5/ref/django-admin/#django-admin-dumpdata

If you are not dealing with huge amounts of data, this can be the simplest way 
forward.

Cheers

Tom

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 CBV - DeleteView - CustomQuery

2013-03-21 Thread Tom Christie
> Is there a site, where I can found such things like What happens in a CBV 
View?

http://ccbv.co.uk is really great resource.  Can't recommend it highly 
enough.


On Thursday, 21 March 2013 13:23:05 UTC, Christian Schmitt wrote:
>
> Hi, yeah that definitly helps.
> I didn't found a good site where CBVs getting described in that way.
> Is there a site, where I can found such things like
>
> What happens in a CBV View? It's way easier to understand the whole CBV 
> thing. 
> Btw. FBVs are way easier than CBVs but with FBVs I need to copy & paste 
> things like the MarkDeleteClass while in CBVs I could inherit from it.
>
> Am Donnerstag, 21. März 2013 14:11:44 UTC+1 schrieb Tom Christie:
>>
>> In cases like this, rather than rely on overriding the default behavior 
>> of the DeleteView,
>> I'd recommend writing your own base class.
>>
>> It'll be more explicit and more obvious exactly what is going on...
>>
>> from django.views.generic import View
>>
>> class MarkDeletedView(View):
>> """
>> Base class for marking a model instance as deleted.
>> """
>> model = None
>> redirect_url = None
>>
>> def delete(self, request, *args, **kwargs):
>> assert self.model, "model attribute must be set"
>> assert self. redirect_url, "redirect_url attribute must be 
>> set"
>>
>> object = get_object_or_404(self.model, pk=kwargs['pk'])
>> if object.date_deleted is not None:
>> raise Http404
>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>> object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
>> object.save()
>> return HttpResponseRedirect(self.redirect_url)
>>
>> Then you can create a different view for each model you need this 
>> behavior on, like so...
>>
>> class CustomerDeleteView(MarkDeletedView):
>> model = Customer
>> redirect_view = reverse('customer-list')
>>
>> Hope that helps.
>>
>>   Tom
>>
>> On Thursday, 21 March 2013 12:39:34 UTC, Christian Schmitt wrote:
>>
>>> Hello guys,
>>> I have a question about the django CBV DeleteView, I want to use it but 
>>> not delete the element, i just want to set a delete_date so that it isn't 
>>> visible anymore.
>>>
>>> With FBV my view looked like this:
>>>
>>> def delete(request, customer_id):
>>> customer = get_object_or_404(Customer, pk=customer_id)
>>> if customer.date_deleted is not None:
>>> raise Http404
>>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>>> customer.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
>>> customer.save()
>>> return HttpResponseRedirect()
>>>
>>> but know I want to change all my Views with CBVs but I really don't 
>>> understand how I could change the default query on DeleteView. Is there 
>>> somebody who could help me with it?
>>>
>>> I mean it is way easier than to Delete items, since I have one 
>>> DeleteView where I could use to Delete all items.
>>>
>>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 CBV - DeleteView - CustomQuery

2013-03-21 Thread Christian Schmitt
Oh, yeah you gave me a good idea, but no, DELETE is fine. Since I wanted to 
do an ajax request anyway.

Am Donnerstag, 21. März 2013 14:22:59 UTC+1 schrieb Tom Christie:
>
> Actually you'll probably want the `delete` method to be a `post` instead,
> but either way hopefully it'll give you the right idea.
>
> On Thursday, 21 March 2013 13:11:44 UTC, Tom Christie wrote:
>>
>> In cases like this, rather than rely on overriding the default behavior 
>> of the DeleteView,
>> I'd recommend writing your own base class.
>>
>> It'll be more explicit and more obvious exactly what is going on...
>>
>> from django.views.generic import View
>>
>> class MarkDeletedView(View):
>> """
>> Base class for marking a model instance as deleted.
>> """
>> model = None
>> redirect_url = None
>>
>> def delete(self, request, *args, **kwargs):
>> assert self.model, "model attribute must be set"
>> assert self. redirect_url, "redirect_url attribute must be 
>> set"
>>
>> object = get_object_or_404(self.model, pk=kwargs['pk'])
>> if object.date_deleted is not None:
>> raise Http404
>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>> object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
>> object.save()
>> return HttpResponseRedirect(self.redirect_url)
>>
>> Then you can create a different view for each model you need this 
>> behavior on, like so...
>>
>> class CustomerDeleteView(MarkDeletedView):
>> model = Customer
>> redirect_view = reverse('customer-list')
>>
>> Hope that helps.
>>
>>   Tom
>>
>> On Thursday, 21 March 2013 12:39:34 UTC, Christian Schmitt wrote:
>>
>>> Hello guys,
>>> I have a question about the django CBV DeleteView, I want to use it but 
>>> not delete the element, i just want to set a delete_date so that it isn't 
>>> visible anymore.
>>>
>>> With FBV my view looked like this:
>>>
>>> def delete(request, customer_id):
>>> customer = get_object_or_404(Customer, pk=customer_id)
>>> if customer.date_deleted is not None:
>>> raise Http404
>>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>>> customer.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
>>> customer.save()
>>> return HttpResponseRedirect()
>>>
>>> but know I want to change all my Views with CBVs but I really don't 
>>> understand how I could change the default query on DeleteView. Is there 
>>> somebody who could help me with it?
>>>
>>> I mean it is way easier than to Delete items, since I have one 
>>> DeleteView where I could use to Delete all items.
>>>
>>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 CBV - DeleteView - CustomQuery

2013-03-21 Thread Christian Schmitt
Hi, yeah that definitly helps.
I didn't found a good site where CBVs getting described in that way.
Is there a site, where I can found such things like

What happens in a CBV View? It's way easier to understand the whole CBV 
thing. 
Btw. FBVs are way easier than CBVs but with FBVs I need to copy & paste 
things like the MarkDeleteClass while in CBVs I could inherit from it.

Am Donnerstag, 21. März 2013 14:11:44 UTC+1 schrieb Tom Christie:
>
> In cases like this, rather than rely on overriding the default behavior of 
> the DeleteView,
> I'd recommend writing your own base class.
>
> It'll be more explicit and more obvious exactly what is going on...
>
> from django.views.generic import View
>
> class MarkDeletedView(View):
> """
> Base class for marking a model instance as deleted.
> """
> model = None
> redirect_url = None
>
> def delete(self, request, *args, **kwargs):
> assert self.model, "model attribute must be set"
> assert self. redirect_url, "redirect_url attribute must be set"
>
> object = get_object_or_404(self.model, pk=kwargs['pk'])
> if object.date_deleted is not None:
> raise Http404
> now = datetime.datetime.utcnow().replace(tzinfo=utc)
> object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
> object.save()
> return HttpResponseRedirect(self.redirect_url)
>
> Then you can create a different view for each model you need this behavior 
> on, like so...
>
> class CustomerDeleteView(MarkDeletedView):
> model = Customer
> redirect_view = reverse('customer-list')
>
> Hope that helps.
>
>   Tom
>
> On Thursday, 21 March 2013 12:39:34 UTC, Christian Schmitt wrote:
>
>> Hello guys,
>> I have a question about the django CBV DeleteView, I want to use it but 
>> not delete the element, i just want to set a delete_date so that it isn't 
>> visible anymore.
>>
>> With FBV my view looked like this:
>>
>> def delete(request, customer_id):
>> customer = get_object_or_404(Customer, pk=customer_id)
>> if customer.date_deleted is not None:
>> raise Http404
>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>> customer.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
>> customer.save()
>> return HttpResponseRedirect()
>>
>> but know I want to change all my Views with CBVs but I really don't 
>> understand how I could change the default query on DeleteView. Is there 
>> somebody who could help me with it?
>>
>> I mean it is way easier than to Delete items, since I have one DeleteView 
>> where I could use to Delete all items.
>>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 CBV - DeleteView - CustomQuery

2013-03-21 Thread Tom Christie
Actually you'll probably want the `delete` method to be a `post` instead,
but either way hopefully it'll give you the right idea.

On Thursday, 21 March 2013 13:11:44 UTC, Tom Christie wrote:
>
> In cases like this, rather than rely on overriding the default behavior of 
> the DeleteView,
> I'd recommend writing your own base class.
>
> It'll be more explicit and more obvious exactly what is going on...
>
> from django.views.generic import View
>
> class MarkDeletedView(View):
> """
> Base class for marking a model instance as deleted.
> """
> model = None
> redirect_url = None
>
> def delete(self, request, *args, **kwargs):
> assert self.model, "model attribute must be set"
> assert self. redirect_url, "redirect_url attribute must be set"
>
> object = get_object_or_404(self.model, pk=kwargs['pk'])
> if object.date_deleted is not None:
> raise Http404
> now = datetime.datetime.utcnow().replace(tzinfo=utc)
> object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
> object.save()
> return HttpResponseRedirect(self.redirect_url)
>
> Then you can create a different view for each model you need this behavior 
> on, like so...
>
> class CustomerDeleteView(MarkDeletedView):
> model = Customer
> redirect_view = reverse('customer-list')
>
> Hope that helps.
>
>   Tom
>
> On Thursday, 21 March 2013 12:39:34 UTC, Christian Schmitt wrote:
>
>> Hello guys,
>> I have a question about the django CBV DeleteView, I want to use it but 
>> not delete the element, i just want to set a delete_date so that it isn't 
>> visible anymore.
>>
>> With FBV my view looked like this:
>>
>> def delete(request, customer_id):
>> customer = get_object_or_404(Customer, pk=customer_id)
>> if customer.date_deleted is not None:
>> raise Http404
>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>> customer.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
>> customer.save()
>> return HttpResponseRedirect()
>>
>> but know I want to change all my Views with CBVs but I really don't 
>> understand how I could change the default query on DeleteView. Is there 
>> somebody who could help me with it?
>>
>> I mean it is way easier than to Delete items, since I have one DeleteView 
>> where I could use to Delete all items.
>>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 CBV - DeleteView - CustomQuery

2013-03-21 Thread Tom Christie
In cases like this, rather than rely on overriding the default behavior of 
the DeleteView,
I'd recommend writing your own base class.

It'll be more explicit and more obvious exactly what is going on...

from django.views.generic import View

class MarkDeletedView(View):
"""
Base class for marking a model instance as deleted.
"""
model = None
redirect_url = None

def delete(self, request, *args, **kwargs):
assert self.model, "model attribute must be set"
assert self. redirect_url, "redirect_url attribute must be set"

object = get_object_or_404(self.model, pk=kwargs['pk'])
if object.date_deleted is not None:
raise Http404
now = datetime.datetime.utcnow().replace(tzinfo=utc)
object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
object.save()
return HttpResponseRedirect(self.redirect_url)

Then you can create a different view for each model you need this behavior 
on, like so...

class CustomerDeleteView(MarkDeletedView):
model = Customer
redirect_view = reverse('customer-list')

Hope that helps.

  Tom

On Thursday, 21 March 2013 12:39:34 UTC, Christian Schmitt wrote:

> Hello guys,
> I have a question about the django CBV DeleteView, I want to use it but 
> not delete the element, i just want to set a delete_date so that it isn't 
> visible anymore.
>
> With FBV my view looked like this:
>
> def delete(request, customer_id):
> customer = get_object_or_404(Customer, pk=customer_id)
> if customer.date_deleted is not None:
> raise Http404
> now = datetime.datetime.utcnow().replace(tzinfo=utc)
> customer.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
> customer.save()
> return HttpResponseRedirect()
>
> but know I want to change all my Views with CBVs but I really don't 
> understand how I could change the default query on DeleteView. Is there 
> somebody who could help me with it?
>
> I mean it is way easier than to Delete items, since I have one DeleteView 
> where I could use to Delete all items.
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread frocco
Has anyone used this?

https://github.com/lanyrd/mysql-postgresql-converter/

I cannot get this working, says cannot find the file

On Thursday, March 21, 2013 8:14:04 AM UTC-4, frocco wrote:
>
> I have not been able to get this to work.
> Says no command found.
>
> I must say, porting Mysql data to Postgresql is a big pain on a mac.
> I am almost inclined to stay with mysql.
>
> I googled for an easy solution, but could not find anything except 
> dbconvert for 100.00
>
>
> On Wednesday, March 20, 2013 10:20:19 AM UTC-4, Patrick Craston wrote:
>>
>> Alternatively, I've found this tool works very well: 
>>
>> https://pypi.python.org/pypi/py-mysql2pgsql 
>>
>> (only thing to look out for are Django IPAddressFields as they are 
>> char(15) fields in MySQL and inet fields in Postgres - py-mysql2pgsql is 
>> obviously not aware of this) 
>>
>> HTH 
>>
>> Patrick 
>>
>> -Original Message- 
>> From: django...@googlegroups.com [mailto:django...@googlegroups.com] On 
>> Behalf Of Tom Evans 
>> Sent: 20 March 2013 14:12 
>> To: django...@googlegroups.com 
>> Subject: Re: PostgresSQL or MySql with django? 
>>
>> On Wed, Mar 20, 2013 at 1:54 PM, frocco  wrote: 
>> > Hello, 
>> > 
>> > I know this is not django related, but can someone help me with the 
>> > syntax to port mysql to postgresql? 
>> > I tried the mysqldump command with the postgresql compatibility 
>> > option, but I still cannot import the data. 
>> > 
>> > Thanks 
>> > 
>> > 
>>
>> Django itself has mechanisms for importing and exporting data in a 
>> database independent format: 
>>
>>
>> https://docs.djangoproject.com/en/1.5/ref/django-admin/#django-admin-dumpdata
>>  
>>
>> If you are not dealing with huge amounts of data, this can be the 
>> simplest way forward. 
>>
>> Cheers 
>>
>> Tom 
>>
>> -- 
>> 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?hl=en. 
>> For more options, visit https://groups.google.com/groups/opt_out. 
>>
>>
>>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Looking for best practices regarding Development and production server paths

2013-03-21 Thread DJ-Tom


Am Donnerstag, 21. März 2013 13:04:53 UTC+1 schrieb Tom Evans:
>
> In my settings.py, I set the path to the project template folder and 
> project static files like so: 
>
> import os.path 
> ROOT = os.path.abspath(__file__).rsplit(os.path.sep, 2)[0] 
> TEMPLATE_DIRS = ( 
>   os.path.join(ROOT, 'templates'), 
>   ) 
> STATICFILES_DIRS = ( 
>   os.path.join(ROOT, 'static'), 
>   ) 
>

Ok - this should do the job nicely :-) 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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Looking for best practices regarding Development and production server paths

2013-03-21 Thread DJ-Tom



>
> On Thu, Mar 21, 2013 at 5:05 PM, DJ-Tom  >wrote:
> Simple, you maintain two settings.py files, make one with Dev_settings.py 
> and  two with Prod_settings.py.
> You can run dev and production  applications like this 
>
> python manage.py runserver --settings=Dev_settings
>
> python manage.py runserver --settings=Prod_settings
>
> it is all about switching between settings.py files. 
>  


This won't work for me since I'm not using "runserver" on the production 
machine, but Apache/WSGI 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django 1.5 CBV - DeleteView - CustomQuery

2013-03-21 Thread Christian Schmitt
Hello guys,
I have a question about the django CBV DeleteView, I want to use it but not 
delete the element, i just want to set a delete_date so that it isn't 
visible anymore.

With FBV my view looked like this:

def delete(request, customer_id):
customer = get_object_or_404(Customer, pk=customer_id)
if customer.date_deleted is not None:
raise Http404
now = datetime.datetime.utcnow().replace(tzinfo=utc)
customer.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
customer.save()
return HttpResponseRedirect()

but know I want to change all my Views with CBVs but I really don't 
understand how I could change the default query on DeleteView. Is there 
somebody who could help me with it?

I mean it is way easier than to Delete items, since I have one DeleteView 
where I could use to Delete all items.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgresSQL or MySql with django?

2013-03-21 Thread frocco
I have not been able to get this to work.
Says no command found.

I must say, porting Mysql data to Postgresql is a big pain on a mac.
I am almost inclined to stay with mysql.

I googled for an easy solution, but could not find anything except 
dbconvert for 100.00


On Wednesday, March 20, 2013 10:20:19 AM UTC-4, Patrick Craston wrote:
>
> Alternatively, I've found this tool works very well: 
>
> https://pypi.python.org/pypi/py-mysql2pgsql 
>
> (only thing to look out for are Django IPAddressFields as they are 
> char(15) fields in MySQL and inet fields in Postgres - py-mysql2pgsql is 
> obviously not aware of this) 
>
> HTH 
>
> Patrick 
>
> -Original Message- 
> From: django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] On Behalf Of Tom Evans 
> Sent: 20 March 2013 14:12 
> To: django...@googlegroups.com  
> Subject: Re: PostgresSQL or MySql with django? 
>
> On Wed, Mar 20, 2013 at 1:54 PM, frocco > 
> wrote: 
> > Hello, 
> > 
> > I know this is not django related, but can someone help me with the 
> > syntax to port mysql to postgresql? 
> > I tried the mysqldump command with the postgresql compatibility 
> > option, but I still cannot import the data. 
> > 
> > Thanks 
> > 
> > 
>
> Django itself has mechanisms for importing and exporting data in a 
> database independent format: 
>
>
> https://docs.djangoproject.com/en/1.5/ref/django-admin/#django-admin-dumpdata 
>
> If you are not dealing with huge amounts of data, this can be the simplest 
> way forward. 
>
> Cheers 
>
> Tom 
>
> -- 
> 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?hl=en. 
> For more options, visit https://groups.google.com/groups/opt_out. 
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Citing Django

2013-03-21 Thread Casey Greene
Sorry -- I guess I didn't mean the manual of style part, but instead
the various fields. Thanks for your help. Embarrassingly I just
realized that apparently that bug is one that I filed a couple years
ago.

Thanks again!
Casey

On Wed, Mar 20, 2013 at 7:58 PM, Russell Keith-Magee
 wrote:
>
>
> On Thu, Mar 21, 2013 at 5:18 AM, Casey Greene 
> wrote:
>>
>> Does anyone have a standard way of citing Django? This ticket:
>> https://code.djangoproject.com/ticket/15379
>> seems to indicate that the preferred way might be:
>> Django core team (2011). Django: A Web framework for the Python
>> programming language. Django Software Foundation, Lawrence, Kansas,
>> U.S.A. URL http://www.djangoproject.com
>>
>> I'm happy to go with that, but I'd like confirmation that that's the
>> preferred way to go. Thus far we've used Django quite a bit (e.g. its
>> used by both http://imp.princeton.edu and http://pilgrm.princeton.edu
>> ) but it hasn't been cited or discussed in the technical parts of
>> these papers. We do, however, cite R and its packages when we use
>> those methods, since there's a commonly accepted way to do so.
>> Providing this readily might help Django gain additional traction in
>> the academic community (i.e. with regular mentions of the framework
>> and evidence of its appropriateness for various tasks).
>>
>
> There isn't an "official" citation format, for two reasons: citation formats
> can vary wildly between publications, and citation standards for software
> are still a matter of some debate.
>
> APA style [1], for example, would dictate something like:
>
> Django (Version 1.5) [Computer Software]. (2013). Retrieved from
> http://djangoproject.com
>
> However, the only true guide is what your publisher will accept. I'd suggest
> getting hold of your publishers guidelines, and filling in the gaps as best
> you can.
>
> If your referencing style guide requires a publisher name, use "Django
> Software Foundation".
>
> If you need a publishing location, use "Lawrence, Kansas".
>
> If you need a web address, use http://djangoproject.com
>
> If you need a name, just use "Django", without any tagline.
>
> If you need a publication date, use the year of release of the version
> you're referencing (e.g., 2013 for v1.5)
>
> Beyond, that, fill in as seems appropriate for your needs.
>
> [1]
> http://www.usq.edu.au/library/referencing/apa-referencing-guide#Other_electronic_media
>
> Yours,
> Russ Magee %-)
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Casey Greene
Assistant Professor
Department of Genetics
Institute for Quantitative Biomedical Sciences
Norris Cotton Cancer Center
The Geisel School of Medicine at Dartmouth
Hanover, NH

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Looking for best practices regarding Development and production server paths

2013-03-21 Thread Tom Evans
On Thu, Mar 21, 2013 at 11:35 AM, DJ-Tom  wrote:
> Hi,
>
> I'm still a beginner and currently I'm trying to get more familiar with
> Django.
>
> I'm looking for any more detailed best-practices-type description on how the
> development cycle is meant to be managed.
>
> In settings.py, there are paths like TEMPLATE_DIRS and STATICFILE_DIRS, how
> is this supposed to work when paths on the development machine differ from
> the production server?
>
> I suppose I do not have to adjust those paths every time I upload a new
> version of my application?

The easiest way to do this is to specify them in terms of relative
path to the settings file.

Eg, I have this structure for my projects

websitename
├── app1
├── app2
├── manage.py
├── project
│   ├── settings.py
│   └── urls.py
├── static
└── templates

In my settings.py, I set the path to the project template folder and
project static files like so:

import os.path
ROOT = os.path.abspath(__file__).rsplit(os.path.sep, 2)[0]
TEMPLATE_DIRS = (
  os.path.join(ROOT, 'templates'),
  )
STATICFILES_DIRS = (
  os.path.join(ROOT, 'static'),
  )

This then works in both dev, test and live, since the structure is the
same on all three.

>
> Another point, how do I manage the time until the database schemes are
> updated to a new version (I'm planning to use south for database scheme
> maintenance) and nobody is supposed to use the application until
> everything's able to work again?
>

Easiest way is to stop people accessing your web app when you don't
want them to, and re-enable it afterwards. Depending on how you are
hosting Django, there can be a number of different solutions. Eg, for
my sites, hosted with Apache and FCGI, I simply stop the FCGI app, and
Apache shows an appropriately pretty 500 page.

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ver. 1.5] Specifying custom User model (extends AbstractUser) doesn't work

2013-03-21 Thread Lewis Taylor
And this is why I learnt the names of many of those major in the Django 
community! Now if I post after them, it's mostly to say. Yes I agree.

Like I'm doing now :-)

On Wednesday, 24 October 2012 05:02:02 UTC+1, Surya Mukherjee wrote:
>
> Django's standard User class isn't sufficient for my needs so I am making 
> my own User class. As per the User Authentication doc page, I am 
> subclassing AbstractUser (not AbstractBaseUser) to add some new stuff.
>
> 
> from django.contrib.auth.models import AbstractUser
>
> class MyUser(AbstractUser):
> test = 'Hello world'
> 
>
> Pretty simple so far. In settings.py:
> 
> # Specifies SDBUser as the custom User class for Django to use
> AUTH_USER_MODEL = 'app.MyUser'
> 
>
> But when i try to syncdb, everything breaks:
>
> [root@Surya project]# manage syncdb
> CommandError: One or more models did not validate:
> app.userprofile: 'user' defines a relation with the model 'auth.User', 
> which has been swapped out. Update the relation to point at 
> settings.AUTH_USER_MODEL.
> auth.user: Model has been swapped out for 'app.SDBUser' which has not been 
> installed or is abstract.
> django_openid_auth.useropenid: 'user' defines a relation with the model 
> 'auth.User', which has been swapped out. Update the relation to point at 
> settings.AUTH_USER_MODEL.
>
> django_openid_auth is a third party OpenID library, but the first two are 
> pure Django and they're still breaking. Wat do?
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




django ImageField ignores upload_to kwarg

2013-03-21 Thread tomasz ducin
I've fallen into a problem with resolving the correct url of uploaded 
images. I've made sure that my routing/templates work correctly and the 
problem is somewhere inside the model layer.

This is my model class:

from django.db import models
from tinymce.models import HTMLField

class Article(models.Model):
"""News article, displayed on homepage to attract users"""
class Meta:
db_table = 'article'
title = models.CharField(max_length=64)
headline = models.CharField(max_length=255)
content = HTMLField()
image = models.ImageField(upload_to = 'articles', null=True, blank=True)
active = models.BooleanField()
created_at = models.DateTimeField()
def __unicode__(self):
return self.title


Now when I open my django shell, I get wrong url/path values. The 
'upload_to' kwarg (defined in Article model for image field) is ignored and 
I don't know why.

$ ./manage.py shell
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from articles.models import Article
>>> Article.objects.all().get(pk=1)

>>> Article.objects.all().get(pk=1).image.path
u'/var/www/django/djninja/djninja/media/slide-03.jpg'
>>> Article.objects.all().get(pk=1).image.url
'/media/slide-03.jpg'


I've defined MEDIA and MEDIA_ROOT in the settings.py:

PROJECT_DIR = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(PROJECT_DIR, "media")
MEDIA_URL = '/media/'


I expect the path/url to be media/articles/slide.jpg instead of 
media/slide.jpg

Thank you in advance for any suggestions!

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django problem:AttributeError:Manage isn't accessible via Link instances

2013-03-21 Thread simon xue
Hi,When I read the book named "Learning Website Development With 
Django",step by step to doing the example,When I read to page 31,"To get an 
object by ID,type the following:>>>Link.object.get(id=1)   " I got this 
error: "Traceback :
File "",line 1,in
File"c:\python27\lib\site-packages\django\db\models\managers.py",line 
232,in __get__
raise AttributeError("manager isn't accessible via %s instances" % 
type.__name__)
AttributeError: Manage isn't accessible via Link instances"

How can I solve this problem?

Thank U 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

2013-03-21 Thread Lightning

 
**
   
[image: enter image description here]I need help configuring for a 
database. Is there a paper I can read that will give me an overview on this 
procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.

ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
class LazySettings(LazyObject):
"""
A lazy proxy for either global Django settings or a custom settings object.
The user can manually configure settings prior to using them. Otherwise,
Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
"""

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Looking for best practices regarding Development and production server paths

2013-03-21 Thread Sreenivas Reddy T
On Thu, Mar 21, 2013 at 5:05 PM, DJ-Tom  wrote:

> Hi,
>
> I'm still a beginner and currently I'm trying to get more familiar with
> Django.
>
> I'm looking for any more detailed best-practices-type description on how
> the development cycle is meant to be managed.
>
> In settings.py, there are paths like TEMPLATE_DIRS and STATICFILE_DIRS,
> how is this supposed to work when paths on the development machine differ
> from the production server?
>
> Simple, you maintain two settings.py files, make one with Dev_settings.py
and  two with Prod_settings.py.
You can run dev and production  applications like this

python manage.py runserver --settings=Dev_settings

python manage.py runserver --settings=Prod_settings

it is all about switching between settings.py files.



> I suppose I do not have to adjust those paths every time I upload a new
> version of my application?
>
> Another point, how do I manage the time until the database schemes are
> updated to a new version (I'm planning to use south for database scheme
> maintenance) and nobody is supposed to use the application until
> everything's able to work again?


> So far that's all I can think of right now - but I'm sure a lot more
> questions will rise the next few days :-)
>
> Thomas
>
>  --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Looking for best practices regarding Development and production server paths

2013-03-21 Thread DJ-Tom
Hi,

I'm still a beginner and currently I'm trying to get more familiar with 
Django.

I'm looking for any more detailed best-practices-type description on how 
the development cycle is meant to be managed.

In settings.py, there are paths like TEMPLATE_DIRS and STATICFILE_DIRS, how 
is this supposed to work when paths on the development machine differ from 
the production server?

I suppose I do not have to adjust those paths every time I upload a new 
version of my application?

Another point, how do I manage the time until the database schemes are 
updated to a new version (I'm planning to use south for database scheme 
maintenance) and nobody is supposed to use the application until 
everything's able to work again?

So far that's all I can think of right now - but I'm sure a lot more 
questions will rise the next few days :-)

Thomas

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Database setup Issue

2013-03-21 Thread Antoni Aloy
You have to create first the database in Postgresql, give it a name and a
password, and configure it to allow connections. Then you have to configure
the database settings with the database name, ip, user and password.

If you're doing the tutorial is much better to stay in sqlite3, so you'll
have less noise and you could focus on the tutorial itself.


2013/3/21 Kamalakannan Srinivasan 

> Hi,
>
> I installed PostgreSQL 8.4.16 and was trying to set up the database as
> specified in the tutorial under djangoproject.com. I gave the Engine name
> as 'django.db.backends.postgresql_psycopg2' and Name as 'PostgreSQL' and
> ran the python manage.py syncdb command. But it gave the error 'database
> PostgreSQL' does not exist.
>
> I even gave the name in different ways - in caps, in small cases,
> suffixing version number etc. But everything returned similar errors.
>
> Please help with a workaround.
>
> Thanks and regards,
> Kamal
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Database setup Issue

2013-03-21 Thread Kamalakannan Srinivasan
Hi,
 
I installed PostgreSQL 8.4.16 and was trying to set up the database as 
specified in the tutorial under djangoproject.com. I gave the Engine name 
as 'django.db.backends.postgresql_psycopg2' and Name as 'PostgreSQL' and 
ran the python manage.py syncdb command. But it gave the error 'database 
PostgreSQL' does not exist.
 
I even gave the name in different ways - in caps, in small cases, suffixing 
version number etc. But everything returned similar errors.
 
Please help with a workaround.
 
Thanks and regards,
Kamal

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can Django do this?

2013-03-21 Thread Antoni Aloy
Hi Harry,

Please hava a look at:

http://www.apibaleares.com
http://www.trobacaca.com

Both are made with Django, the first one with 1.4.x and de second actually
is 1.2 and initially was 0.96 :) They have the full front-end plus a
customized backend to allow people to upload properties and descriptions.

Hope it helps!



2013/3/21 Harry Ord 

> Hello
>
>  Can i create a website just like this with Django?
>
> http://www.hbn.cl/
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.