Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart

> On Sep 27, 2015, at 06:04, Cai Gengyang  wrote:
> 
> This is my entire settings.py file
> 
> …

I’m not seeing the problem, but it is certainly there somewhere.

Try removing pieces of the settings file until you can isolate the syntax 
problem which is likely on or before line 45. Copy the original one aside so 
you can go back to it and repair the problem once you figure out where it is.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7A42C6CC-7DCE-4C0F-B7D2-6CA67C9F09D6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart

> On Sep 27, 2015, at 05:26, Cai Gengyang  wrote:
> 
> Hi Tom,
> 
> Following your latest instructions , I have posted my input and output 
> results here. Still getting an error message though it is a different one 
> this time ( a traceback error )

Oh, much better :)

You are now seeing a typo in your settings.py file. Without seeing more of the 
file I can not guess at the exact place with the error, but perhaps you have an 
extra or a missing single quote character in a preceeding line in the file??

hth

- Tom


> 
> CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder
> 
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls
> 
> manage.py mysite
> 
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate
> 
> Traceback (most recent call last):
> 
>   File "manage.py", line 10, in 
> 
> execute_from_command_line(sys.argv)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 338, in execute_from_command_line
> 
> utility.execute()
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 303, in execute
> 
> settings.INSTALLED_APPS
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  line 48, in __getattr__
> 
> self._setup(name)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  line 44, in _setup
> 
> self._wrapped = Settings(settings_module)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  line 92, in __init__
> 
> mod = importlib.import_module(self.SETTINGS_MODULE)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
>  line 37, in import_module
> 
> __import__(name)
> 
>   File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45
> 
> 'django.middleware.csrf.CsrfViewMiddleware',
> 
>   ^
> 
> SyntaxError: invalid syntax
> 
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ 
> 
> 
> 
> 
> 
> On Sunday, September 27, 2015 at 7:51:51 PM UTC+8, Thomas wrote:
> 
> > On Sep 27, 2015, at 04:39, Cai Gengyang gmail.com 
> > > wrote: 
> > 
> > Hi Tom, 
> > So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite 
> > folder ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2) 
> > This puts me in the same directory as the manage.py file. 
> > Then I key in the command  : $ python manage.py migrate 
> 
> The command must be typed from a terminal window, and afaik Finder has no 
> influence on the current working directory in that window. 
> 
> Use the Terminal app to open a command line window, then use “cd” or “pushd” 
> to go to “mysite folder” within that terminal window. 
> 
> If that is done correctly, then you should be able to type “ls” and see 
> manage.py in the resulting listing. Then try typing the python command above. 
> 
> btw, I would strongly recommend using virtualenv for developing on your Mac 
> (and on any other system). There are many references to that in this mailing 
> list; do a google search to find a procedure for doing this.
> 
> hth 
> 
> - 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 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/278af114-1a2e-4c4b-ab90-f2c4814d7f4e%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

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


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart

> On Sep 27, 2015, at 04:39, Cai Gengyang  wrote:
> 
> Hi Tom,
> So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite folder 
> ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2)
> This puts me in the same directory as the manage.py file.
> Then I key in the command  : $ python manage.py migrate

The command must be typed from a terminal window, and afaik Finder has no 
influence on the current working directory in that window.

Use the Terminal app to open a command line window, then use “cd” or “pushd” to 
go to “mysite folder” within that terminal window.

If that is done correctly, then you should be able to type “ls” and see 
manage.py in the resulting listing. Then try typing the python command above.

btw, I would strongly recommend using virtualenv for developing on your Mac 
(and on any other system). There are many references to that in this mailing 
list; do a google search to find a procedure for doing this.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C37BDA8F-208C-4656-9C25-68479B07C444%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart
> …
> However, when I try to run the following command : $ python manage.py migrate 
> to create the tables in the database,
> CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate  
> input
> I get the following error message :
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
>  can't open file 'manage.py': [Errno 2] No such file or directory  output

You need to be in the same directory as the file manage.py for the command to 
work. For Django-1.8 that is likely to be one level above your settings.py file.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/EB6F90BA-E19B-4A79-9DF0-3466F4C2AC6C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: extract data from MS SQL database

2015-09-14 Thread Tom Lockhart

> On Sep 14, 2015, at 21:12, sum abiut  wrote:
> 
> Hi all,
> Can someone please point me to right direction. I am trying to extract data 
> from an existing  ms sql database. i just need some direction to get started.

If you are trying to port your data from MySQL to Postgres, you may be able to 
use a combination of scripts available in Postgres and some alter table 
commands to get the datatypes to match up with what Django expects. Some 
columns will need to be converted by hand I would guess (e.g. date/time types?).

If you are just trying to pull some data from some tables, you might find that 
using python is helpful (the library for Postgres is great for sucking in data; 
not sure about the feature set for the MySQL python library).

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54EC97DA-B170-4AC8-A939-62B1652294B6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customization in User Add screen

2015-09-10 Thread Tom Lockhart

> On Sep 9, 2015, at 22:36, Pawanesh Gautam  wrote:
> 
> how to add extra field in user add screen ?? 

afaik you will need to use your own form (in forms.py) which includes the 
fields you want.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23DB57A8-61C2-48A6-A105-6409A187427F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Console Routes With Django ??

2015-08-11 Thread Tom Lockhart

> On Aug 11, 2015, at 12:29, Prabath Peiris  wrote:
> 
> Hi 
> 
> I am new to (kind of) Django framework and just finish the 
> Django-REST-framework tutorials and it looks really cool. I am a big fan of 
> ZendFramework2.0 (with Apigility) and trying to make parallels between these 
> two frameworks. My primary question is about console routes. In ZF2 you can 
> define console routes very easily and execute same controllers as web API 
> requests. What is the best way to accomplish this in Django (specially using 
> REST framework). 
> 
> ZF2 console routes : 
> http://framework.zend.com/manual/current/en/modules/zend.console.routes.html 
> 
affect the equivalent would be Django management commands.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/755F8E03-EE81-4379-876A-563DA2A0321B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: System requirements

2015-07-27 Thread Tom Lockhart

> On Jul 27, 2015, at 11:48, Ingo Hohmann  wrote:
> 
> Thank you.
> 
> It's the age old problem between management and development. I'd say develop 
> on a small server, and then test how far it can go. But someone wants to know 
> _now_.

“Thousands of entries” is relatively small. Unless you have a very large user 
community to drive up server requirements, this sounds like a modest 
installation. Adding in ElasticSearch or Solr for text search will add to the 
footprint but for an initial deployment I would guess that a medium sized AWS 
instance could do what you need.

“Expect the unexpected” works both ways: more capabilities may add to the 
runtime requirements. Unexpectedly.

hth

- Tom

> 
> Am Montag, 27. Juli 2015 19:04:26 UTC+2 schrieb alvaro.rosa1985:
> Não entendi nada.
> Erik Cederstrand  escreveu:
> 
> >
> >> Den 27/07/2015 kl. 07.32 skrev Ingo Hohmann  >> >:
> >> 
> >> Hi,
> >> 
> >> I'm new to django, and I would like to get a hint about system 
> >> requirements. If you know about any helpful links, these are welcome, too. 
> >> So far what I dog up by googlng wasn't too helpful.
> >> 
> >> Currently we have a
> >> 
> >> - Database with mostly static entries in the thousands
> >> - it should be possible to search the database on different fields / over 
> >> several fields
> >> - the data contains images, as well
> >> 
> >> And the spec says: Expect unexpected changes in several ways.
> >> 
> >> I guess things like voting and commenting will come.
> >> 
> >> Maybe later some sort of api access ...
> >> 
> >> Do you have a rough idea, what kind of setup will be needed?
> >
> >There is absolutely no sensible way to answer this question in terms of 
> >hardware. For all we know, you could be describing the specs for google.com 
> >, or the intranet for your county church. Everything 
> >depends on what your service needs to do, how many visitors you have, and 
> >how fast they need a response.
> >
> >My suggestion would be to start with some cheap or free hosting and hack 
> >away. While writing your software, you should always keep in mind the load 
> >you expect/dream for, and make sure you are prepared to add whatever 
> >solutions are necessary to handle increasing load. Prepare yourself by 
> >collecting performance metrics for your software and your hardware, and 
> >define what response times your visitors should expect.
> >
> >Do performance tests before launch with whatever artificial traffic you can 
> >generate. Hardware requirements are roughly proportional to the number of 
> >requests. Know where your hot spots are and what you can do to solve them. 
> >As real-world traffic starts coming in, look at your metrics. To increase 
> >performance, you can either improve your software or add hardware. The 
> >former is expensive in salary, the latter is expensive in invoices.
> >
> >
> >Erik
> >
> >-- 
> >You received this message because you are subscribed to the Google Groups 
> >"Django users" group.
> >To unsubscribe from this group and stop receiving emails from it, send an 
> >email to django-users...@googlegroups.com .
> >To post to this group, send email to django...@googlegroups.com 
> >.
> >Visit this group at http://groups.google.com/group/django-users 
> >.
> >To view this discussion on the web visit 
> >https://groups.google.com/d/msgid/django-users/F69A1D5E-35EE-427C-9EA2-E6FB0A277523%40cederstrand.dk
> > 
> >.
> >For more options, visit https://groups.google.com/d/optout 
> >.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@googlegroups.com 
> .
> Visit this group at http://groups.google.com/group/django-users 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d77ff4d1-f103-428b-8572-5c95b4558f9e%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at 

Re: Downloading Django

2015-07-24 Thread Tom Lockhart
> …
> I am having some trouble installing Django.  The installation documentation 
> is great and I have downloaded Python version 3.4.3 for OS X  but can't seem 
> to complete the download.  I am new to programming so most likely its user 
> error.

I use MacOS for my development machine. If it were me (and when it is, this is 
how I do it):

1) Install MacPorts
2) Install PostgreSQL and Python from MacPorts
3) Use virtualenv to create a standalone Python environment
4) Enable the virtualenv by sourcing bin/activate
5) Use pip to install other Python packages including Django
6) Work through the Django tutorial

If you have specific difficulties ask the list for help.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6A899E39-83D4-4452-9AB3-D669E08E689C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need Django Help Again.

2015-07-22 Thread Tom Lockhart

> On Jul 22, 2015, at 09:11, Steve Burrus  wrote:
> 
> I find myself in ned of help yet again w. django. Just to say parenthetically 
> I have had this problem before. just what am I doing wrong with the command 
> "python .\Scripts\ django-admin.py startproject me" to consistently get this 
> error message! Thanx to anyone who helps me.   
> 
> "C:\Users\SteveB\Desktop\burrus>.\Scripts\activate
> (burrus) C:\Users\SteveB\Desktop\burrus>python .\Scripts\ django-admin.py 
> startproject me
> C:\Users\SteveB\Desktop\burrus\Scripts\python.exe: can't find '__main__' 
> module in '.\\Scripts\\’"

You seem to have a space after the “\Scripts\”.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9F05E056-A548-4EE4-89AE-0F3F14876503%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django subprocess doesnt like sleep

2015-06-05 Thread Tom Lockhart

> On Jun 5, 2015, at 8:44 AM, dk  wrote:
> 
> I created a website that can reboot a machine. basically subprocess a script 
> that lunch the reboot command in Linux.
> after that  I need to run some other operations. after that I wait 1 minute 
> before start pinging the machine to see if its back online.
> 
> the funny thing my script doesn't work, and I found out that django doesn't 
> like to wait more than 24 secs. =(  I might be doing something wrong?  If I 
> do more than 25 the process just stops at the time.sleep(60) and nothing 
> happen afterwards.  if I do it for 24 secs everything run fine.  

That is a long delay for an http request/response cycle.

If you do not already, you may want to model the remote machine state in a 
Django model. Use that to monitor and update the machine states and then your 
client-facing interactions can be decoupled from it.

You can use a subprocess or celery to do the extended work as required.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/DB6523B8-0EC3-4181-A247-56B9AF1CFFF7%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Possible bug in QuerySet API when chaining filter() and update() methods?

2015-05-19 Thread Tom Lockhart
On May 19, 2015, at 8:13 AM, Chi Gao  wrote:

> I encounter a similar problem. This issue is due to in MySQL "Currently, you 
> cannot update a table and select from the same table in a subquery." A 
> workaround way (in MySQL) is to create a template table from the selection:
> 
>  UPDATE `djangoapp_mymodel` SET `foo_field` = 1 WHERE 
> `djangoapp_mymodel`.`id` IN (SELECT U0.`id` FROM `djangoapp_mymodel` U0 AS 
> template_table)
> 
> But I started to use django since yesterday and don't know how to fix it in 
> django. Any suggestions?

Postgres.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ED016F8-6A8C-4CA4-9D06-663F9BEED0C8%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to represent a calendar month as a field in django models

2015-05-03 Thread Tom Lockhart
On May 3, 2015, at 7:17 PM, Mike Dewhirst <mi...@dewhirst.com.au> wrote:

> On 4/05/2015 11:41 AM, Tom Lockhart wrote:
>> On May 3, 2015, at 2:35 PM, Matthys <matth...@gmail.com> wrote:
>> 
>>> I posted the question also on stackoverflow:
>>> 
>>> http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model
>>> 
>>> The question is for situations where a model instance relates to a specific 
>>> month, but not to a specific day.
>> 
>> I would use a date field and, perhaps, clean the data to force the day to be 
>> the first day of the month. Then you can do date/time arithmetic using 
>> standard features.
> 
> Surely that would destroy data which wouldn’t be desirable.

I’m not sure how that follows. Although the question does not state it 
explicitly, I believe that the OP is interested in dates for which only the 
year and month are significant. Saving the month as a separate field seems to 
overly complicate the problem if any date/time arithmetic is required.

Perhaps I’m not understanding the downsides here (data destruction did not seem 
to be a side effect of my suggestion, beyond rounding the date to the 
application’s precision of interest): under what circumstances would it be 
desirable to store dates but not use date field functionality?

Regards,

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/A8784BEE-7AFD-4472-8217-7F81979C56E3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to represent a calendar month as a field in django models

2015-05-03 Thread Tom Lockhart
On May 3, 2015, at 2:35 PM, Matthys  wrote:

> I posted the question also on stackoverflow:
> 
> http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model
> 
> The question is for situations where a model instance relates to a specific 
> month, but not to a specific day.

I would use a date field and, perhaps, clean the data to force the day to be 
the first day of the month. Then you can do date/time arithmetic using standard 
features.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/870AC9B8-093F-47B6-8906-F76EB2453791%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread Tom Lockhart
> The Python functions I wish to execute use numpy and other Python packages I 
> would like like to convert to JavaScript.

As has been suggested, the tutorial is where you want to start. By the time you 
finish part 4 you will have a good idea how to bypass references to a data 
model and use forms and views to call something in numpy and return results.

Trying to skip the tutorial just means that you will be missing information 
required to be comfortable starting with Django. We pretty much all started 
there and do not regret it.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15165428-D0C6-47B2-9F23-AC92B2D54BBB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: {{STATIC_URL }} or {% static "...." %} What`s the correct to use?

2015-03-20 Thread Tom Lockhart
On Mar 20, 2015, at 9:59 AM, Fellipe Henrique  wrote:

> 
> On Fri, Mar 20, 2015 at 11:43 AM, Vijay Khemlani  wrote:
> Soo when you open your webpage, look at its source code, click on the 
> "/static/public/css/bootstrap.min.css" path it shows the file in Firefox?
> 
> Yes.. when I open source code in firefox, click them.. show me the file.. 
> but, nothing to appears correctly my HTML...
> 
> I really upset about these... I really don’t know what's happen here... 

Your original problem statement included:

  …
  - When I try to go:  localhost:8000/static   show these:
  Page not found (404)
  …

In my debug setup, I have the same result, and this is normal. You *should* be 
able to take a specific static resource and put it into the browser as a URL. 
For example, I can put http://localhost:8000/static/fz/img/loadingAnimation.gif 
into my browser and that *does* find the gif.

This is compatible with your observation that you can take the link in your 
html and that *does* work when pasted into your browser.

I’m guessing that there is a problem with your HTML, not with your static 
setup. Can you distill the problem down to a simple HTML template and resulting 
page and post both?

When debugging html template troubles you may want to play around with {% 
comment %}…{% endcomment %} blocks to get rid of code for testing.

hth

- Tom


> 
> T.·.F.·.A.·. S+F
> Fellipe Henrique P. Soares
> 
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
> Blog: http://fhbash.wordpress.com/
> GitHub: https://github.com/fellipeh
> Twitter: @fh_bash
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAF1jwZG78iexn0uLign0Rj-d_dvi61%2BtrNHTnVxXMkUxOi_gSg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this information.

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


Re: {{STATIC_URL }} or {% static "...." %} What`s the correct to use?

2015-03-20 Thread Tom Lockhart
On Mar 20, 2015, at 7:37 AM, Néstor  wrote:

> Is it OK to have this syntax?
>  href=“{% static "public/css/bootstrap.min.css" %}">

fwiw yes it is OK to have that syntax with double quotes inside another set of 
double quotes.

- Tom

> 
> Should you not do something like this:
> href="{% static 'public/css/bootstrap.min.css' %}">

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


Re: ImageField isn't working

2015-02-19 Thread Tom Lockhart
On Feb 19, 2015, at 8:03 AM, Valéria Pacheco  wrote:

> Hello! I'm a newbie in Django and Python, I'm trying to use the ImageField 
> property.
> The problem is represented in the attachment images.
> The uploading of the image works fine, but when trying to access it, the link 
> seems to be broken. 
> I already checked for answers online but neither seems to work.

The URL you are trying seems to be 
/admin/backOffice/product/12/media/images/teste_processo.jpg/ which is not 
likely to work.

In my development server settings.py I’ve got the following:

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))

and I’ve made a media/ directory inside my project area. Then you can find the 
image with a URL something like:

/media/images/teste_processo.jpg

(which may already be the case for you; look for the uploaded file and use a 
URL prefixed with “/media” then the path to the file).

hth

- 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/8cf5041c-2ad7-40ec-9243-d4e1a928013e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 


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


Re: Sqlite3 to Postgres Migration?

2015-02-19 Thread Tom Lockhart
On Feb 18, 2015, at 11:04 PM, talex  wrote:

> I have a functioning Django application that is based on sqlite3, 
> but I want to change to using Postgres.

I’ll point out for the benefit of others who might be getting started: Postgres 
is a full featured database and supports the full range of Django features and 
add-ons including GeoDjango. Starting development with a production-quality 
database already in place is not much more work and will save grief later on.

Usually I’d end with “hth”, but this is no help at all for talex…

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9963605E-7243-4827-AD56-10544AB28634%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread Tom Lockhart
On Feb 19, 2015, at 5:27 AM, SHINTO PETER  wrote:

> How to install django in redhat where i have python 2.6 and 2.7 and i need to 
> install django in python 2.7  

Use virtualenv to select and install python 2.7 from your existing installation 
into a separate place. There is a redhat package for virtualenv. Then use pip 
(which will be installed in that separate place) to install all of the other 
python packages.

You can use an existing postgres installation but I’d recommend configuring a 
new data area for it.

hth

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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/8feed982-d4e5-41a4-a1f5-463589711961%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


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


Re: How to use password hasher snippet in Django?

2015-01-22 Thread Tom Lockhart
On Jan 22, 2015, at 4:42 PM, Supermario  wrote:

> Many thanks for your help Thomas. Indeed I am in the middle of big escape 
> effort to get the heck away from Drupal.
> 
> I tested your snippet in the shell and DrupalPasswordHasher hashes perfectly 
> well there. 
> 
> However, when I integrate the hash into my project as per your explanation, 
> django-registration module still refuse to authenticate old drupal users. 
> 
> Any ideas on how to troubleshoot this?

I’m not using django-registration so don’t know if it uses some other mechanism 
to hash and compare passwords.

I might try putting a simple print statement into the hash routine to make sure 
that it is executing (run using the development server and just look for the 
print output on your console).

All password processors are executed in order until one of the verify() methods 
returns True.

Oh! You will also need to prepend “drupal” to each hashed password you bring 
over from the drupal database. Or do an explicit update of your new database to 
prepend that string to the hashed password field.

hth

- Tom


>  
> Cheers
> 
> On Thursday, January 22, 2015 at 4:12:07 AM UTC+1, Thomas wrote:
> On Jan 21, 2015, at 3:07 PM, Supermario  wrote:
> 
>> I am trying to move Druap 7 site to django 1.7 without invalidating user 
>> passwords, and this proved to be daunting.
>> 
>> Fortunately, I have found this SO question and this hashing snippet but 
>> there is no documentation and as a newbie to django, I have no clue how to 
>> integrate the snippet into my project.
>> 
> 
> I’ve enclosed a password processor I used in the past for a Drupal 
> conversion; the gist came from a web search and is attributed in the code but 
> has some minor fixes. I’ve actually included two processors, with one 
> disabled with “XXX” in the function name. I think I had trouble getting that 
> one to work.
> 
> You can create a “drupal” app, which just has an __init__.py and this file as 
> hashers.py
> 
> You will want to add “drupal” as one of your apps, then also define the 
> following in your settings.py:
> 
> PASSWORD_HASHERS = (
> 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
> 'drupal.hashers.DrupalPasswordHasher',
> 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
> 'django.contrib.auth.hashers.BCryptPasswordHasher',
> )
> 
> Since you are starting fresh, you can include only the recommended best 
> password hasher from Django plus the drupal hasher. And if you prefer you 
> could fold the hashers.py file into another existing app in your project.
> 
> Also, the structure of your project may be a bit different from mine since 
> the recommended Django layout has changed a bit over the last few versions.
> 
> hth, and enjoy getting the heck away from Drupal hell…
> 
> - 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/aa905c13-b9b1-42ba-b0c2-4127d079a8c3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this information.

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


Re: How to use password hasher snippet in Django?

2015-01-21 Thread Tom Lockhart
On Jan 21, 2015, at 3:07 PM, Supermario  wrote:I am trying to move Druap 7 site to django 1.7 without invalidating user passwords, and this proved to be daunting.Fortunately, I have found this SO question and this hashing snippet but there is no documentation and as a newbie to django, I have no clue how to integrate the snippet into my project.I’ve enclosed a password processor I used in the past for a Drupal conversion; the gist came from a web search and is attributed in the code but has some minor fixes. I’ve actually included two processors, with one disabled with “XXXâ€� in the function name. I think I had trouble getting that one to work.You can create a “drupalâ€� app, which just has an __init__.py and this file as hashers.pyYou will want to add “drupalâ€� as one of your apps, then also define the following in your settings.py:PASSWORD_HASHERS = (    'django.contrib.auth.hashers.PBKDF2PasswordHasher',    'drupal.hashers.DrupalPasswordHasher',    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',    'django.contrib.auth.hashers.BCryptPasswordHasher',)Since you are starting fresh, you can include only the recommended best password hasher from Django plus the drupal hasher. And if you prefer you could fold the hashers.py file into another existing app in your project.Also, the structure of your project may be a bit different from mine since the recommended Django layout has changed a bit over the last few versions.hth, and enjoy getting the heck away from Drupal hell…- 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/B276D536-93E4-4A28-AB5B-9E184685B675%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
import hashlib

from django.contrib.auth.hashers import BasePasswordHasher
from collections import OrderedDict


class DrupalPasswordHasherXXX(BasePasswordHasher):
"""
From dgrtwo at http://djangosnippets.org/snippets/2729
As it stands, this looks for a password which starts with "S"
so needs the leading "$" present in the drupal hashed value removed.
This also fails in the user admin panel; perhaps due to a missing
safe_summary method.
"""
algorithm = "S"
iter_code = 'C'
salt_length = 8
_ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

def encode(self, password, salt, iter_code=None):
"""The Drupal 7 method of encoding passwords"""
if iter_code is None:
iterations = 2 ** self._ITOA64.index(self.iter_code)
else:
iterations = 2 ** self._ITOA64.index(iter_code)
hash = hashlib.sha512(salt + password).digest()
for i in range(iterations):
hash = hashlib.sha512(hash + password).digest()
pass
l = len(hash)

output = ''
i = 0
while i < l:
value = ord(hash[i])
i = i + 1
output += self._ITOA64[value & 0x3f]
if i < l:
value |= ord(hash[i]) << 8
output += self._ITOA64[(value >> 6) & 0x3f]
if i >= l:
break
i += 1
if i < l:
value |= ord(hash[i]) << 16
pass
output += self._ITOA64[(value >> 12) & 0x3f]
if i >= l:
break
i += 1
output += self._ITOA64[(value >> 18) & 0x3f]
pass
longhashed = "%s$%s%s%s" % (self.algorithm, iter_code, salt, output)
return longhashed[:54]

def verify(self, password, encoded):
hash = encoded.split("$")[1]
iter_code = hash[0]
salt = hash[1:1 + self.salt_length]
return encoded == self.encode(password, salt, iter_code)


class DrupalPasswordHasher(BasePasswordHasher):
"""
From grillermo at http://djangosnippets.org/snippets/2924/
Modified from DrupalPasswordHasher to fix "the issue" whatever that is.
To verify functionality:
>>> h = DrupalPasswordHasher()
>>> h.verify("password1234", "$S$DeIZ1KTE.VzRvudZ5.xgOakipuMFrVyPmRdWTjAdYieWj27NMglI")
True
"""
DRUPAL_HASH_COUNT = 15
DRUPAL_MIN_HASH_COUNT = 7
DRUPAL_MAX_HASH_COUNT = 30
DRUPAL_HASH_LENGTH = 55
_ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
algorithm = 'drupal'

def verify(self, password, hashed_password):
# django-1.5 passes in password in unicode which causes trouble in hashlib.sha512()
if (isinstance(password, unicode)):
password = password.encode('ascii')
pass
# slight 

Re: is it worth going for version 1.6 for commertial project

2014-11-22 Thread Tom Lockhart

On Nov 22, 2014, at 4:53 AM, Krishnakant Mane  wrote:

> Hello all,
> I have been looking for some good discussion on this issue.
> i see there is not much difference between 1.7 and 1.6 as far as my 
> requirement goes.
> I have gone through the official docs for both in a kind of rappid specific 
> way.
> As it is I am not going to use ORM at all.

I am sticking with 1.6.x in case the new migration system needs a bit of extra 
time to iron out.

But since you are not using the ORM then you will not notice one way or the 
other. I’d probably go with 1.7.x…

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/FBBC7DD5-712A-46FF-A4FF-0A38495D1A6C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ImportError: cannot import name 'GEOSException'

2014-11-20 Thread Tom Lockhart
> Thanks for the reply.  Yes, I am using a virtualenv for this project.  I’ll 
> try to stick it out with GeoDjango, but I really do not know what to do now 
> to try to continue on with the install.  

I would probably stop “continuing”, and go back to the start. afaict the 
installation instructions for Windows in the Django docs (mentioned by Carl) 
should address the path issues you are seeing. In particular, the lines 
including “set PATH=%PATH%;…” and the registry updates in the “Modify Windows 
environment” section of the GeoDjango installation instructions would seem to 
cover it.

If after starting over and slavishly following the instructions you still see 
the path issues, post the values of the variables from the installation 
instructions which are actually set on your system (e.g. PATH). We should be 
able to help a bit more. Not me since I don’t know much about Windows, but 
someone will…

hth

- Tom


> 
> At this point in my Django career, I am pretty much a monkey banking on a 
> keyboard when troubleshooting this type of issue.   On that note, can you 
> possible refer me to any program/documentation on how I would troubleshoot 
> such an issue (stepping through code, checking variable values, etc).
> 
> If and when I get this up and running, I'll have to put all of the info 
> somewhere, for other peoples' reference.  
> 
> Ivan  
> 
> On Thursday, November 20, 2014 9:38:09 AM UTC-5, Thomas wrote:
> 
> On Nov 19, 2014, at 2:24 PM, jogaserbia  wrote: 
> 
> > Thanks for the help Carl.  Also, thanks for filing the ticket. 
> > 
> > Every bit of info helps.  I really do like Python and Django so far.   
> > 
> > I am just wondering whether I should just quit trying to make GeoDjango 
> > work on my windows machine (at work).  I will be setting up a linux machine 
> > at home in the next couple of months, and can try it out again.   
> 
> Windows boxes can be cranky and annoying, but I’d stick with it and just Make 
> It Work. Once you have a complete installation (and document how you got 
> there!) you won’t have to think hard about it again. Or use virtualbox (and 
> Docker on top of it) to get started with your Linux installation now. 
> 
> You *are* using virtualenv, right? That is very high on my list of things 
> that make my life easier for setting up development systems and deploying to 
> production. You may find that it helps with some of the issues you are seeing 
> on your system. 
> 
> > As a workaround, what I could probably do (if I can figure it out) is call 
> > the postgres fuctions for distance between Lon Lat points that will serve 
> > as the basis for the application that I am building.   
> 
> Yeah, I wrote that code back in the day and I would use GeoDjango. Not that 
> it doesn’t do what it says it does, but GeoDjango gives you everything you 
> will need all at once. 
> 
> hth 
> 
> - 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/fa610d6b-352e-411b-b831-1540b2c67724%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this information.

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


Re: ImportError: cannot import name 'GEOSException'

2014-11-20 Thread Tom Lockhart

On Nov 19, 2014, at 2:24 PM, jogaserbia  wrote:

> Thanks for the help Carl.  Also, thanks for filing the ticket. 
> 
> Every bit of info helps.  I really do like Python and Django so far.  
> 
> I am just wondering whether I should just quit trying to make GeoDjango work 
> on my windows machine (at work).  I will be setting up a linux machine at 
> home in the next couple of months, and can try it out again.  

Windows boxes can be cranky and annoying, but I’d stick with it and just Make 
It Work. Once you have a complete installation (and document how you got 
there!) you won’t have to think hard about it again. Or use virtualbox (and 
Docker on top of it) to get started with your Linux installation now.

You *are* using virtualenv, right? That is very high on my list of things that 
make my life easier for setting up development systems and deploying to 
production. You may find that it helps with some of the issues you are seeing 
on your system.

> As a workaround, what I could probably do (if I can figure it out) is call 
> the postgres fuctions for distance between Lon Lat points that will serve as 
> the basis for the application that I am building.  

Yeah, I wrote that code back in the day and I would use GeoDjango. Not that it 
doesn’t do what it says it does, but GeoDjango gives you everything you will 
need all at once.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39DE9C97-10DD-4C0A-85B2-3B8EAE12B093%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installing django on red hat linux box

2014-10-22 Thread Tom Lockhart
On Oct 22, 2014, at 9:12 AM, robert brook  wrote:

> 
> I have alot of experience installing packages on windows and mac and it goes 
> very smoothly.
> I do not have alot of experience doing the installs on a Linux box.
> 
> I am running into problems installing 4 packages.
> 
> The Lan team tried yum, but the basic django packages were not available.

Use yum to install python and virtualenv and the rest should go easily using a 
virtualenv setup.

This is commonly recommended for the other platforms also.

hth

- Tom

> 
> Then I tried installing pip and I got proxy errors using the get-pip.py script
> 
> So I fell back to installing the dowloaded packages with the old standy  
> setup.py install which fails.
> 
> I am attaching the top of the log
> 
> Anyone have any suggestions how to proceed?
> 
> **
> running install
> 
> running bdist_egg
> 
> running egg_info
> 
> writing pyodbc.egg-info/PKG-INFO
> 
> writing top-level names to pyodbc.egg-info/top_level.txt
> 
> writing dependency_links to pyodbc.egg-info/dependency_links.txt
> 
> reading manifest file 'pyodbc.egg-info/SOURCES.txt'
> 
> reading manifest template 'MANIFEST.in'
> 
> warning: no files found matching 'tests/*'
> 
> writing manifest file 'pyodbc.egg-info/SOURCES.txt'
> 
> installing library code to build/bdist.linux-x86_64/egg
> 
> running install_lib
> 
> running build_ext
> 
> building 'pyodbc' extension
> 
> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 
> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic 
> -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall 
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
> --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv 
> -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python2.6 -c 
> /home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.cpp -o 
> build/temp.linux-x86_64-2.6/home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.o 
> -Wno-write-strings
> 
> In file included from /home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.cpp:12:
> 
> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:41:20: error: Python.h: No such file 
> or directory
> 
> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:42:25: error: floatobject.h: No such 
> file or directory
> 
> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:43:24: error: longobject.h: No such 
> file or directory
> 
> *
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/83a1d410-9cc1-4841-a517-1895ba220179%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this information.

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


Re: Getting started with django templatetags

2014-10-19 Thread Tom Lockhart

On Oct 18, 2014, at 2:24 AM, Scipion  wrote:

> Hey,
> 
> I have started to use Django (1.6) few weeks ago and I have the following 
> problem to resolve by using templatetags. (this is my very first templatetags 
> draft, so I may be wrong in the way of designing it, do not hesitate to 
> highlight anything weird).
> In my template, I have a list of elements (defined in the context) : items 
> (among 6 different django models).
> According to which class an item belongs, I have to display an image or a 
> title specific to this class (these informations can't be stored in the 
> models). 
> So basically, in my template I would like to have something like : 
> 
> {% for item in items %}
>  {% show_title_tag item %} 
> myPath/{% show_image_name_tag %}
> {% endfor %}
> 
> 
> I can't have more than that.
> 
>
>  @register.tag
> def show_title_tag(parser,token):
> tag_name, item = token.split_contents()
> if isinstance(item,class1):
> return MyNode(item.quote)
> elif isinstance(item,class2):
> return MyNode(item.subtitle)
> elif isinstance(item,class3):
> return MyNode(item.title)
> ...
> # basically, the field to use change for each class
>  
> @register.tag
> def show_image_name_tag(parser,token):
> tag_name, item = token.split_contents()
> if isinstance(item,class1):
> return MyNode("specific image name linked to class 1")
> elif isinstance(item,class2):
> return MyNode("specific image name linked to class 2")
> ...
> # the name change at each class, and is not stored in the object
> 
>  
> class MyNode:
> def __init__(self, image_or_title_string):
> self.image_or_title_string = image_or_title_string
> def render(self, context):
> return image_or_title_string.resolve(context)
> 
> 
> 
> 
> 
> Two main questions :  
> 
>  1. I am duplicated the if-elif code. Any idea how I could do it without
> duplicating it ? I could maybe only use one tag and add an extra
> parameter (in the tag and in the render) to specify which
> information I need (either the image or the title). Really not sure
> about this ...

This should not count as a suggestion of "best practices". At all.

But if you really cannot associate your related data with a model, then I might 
try setting up a lookup table with the classes as the lookup key. Something like

imagelookups.py

include .models

image_table = {class1: specific_image_url_for_class1,
class2: specific_image_url_for_class2,
...}

I'm not sure that the template tag is particularly useful here; why not just 
cough up the image URL itself rather than an entire piece of template?

So your template tag can just set a variable to be used in your templates:

@register.simple_tag
def show_title_tag(parser, token):
tag_name, item = token...
return image_table[item]

hth

- Tom


> 
>  
>  2. Can I have access to the variable and not the string in the tag code
> (after doing : tag_name, item = token.split_contents()). I imagine
> that item will be a string and not my django object. How can I
> resolve this ?
> 
> Also, here are the requirements I have to enforce : 
> 
>  - keep template very simple
>  - use templatetags to solve it
>  - can't modify models
>  - check to which class an item belongs with a function as isinstance in
>the templatetags (not in the template)
> 
>  
> Please, any suggestions are welcome here, as long as they respect the 
> requirements. Also, remind that I am a django beginner, I am just trying to 
> do it simple and readable, not highly effective.
> 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/7b4b4803-dd5b-44ce-a785-b9a0d5fe6abb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized 

Re: query join tables

2014-10-12 Thread Tom Lockhart
On Oct 12, 2014, at 10:01 PM, dk  wrote:

> I have this 2 models
> 
> class Choice(models.Model):
> restaurant = models.ForeignKey(Restaurant)
> person = models.ForeignKey(Person)
> date = models.DateField("time published")
> time = models.TimeField("date published")
> 
> class Person(models.Model):
> name = models.CharField(max_length=100)
> last_name = models.CharField(max_length=100)
> email = models.EmailField()
> 
> and I would like to be able to see check if in a certain date, a certain 
> person does exist in the record.
> I am currently querying the date first.
> 
> date_query = Choice.objects.filter(date=dater)
> for i in date_query:
> if i.person_id == to_email_i_am_looking:
> 
> might be another way to chain the querys?

You can chain together the filters:

person = Person.objects.get(name=person_name)
choices_for_person_on_date = 
Choice.objects.filter(date=dater).filter(person=person)

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/86A8F8F0-1AA8-4FD2-ACA7-CF779B3808AC%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres database server

2014-10-11 Thread Tom Lockhart

On Oct 11, 2014, at 10:10 AM, sheyda kianimehr  wrote:

> Hi guys I have a problem.
> I am so new in Django and Postgres
> 
> I am installed python, django, postgres on Ubuntu (acording to 
> https://docs.djangoproject.com/en/1.7/intro/tutorial01/)
> but I have problem in seting up The development server,
> I see password for postgres user error after typing this is my Terminal
> python manage.py runserver
> 
> I put a password in setting.py file but it doesn't work yet.
Are you sure that you are accessing the database through django the way the 
database expects?

You should be able to access your database through the command line:

psql -U your_db_username dbname

Send your DATABASES variable from the settings file and we might have some more 
suggestions.

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/77B3791A-A6C8-43D8-9FE6-0D98E016441C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM performance

2014-09-03 Thread Tom Lockhart

On 2014-09-03, at 4:22 PM, msoulier  wrote:

> Hi,
> 
> I am looking at Django's performance with respect to modifying large numbers 
> of objects, each in a unique way that cannot be batched. If I make a simple 
> change to one of my Django models and save(), and then do the same thing in 
> sqlalchemy, I notice a performance difference of about 48 times as far as the 
> rate that the objects are processed to my postgresql db.
> 
> The code is a simple property update and save, in a loop, trying to process 
> as many objects as possible.
> 
> Is the Django ORM known to be slower in this regard, or is it likely 
> something that I'm doing?

I haven't had to deal with this myself, but the speed difference smacks of 
transactional issues. If you can run your loop by wrapping all of it or pieces 
of it (say, 100 or 1000 chunks) in a single transaction you'll probably see 
some significant speedup.

https://docs.djangoproject.com/en/dev/topics/db/transactions/

hth

- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1193F2BD-2597-4D68-A8EE-D593FFD084EF%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2014-06-01 Thread Tom Lockhart

On 2014-05-31, at 4:41 AM, ngangsia akumbo  wrote:

> please i need some legit answer please

Please give one or two specific examples of functionality you need. There are 
parameters for fields which can help specialize some behaviours without needing 
a new model. And there are hooks to allow specialization of behaviours in 
interpretation or handling when reading or saving values which you may find 
useful.

afaik there is no large library of model specializations for Django, but that 
may be because there is no clear large set of specializations that would be 
useful.

So give an example please. Is it the book name, the book author, or something 
else which needs extra or restricted behaviours?

- Tom


> 
> we have in the models forexaple
> 
> class Book():
> 
> name = InputTextField
> Autho = 
> 
> 
> Please are there not more parmaters that can hel you to better define your 
> model. Are there no library for models?
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/cb57997d-ac3e-40a4-b7f8-791db176%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this information.

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


Re: function to create objects in a given model

2014-05-21 Thread Tom Lockhart
On 2014-05-21, at 9:15 AM, chansonsyiddish <chansonsyidd...@gmail.com> wrote:

> Thanks, Tom,
> 
> I'm not sure I need to use signals altogether, as I know when a Song is 
> added. If I make a method in the Song model, I suppose I can import the model 
> and run it in the shell? Or is there a way I could run it directly from the 
> admin site? 

Yes and yes.

python manage.py shell
>>> from yourapp.models import Song
>>> s = Song.objects.get(title='your title here')
>>> s.make_words()

For the admin interface, look at the actions keyword for admin classes. 
Something like

class SongAdmin(admin.ModelAdmin):
  ...
  actions = ['gen_words']
  ...
  def gen_words(self, request, queryset):
for obj in queryset:
  obj.make_words()
  pass
return
gen_words.description='Generate words for selected songs'

To do the same for all songs at once you can implement a management command for 
the command line or if in the admin GUI you will likely want to implement a GUI 
button. I'd stayed away from GUI buttons previously but it turns out to be 
pretty simple once you have one done.

hth

 - Tom


> 
> Hélène
> 
> 
> 
> 
> On 21/05/2014 17:15, Tom Lockhart wrote:
>> On 2014-05-20, at 12:26 PM, "C. Kirby" <mist...@gmail.com> wrote:
>> 
>>> I would strongly suggest you use signals.
>> 
>> This nicely enables an automatic path of execution. But if you also want to 
>> execute this code, say, from the admin interface or separately for testing 
>> then you may want to package the fundamental code into a method of the Song 
>> model, then run that method in the signal handler.
>> 
>> hth
>> 
>> - 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/537CD10A.9070307%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this information.

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


Re: failure of auto increment in inndb (mysql)

2014-01-27 Thread Tom Lockhart
> ...
> Now Jane Smith has the same ID as John Doe had previously. This may not be a 
> problem in your situation, or it might. Anyway it's good practice to never 
> re-purpose an ID.

MySQL started as a non-ACID query server (not a full relational database in the 
accepted sense) and these kinds of issues likely stem from that history. Folks 
getting started with databases and django may want to consider using Postgres 
for their foundation.

hth

 - 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08011991-F07D-407A-B983-D7C694678631%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: time problem in django 1.6

2014-01-27 Thread Tom Lockhart
I am not using 1.6 yet. However, you will likely get the best help if you can 
describe more exactly your symptoms. What does "giving a wrong time" actually 
look like? Are the fields scrambled? Is there a time offset to the result? Or 
something else?? Please be specific on what you are finding and why you think 
it is wrong.

hth

   - Tom

On 2014-01-27, at 12:21 AM, Hossain Aboutalebi  
wrote:

> I am one of the new user in django 1.6 but one thing very bad I have noticed 
> in this version of django is that time.strftime("%H:%M:%S") does not working 
> and giving a wrong time in my view . Is there any alternating approach for 
> getting a right time in django view or not ?
> 
> Note : if you type print(time.strftime("%H:%M:%S")) in python 3 you will see 
> a right time but in django 1.6 it is not true
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/fba065bb-0490-4a42-b85f-2e3fef254132%40googlegroups.com.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0A2A4051-6454-4DCA-85C5-EBA68BC220BD%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need Direction for Web App

2013-12-25 Thread Tom Lockhart

On 2013-12-24, at 4:55 PM, zobcl...@gmail.com wrote:

> I would like to create a web app / interface to manipulate and maintain my 
> server's dhcpd.conf file. 
> Background in Short:
> I was asked a few years back to build a wifi network for approximately 500 
> users with unlimited devices. With no money (barely any money). Done. 
> The only requirement/restriction is we use MAC address filtering. So I have a 
> server, serving dhcp leases. I have to manually input each MAC address with a 
> hostname and group. This is a terrible pain. Especially for the amount of 
> users I have with unlimited devices. Christmas time is horrible because they 
> all come in wanting new devices registered. 
> I do have, at least, a web form through google which updates an excel sheet 
> in google docs, which I then access, copy the MAC address, then using my 
> server gui, add the new MAC to the dhcpd.conf file and restart the server. 
> What I've done & What my hope is:
> I have started the Django tutorial. I have dabbled with python. I am an 
> enthusiast in training. I have very little to no experience. I can learn. 
> Fast. I am just running into branches of "things to learn" and it's starting 
> to be a little overwhelming. 
> I hope to do the lion's share of creating a web app that will do the 
> following:
> 
> 1. Register a user using sqlite3 database I have already created for all 
> users. 
> 2. Authenticate a user
> 3. Provide a display of registered devices for user to either delete or not 
> delete
> 4. Provide a form to register a new device(s)
> 5. submit request, append to dhcpd.conf & restart dhcp server 

I would use one of the Django CMS apps as a starting point (I've had good 
experiences with Mezzanine and I'm sure other ones would work). For example, 
Mezzanine out of the box can give you a blog for a home page (so you can post, 
say, status updates), user authentication, and other pieces you may not use 
right away but are available when you want them. You can also put these 
together individually from Django components and other available apps, but 
afaict that is almost guaranteed to be a bit more work.

Finish working through the Django tutorial, since that will introduce you to 
the building blocks.

Start your project by defining the schema in your new app with your own 
models.py underneath your new project. That will almost immediately give you an 
admin interface to play with your schema.

Think about using Postgres for the database.

You should be able to export your current spreadsheet and then perhaps read it 
into a python program and out into your database. Or you might be able to 
import it directly into a single table then use raw SQL to push the data around 
into the schema you need. You mentioned that you already have database content 
for users in sqlite; not sure what that schema looks like but although Django 
has enough hooks to map most existing schemas to the Django ORM, you might find 
it cleaner and more maintainable to define your schema in Django and then 
convert your existing tables over to it (they are likely to be very similar, 
and you may be able to do it with some raw SQL).

You will find that asking very specific questions on this mailing list will be 
more likely to get a response, so as you go along feel free to do so. Search 
first for the answer though; you will find a lot of questions have already been 
answered and come up in google.

hth

 - 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/A29A421E-12A5-4979-A50B-6B3186D106ED%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can't Install on Windows 8.1

2013-12-24 Thread Tom Lockhart

On 2013-12-24, at 6:56 AM, Malik Rumi <malik.a.r...@gmail.com> wrote:

> Thank you. One more question before I dive in: I already have python 
> installed. Are you suggesting I remove it and start over?

No. What you will find is that virtualenv will pick up whatever python it finds 
and package it in a new self-contained area. At that point you will have full 
control over what additional things get installed. But it needs a python 
installation somewhere else to get started.

If you have put a bunch of packages into your native python installation and 
are not sure what you have, you may want to re-install just to get a clean 
basic installation. But I haven't had to do that and would not bother unless 
you see other issues.

hth

- Tom

> 
> On Tuesday, December 24, 2013 8:04:08 AM UTC-6, Timothy W. Cook wrote:
> Since it appears that you are not too familiar with Python, this may help:
> http://www.youtube.com/watch?v=d_W02OwHa38
> 
> Using a virtual environment and pip will a long way to solving many of your 
> issues.   It is considered best practice 'for a reason'. 
> 
> https://zignar.net/2012/06/17/install-python-on-windows/
> 
> Then, install django and other requirements inside your virtualenv.
> 
> 
> 
> HTH,
> Tim
> 
> 
> 
> 
> On Tue, Dec 24, 2013 at 11:35 AM, Malik Rumi <malik@gmail.com> wrote:
> Hello. This is my first post. The attached Word document tracks everything I 
> have done this morning to get this to work. 
> 
> Your insights, guidance, and assistance is greatly appreciated. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/dec70718-1de8-403d-9321-fbbfd760e88d%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> -- 
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/952e8e35-bb11-4c66-aca8-d25585606d76%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/E65C7D3B-1493-44F5-AC2C-516E27912E60%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: ViewDoesNotExist at /admin/

2013-12-24 Thread Tom Lockhart

On 2013-12-23, at 9:42 PM, Gabriele Stoia <gabrielest...@gmail.com> wrote:

> I think I found the problem...maybe...
> 
> I running my app in the same hosting of another app ... (sorry for my 
> english..is not my first language... I'm italian…)

If you are not using virtualenv and pip to manage each of these installations 
you will likely find it useful to do so. It should eliminate worries about 
conflicts between version sets.

hth

  - Tom

> 

> I have
> 
> -- first app
> -- feincms
> -- other module
> -- ...
> --second app
> -- -- feincms
> -- -- other module
> 
> Maybe my second-app is using feincms of the first app which is different 
> version.
> I think this because I got this error :
> 
> No module named filterspecs
> /home/alessandrocambogia/feincms/admin/filterspecs.py in , line 7
> 
> where alessandrocambogia is the first-app.
> 
> I need to have 
> /home/alessandrocambogia/gabryandjenny/feincms
> 
> where gabryandjenny  is the second-app
> 
> but actually I don't know how to change the path... Is my first experience in 
> Django.
> Can you help in this  Please ??? 
> Thank you in advance.
> 
> Gabri
> 
> 
> 
> Il giorno martedì 24 dicembre 2013 07:45:02 UTC+7, Russell Keith-Magee ha 
> scritto:
> 
> On Mon, Dec 23, 2013 at 10:53 AM, Gabriele Stoia <gabrie...@gmail.com> wrote:
> Hi Russel,
> 
> thank you for your e-mail !!!
> I thought that something was connected with MPTT or FeinCMS... I'll try to 
> work out !
> What I really don't understand why so many problem when you in deployment ??? 
> In local everything was super fine !!!
> 
> If you're having "deployment only" problems, this points to a problem with 
> the way your development process is organised. These sorts of problems only 
> emerge because your development environment is fundamentally different to 
> your production environment -- for example, different versions of software, 
> different paths. If you make good use of virtualenv to isolate your project, 
> and use requirements files to ensure version compatibility, you should be 
> able to minimise this sort of problem.
> 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e66a8967-5e82-43b2-9ba8-8736cb192025%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C827910A-B624-4454-B6F9-4F6BC5F55137%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: Django Weekend Cardiff

2013-12-20 Thread Tom Lockhart

On 2013-12-20, at 1:07 AM, "Daniele Procida" <dani...@vurt.org> wrote:

> As you may already be aware, tickets for Django Weekend Cardiff 
> <http://djangoweekend.org> sold out in three weeks.
> 

Congratulations Daniele!

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43AE486B-B882-44F4-9C96-B756EAA7B647%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: intiial sql and foreign keys

2013-12-14 Thread Tom Lockhart
Ah, hadn't used that before. And frankly I wouldn't bother doing that since it 
is a one-time operation. I would write a script to do the load with calls to 
psql (assuming you are using postgres of course). If order is not guaranteed 
then even if things work for you now using "initial sql" may just be postponing 
a problem to the future.

hth

  - Tom


On 2013-12-14, at 6:02 AM, Larry Martell <larry.mart...@gmail.com> wrote:

> On Fri, Dec 13, 2013 at 8:08 PM, Tom Lockhart <tlockhart1...@gmail.com> wrote:
> 
> On 2013-12-13, at 1:48 PM, Larry Martell <larry.mart...@gmail.com> wrote:
> 
>> I have 2 tables that I need to initialize with some initial sql files.
>> One table has a foreign key reference into the other. The docs say
>> "Note that if you have multiple SQL data files, there’s no guarantee
>> of the order in which they’re executed." So what can I do here? I
>> obviously need the table with the referenced data loaded first so I
>> can pick up the ids when I load the referencing table? How is this
>> situation (which seems like it would be fairly common) typlcally
>> handled?
> 
> If you already have the keys (that is, the table ids) assigned, then you can 
> probably load the tables in one transaction since integrity is checked on 
> commit.
> 
> If you need the keys assigned, then you might want to do a python script. 
> psycopg2 can return a value which you can then stuff into your other table.
> 
> But maybe your question has a simpler answer. If you are loading SQL data 
> directly, and not through django fixtures, you can control which table gets 
> loaded first. Load the one with the foreign key references second.
> 
> You might need to set the next value for the sequences used for table ids if 
> you are doing a bulk load. Something like this for pgsql:
> 
> select max(colname) from tablename;
> select pg_catalog.setval('tablename_colname_seq', maxid, true);
> 
> hth
> 
> 
> As I wrote in my initial post, I am loading the data with initial sql files 
> (https://docs.djangoproject.com/en/1.5/howto/initial-data/#providing-initial-sql-data).
>  I have to experiment and see what happens first - fixtures or initial sql. I 
> may be able to do the referenced table with one and the referencing table 
> with the other. Seems bulky though. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CACwCsY6DDNQWqE%2BWqGxDcLwKW%2B78VpSHbWF9epUi8O51LkY97Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C13D8BC5-BBED-4F62-B880-217EEB754460%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: intiial sql and foreign keys

2013-12-13 Thread Tom Lockhart

On 2013-12-13, at 1:48 PM, Larry Martell <larry.mart...@gmail.com> wrote:

> I have 2 tables that I need to initialize with some initial sql files.
> One table has a foreign key reference into the other. The docs say
> "Note that if you have multiple SQL data files, there’s no guarantee
> of the order in which they’re executed." So what can I do here? I
> obviously need the table with the referenced data loaded first so I
> can pick up the ids when I load the referencing table? How is this
> situation (which seems like it would be fairly common) typlcally
> handled?

If you already have the keys (that is, the table ids) assigned, then you can 
probably load the tables in one transaction since integrity is checked on 
commit.

If you need the keys assigned, then you might want to do a python script. 
psycopg2 can return a value which you can then stuff into your other table.

But maybe your question has a simpler answer. If you are loading SQL data 
directly, and not through django fixtures, you can control which table gets 
loaded first. Load the one with the foreign key references second.

You might need to set the next value for the sequences used for table ids if 
you are doing a bulk load. Something like this for pgsql:

select max(colname) from tablename;
select pg_catalog.setval('tablename_colname_seq', maxid, true);

hth

   - 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CACwCsY7si8kVqx3fqNRY%3DV%3DqPzGN1q-P2p5gfrc0a8UXps-OCQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7CB9A5F7-7A81-4DE4-95FD-7FC0BFD0035E%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: DecimalField and SQL Server

2013-12-08 Thread Tom Lockhart

On 2013-12-08, at 7:18 AM, Derrick Jackson <derrick.jackso...@gmail.com> wrote:

> Thanks Vernon and Michael.
> 
> I've done a little more research and at first I thought the problem was in 
> django_pyodbc.  However, running the following "%0.2f" % 3 
> from the python console and it yields '2.00' and I don't 
> understand why the digit prior to the decimal is "2" and not "3".  This may 
> be a lack of understanding but any help would be appreciated. 

This (and your original problem) is a symptom of using floating point internal 
representation to hold a decimal fixed-precision number. It can not be done 
reliably, since floating point numbers are base-2 with exponents and fractional 
integers have rounding imprecision in that representation.

I would be a bit surprised that your ODBC package is using floating point 
internally for decimal types, but it may. Until you narrow it down that entire 
chain is suspect. ODBC drivers have the problem that they must support the 
least capable databases as well as the most. imho if you can get away from ODBC 
and use a database-specific support layer you might have better luck. Maybe try 
the one mentioned earlier??

hth

  - Tom

> 
> On Friday, December 6, 2013 1:52:18 PM UTC-5, Vernon D. Cole wrote:
> Derrick:
> 
> I just added your failing test pattern to the unit test for adodbapi, and it 
> works correctly. Therefore I would conclude that the problem is in 
> django-pyodbc, not in SQL Server itself.
> 
> Micheal and I maintain the other SQL server backend, sqlserver_ado, so I am 
> afraid that we can't be much more help to you.
> --
> Vernon Cole
> 
> On Friday, December 6, 2013 6:59:11 AM UTC-7, Derrick Jackson wrote:
> Hi Michael,
> 
> I'm using django-pyodbc 0.10
> 
> On Friday, December 6, 2013 8:42:00 AM UTC-5, Michael Manfre wrote:
> Which database backend are you using to connect to SQL Server?
> 
> Regards,
> Michael Manfre
> 
> On Friday, December 6, 2013 6:45:30 AM UTC-5, Derrick Jackson wrote:
> Hello all,
> 
> I have a strange occurrence I'd like to share to see if any of you have run 
> into the same thing.  I am using Django 1.5.4, SQL Server 2008, and have the 
> following field definition in one of my models:
> 
> gift_value = models.DecimalField(max_digits=20, decimal_places=2, 
> verbose_name='Gift Value')
> SQL Server table has the field's dataType as numeric(20,2).
> 
> In my form if I enter the following values:
> 
> 44 is saved as 16
> 22 is saved as 08
> 66 is saved as 24
> 
> Well you get the picture, no need for me to bore you with more examples.  
> Have any of you see this happen before?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/3aefeaa5-cf81-47c0-99d6-00c09fcda6a9%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75BE285A-8795-4D34-B47C-8C7F59E3B969%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: how to load and render "static .txt file content" from django template

2013-12-07 Thread Tom Lockhart

On 2013-12-07, at 4:16 AM, Fatih Tiryakioglu <fatih...@gmail.com> wrote:

> Hi all,
> 
> I want to render a static .txt file from django template, but I can't load 
> it. I tried some combinations. Here is some of them:
> 
>
> 
> 
> 
> src="shortcut/to/text-file.txt" 
> 
> How can I load the context of this file?

Not sure about the textarea markup, but I would think that you would need to 
load the static tag and do something like



Take a look at the html your browser is getting and see if the paths for your 
text files look similar to the paths already working for images.

hth

  - Tom


> 
> Thanks all.
> 
> Note: I can render static image files, so it is not a settings problem.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/b54669cb-6d8e-481a-a4f7-665fd1e0876d%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/FE709582-B7A6-4575-A12A-2CD35A235853%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: Does not generate the password hash my User

2013-12-05 Thread Tom Lockhart

On 2013-12-05, at 11:54 AM, Ricardo Kamada <ricardokam...@gmail.com> wrote:

> I have a model "Cliente" and in it a field "password".
> In forms.py file, I am using ModelForm, but put in the password field
> Password = forms.CharField (widget = forms.PasswordInput (render_value = 
> True))
> It turns out that the admin password field appears readable, and I do not 
> want that to happen.
> I tried to put in set_password. Models but did not succeed.
> Now if I put in the admin:
> form = FormCliente
> Displays the password field and confirm password type password.
> But I will not so I want to appear only the password hash.
> 
> http://pastebin.com/AQnWR0W3
> in line 19 does not generate the password hash, but the readable password

render_value=False seems to be helpful here.

Also, in my forms (copied from Mezzanine) there are two fields defined, 
"password1" and "password2", both with render_value=False, and then the actual 
password is set after validating the second against the first.

hth

- Tom

> 
> Ricardo
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAJTdXTGzao5CaAfX9b%3Dyy_%2BG6LeEcSV1FA7Z11tALZ2WYR4XhQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14458EFE-CD22-4FB9-B6D7-6C79DF196435%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: Anyone tried a pre-existing django blog app like wordpress to add to their site?

2013-12-03 Thread Tom Lockhart

On 2013-12-03, at 7:02 PM, Creed Mangrum  wrote:

> Just wondering if there is any general feelings or inclinations to any good 
> ones out there. Thanks!

I've been using Mezzanine as the underpinnings for a bigger site. I can 
recommend it highly. Not familiar with others though.

 - 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/76893eda-564b-419e-a6b5-8e6c944a2f98%40googlegroups.com.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/644782B4-1851-4B8D-B3AE-9CAC4D66B179%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to integrate Postgresql db with Django,so that data will be retrieved from that postgresql db table and show it on browser via html

2013-12-03 Thread Tom Lockhart

On 2013-12-02, at 10:42 PM, Swastik Acharya  wrote:

> django 1.4 version
> postgresql 9.1 version
> 
> I have successfully loaded all the html files and css on browser using django.
> Now  i have some tables in postgresql ,which i need to integrate it with 
> django and .html files so that data will be read and execute both from html 
> file inputs and database table.
> what are the steps to achieve this ?
> 

If you have a working Django installation, you just need your models.py to have 
a definition matching your existing table(s) and you will probably want to have 
an admin.py to give you easy first access to these tables.

> the home.html contains the macid,hostname,blacklisted etc whatever are there 
> in postgresql table.
> i just need to connect and file up those blank spaces in html with data from 
> postgresql table.
> 

Have you worked through the Django tutorial?

You will need your home.html to retrieve your table items as context variables. 
Having a views.py with a view inheriting from ListView will probably be helpful 
here. Then your urls.py at the top level of your site needs to map the home 
page pattern ("^$") to your view.


> 
> for ex:
> my folder structure is
> >folder
>   >mysite
>   >app
> -static
> -style.css
> -main.css
> -templates
>   -home.html
> -init.py and init.pyc
> -models.py and models.pyc
> -test.py
> -views.py
> 
> >mysite
>   -init.py
>   -settings.py and settings.pyc
>   -urls.py and urls.pyc
>   -views.py and views.pyc
>   -wsgi.py
>   >mysite.db
>   >manage.py
> 
> 
> and in postgresql the table name is device_table
> and its contents are:
> 
> 
> CREATE TABLE device_table
> (
>   serial_no serial NOT NULL,
>   macid character varying(100) NOT NULL,
>   date_time_of_installation timestamp without time zone,
>   blacklisted boolean,
>   activated integer,
>   deactivated boolean,
>   reason character varying(500),
>   hostname character varying(255),
>   host_ip character varying(50),
>   agent_version character varying(75),
>   CONSTRAINT device_table_pkey PRIMARY KEY (macid)
> )
> WITH (
>   OIDS=FALSE
> );
> ALTER TABLE device_table OWNER TO postgres;
> 
> Note:I have created models.py by running inspectdb command.

Does your models.py have a Meta class with a line

  db_table="device_table"

?

Please post your urls.py and models.py and also give details on what specific 
problem you are seeing.

hth

   - 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/893C8680-F56E-4BA9-95F1-9DE83813EBCB%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html to odt

2013-11-22 Thread Tom Lockhart

On 2013-11-21, at 9:34 PM, Harjot Mann  wrote:

> I want to save my html django templates to odt file. Is there any way
> to do this?

Not sure what you actually want to do. If you are trying to capture your final 
html, you might be able to script something, possibly with selenium, to 
generate the page and then send it to Libre Office as a batch job:

http://stackoverflow.com/questions/16202103/how-to-open-file-in-libre-office-and-save-this-like-doc-file

hth

 - 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4082C55B-E4DC-425A-A239-5BC11B652042%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Psycopg2 on Mac OS X (Snow Leopard)

2013-11-10 Thread Tom Lockhart

On 2013-11-10, at 1:16 AM, Matthias Fripp <mfr...@gmail.com> wrote:

> I had the same problem. I am trying to make this work on a multi-user 
> machine. My two options seem to be

Neither seem good. I install most required packages which are not handled by 
pip using MacPorts (Homebrew works fine too afaik).

This has several advantages, not the least of which is you can avoid the 
shenanigans happening for your options (1) and (2) below. But the biggest 
advantage for me is that it gives me control over the versioning for the 
packages I am using. If you want to revlock on a version of Postgres, you can 
do that. If you want to run a different version from what Apple is shipping, or 
want to get a security release right away, you can do that. And you don't have 
to go diving down into Apple's library structure to figure out where things 
live or what version you are actually running.

hth

  - Tom


> 
> (1) Add this line to /etc/profile:
> 
> export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib
> 
> The disadvantage of this is that changing DYLD_LIBRARY_PATH doesn't seem to 
> be a common technique on Macs, and I'm not sure whether this would run if 
> python is being used by some specialized account (rather than a normal login 
> account).
> 
> (2) Create symbolic links in /usr/lib :
> 
> sudo ln -s /Library/PostgreSQL/9.3/lib/libpq.5.dylib /usr/lib/libpq.5.dylib
> sudo ln -s /Library/PostgreSQL/9.3/lib/libssl.1.0.0.dylib 
> /usr/lib/libssl.1.0.0.dylib
> sudo ln -s /Library/PostgreSQL/9.3/lib/libcrypto.1.0.0.dylib 
> /usr/lib/libcrypto.1.0.0.dylib
> (It may also have been possible to place these symbolic links in 
> /Library/Python/2.6/site-packages/psycopg2/ , next to _psycopg.so .)
> 
> The disadvantage of using these symbolic links is that it will be harder to 
> maintain when I switch to a new version of PostgreSQL. It was also tedious to 
> find the list of missing dylibs by trial and error (in retrospect, I could 
> have used otools -l /Library/Python/2.6/site-packages/psycopg2/_psycopg.so to 
> get a full list of the libraries needed for psycopg2).
> 
> I would still like to find the "normal" way to add the whole 
> /Library/PostgreSQL/9.3/lib/ directory to the Mac's dynamic library search 
> path, especially for a multi-user machine. Installing PostgreSQL via HomeBrew 
> instead of EnterpriseDB might take care of this automatically?
> 
> Matthias
> 
> On Monday, October 28, 2013 9:54:05 AM UTC-10, Skip Montanaro wrote:
> > I just had this exact same problem and it took me a while to find the 
> > solution. 
> > 
> > On OSx there is a separate library path variable for .dylib library files. 
> > I 
> > added the following to my .bashrc (or.bash_env or however you set up your 
> > shell environment). 
> > 
> > export 
> > DYLD_LIBRARY_PATH="/usr/local/Cellar/openssl/1.0.1e/lib/:$DYLD_LIBRARY_PATH"
> >  
> 
> Thanks for the suggestion. Found libssl in the PostgreSQL installation: 
> 
> % find / -name libssl.1.0.0.dylib 2>/dev/null 
> /Library/PostgreSQL/9.2/lib/libssl.1.0.0.dylib 
> /Library/PostgreSQL/9.2/pgAdmin3.app/Contents/Frameworks/libssl.1.0.0.dylib 
> 
> I guess that makes sense. I should be able to modify the activate 
> script and deactivate function to set/reset DYLD_LIBRARY_PATH 
> appropriately. 
> 
> Skip 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f914348c-462d-4c86-9fc1-0212e02e4c3b%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/618B480B-60A0-4305-BAAC-3030359D0523%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: Psycopg2 on Mac OS X (Snow Leopard)

2013-10-28 Thread Tom Lockhart

On 2013-10-27, at 7:46 AM, Doug Snyder  wrote:

> I don't have a very specific answer for your question. I just started doing 
> my django dev on OSX coming from Ubuntu
> My understanding is that Home Brew is a better solution than Mac Ports, I 
> have heard some people being very critical of Mac Ports which I think was 
> once the best solution for python environments on OSX but I think has been 
> mostly replaced by Home Brew. Switching over may solve your problem 
> automatically and may make life easier down the road too. But maybe someone 
> else will have a more knowledgable, specific answer to your specific problem.

I can't address any benefits of switching. But I have been using MacPorts for 
some time and have had no problems.

Not sure who "some people" are wrt MacPorts but I haven't noticed complaints or 
problems (or in fact, any discussion of MacPorts vs Homebrew) in the context of 
Django or Postgres on the mailing list. I'm pretty sure both do this job just 
fine.

hth

 - 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6EE04A48-58D9-41EF-B312-C83B0B0E5BB7%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: New to Django cannot figure URLpatterns

2013-10-14 Thread Tom Lockhart

On 2013-10-14, at 3:58 PM, Mark Strickland  wrote:

> I am new to using Django and I can get one urls to work, but I cannot get 
> another.  I am running Django 1.5
> 
> This url works.
> 
> url(r'^$', views.index, name='index'),
> 
> But if I try to follow this one.
> 
>  url(r'^(?P\D+)/$', views.detail, name='detail'),

Look at item 8 in the debug message below. I think you want something like

url(r'^/plugin/(?P\D+)/$', views.detail, name='detail'),

for the URL you want to match.

hth

 - Tom


> 
> I get the following error.when I try http://127.0.0.1:8000/plugin/title where 
> title is a unique key in the database.
> 
> Page not found (404)
> Request Method:   GET
> Request URL:  http://127.0.0.1:8000/plugin/cbs/
> Using the URLconf defined in urlconf, Django tried these URL patterns, in 
> this order:
> ^__debug__/m/(.*)$
> ^__debug__/sql_select/$ [name='sql_select']
> ^__debug__/sql_explain/$ [name='sql_explain']
> ^__debug__/sql_profile/$ [name='sql_profile']
> ^__debug__/template_source/$ [name='template_source']
> ^admin/doc/
> ^admin/
> ^plugin/ ^(?P\d+)/$ [name='detail']
> ^plugin/ ^$ [name='index']
> The current URL, plugin/cbs/, didn't match any of these. 
> 
> Any and all help or guidance would be greatly appreciated. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/3d625e8e-ff23-4411-a0e2-503b8496c286%40googlegroups.com.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02B1044E-EE5C-47DC-AA56-1F466E53ED24%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Static files configuration

2013-09-28 Thread Tom Lockhart

On 2013-09-28, at 4:58 PM, Tom Lockhart <tlockhart1...@gmail.com> wrote:

> 
> On 2013-09-28, at 4:21 PM, Jason S <ser...@gmail.com> wrote:
> 
>> Thanks Tom,
>> I had a pretty painful install experience over a few weeks and had sudo'd a 
>> command I shouldn't have when doing the GAE install. 
>> After that experience i'd thought it'd be a pain to sort it out but i've 
>> just chown'd the project directory and the /tmp/dev_appserver.searchindexes 
>> (after making a backup) and its fine.
>> 
>> Also your right I have recently added django.contrib.staticfiles to my 
>> INSTALLED_APPS list, so that may well be it.
>> 
>> So i'm able to start the dev server as a standard user now and have my 
>> static content for my project served from [project]/templates/static/ but 
>> managed to break the admin css in the process.
> 
> I'm pretty sure mine is getting picked up after running "python manage.py 
> collect_static" since that css lives somewhere in your installed python code.

Whoops. There is no underscore in the command. Sorry about that.

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


Re: Static files configuration

2013-09-28 Thread Tom Lockhart

On 2013-09-28, at 4:21 PM, Jason S <ser...@gmail.com> wrote:

> Thanks Tom,
> I had a pretty painful install experience over a few weeks and had sudo'd a 
> command I shouldn't have when doing the GAE install. 
> After that experience i'd thought it'd be a pain to sort it out but i've just 
> chown'd the project directory and the /tmp/dev_appserver.searchindexes (after 
> making a backup) and its fine.
> 
> Also your right I have recently added django.contrib.staticfiles to my 
> INSTALLED_APPS list, so that may well be it.
> 
> So i'm able to start the dev server as a standard user now and have my static 
> content for my project served from [project]/templates/static/ but managed to 
> break the admin css in the process.

I'm pretty sure mine is getting picked up after running "python manage.py 
collect_static" since that css lives somewhere in your installed python code.

btw, if you aren't using virtualenv and pip for python packages I would highly 
recommend that you spend a few minutes to get that going.

- Tom

> 
> INFO:root:"GET / HTTP/1.1" 200 -
> INFO:root:"GET /static/css/base.css HTTP/1.1" 200 -
> INFO:root:"GET /static/img/MainBanner.png HTTP/1.1" 200 -
> INFO:root:"GET /admin HTTP/1.1" 301 -
> INFO:root:"GET /admin/ HTTP/1.1" 200 -
> INFO:root:"GET /admin/css/base.css HTTP/1.1" 404 -
> INFO:root:"GET /admin/css/dashboard.css HTTP/1.1" 404 -
> INFO:root:"GET /admin HTTP/1.1" 301 -
> INFO:root:"GET /admin/ HTTP/1.1" 200 -
> INFO:root:"GET /admin/css/base.css HTTP/1.1" 404 -
> INFO:root:"GET /admin/css/dashboard.css HTTP/1.1" 404 -
> 
> I've put the base.css file everywhere in the hopes of finding a location that 
> the admin module will pick it up from, but have just made a mess can you 
> advise where I should expect the admin module to pick up it's CSS? 
> Once i've gotten the admin CSS working and confirmed the dev site's static 
> content is still working, i'll clean all of the directories with CSS that 
> aren't needed in the myapp directory and can start trying to make something!
> 
> ./django-1.4/django/contrib/admin/static/admin/admin/css/base.css
> ./django-1.4/django/contrib/admin/static/admin/css/base.css
> ./myapp/admin/admin/css/base.css
> ./myapp/admin/css/base.css
> ./myapp/templates/admin/css/base.css
> ./myapp/templates/static/css/base.css
> ./myapp/blogtut/static/css/base.css
> ./myapp/css/base.css
> ./myapp/static/admin/admin/css/base.css
> ./myapp/static/admin/css/base.css
> ./myapp/static/css/base.css
> ./django-testapp/admin/admin/admin/css/base.css
> ./django-testapp/templates/admin/admin/css/base.css
> 
> 
> 
> 
> On Saturday, 28 September 2013 13:03:07 UTC-10, Thomas wrote:
> 
> On 2013-09-28, at 3:27 PM, Jason S <ser...@gmail.com> wrote: 
> 
> > I can now access my CSS file and i've confirmed it's location by changing 
> > its name and confirming the dev server can't see it any more.after I change 
> > the file name. 
> > 
> > The directory its finding it is under [project]/templates/static/css 
> > Sorry, no idea why its working but I suspect its permissions based as i'm 
> > running udo python manage.py runserver 0.0.0.0:8080 
> > I think the dev server is only accessing files owned by root? It doesn't 
> > sound right though. 
> 
> Is there another reason you are running as root? I've been doing all 
> development with my normal user account and have seen no issues at all. If 
> you do have permissions problems those should go away if everything is owned 
> by you rather than root. 
> 
> And you may have enabled django.contrib.staticfiles in your INSTALLED_APPS. I 
> think that helps to find files when you are running the development server. 
> There is a nice chapter in the Django docs on serving static files. 
> 
> hth 
> 
> - 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.
> For more options, visit https://groups.google.com/groups/opt_out.

Tom Lockhart
tlockhart1...@gmail.com



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

Re: Static files configuration

2013-09-28 Thread Tom Lockhart

On 2013-09-28, at 3:27 PM, Jason S  wrote:

> I can now access my CSS file and i've confirmed it's location by changing its 
> name and confirming the dev server can't see it any more.after I change the 
> file name.
> 
> The directory its finding it is under [project]/templates/static/css
> Sorry, no idea why its working but I suspect its permissions based as i'm 
> running udo python manage.py runserver 0.0.0.0:8080
> I think the dev server is only accessing files owned by root? It doesn't 
> sound right though.

Is there another reason you are running as root? I've been doing all 
development with my normal user account and have seen no issues at all. If you 
do have permissions problems those should go away if everything is owned by you 
rather than root.

And you may have enabled django.contrib.staticfiles in your INSTALLED_APPS. I 
think that helps to find files when you are running the development server. 
There is a nice chapter in the Django docs on serving static files.

hth

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


Re: Help with Django installation on windows

2013-09-21 Thread Tom Lockhart

On 2013-09-21, at 1:27 PM, Poom Buncha  wrote:

> Hi all
>  
> First off, I like to say that I am a beginner to everything related to 
> computing. So I have to appologize a head of time if what I am asking is 
> common sense.
> I'm trying to install Django on my windows computer
>  
> So I install Python 2.7 (and went throught the tutorial)
> I downloaded the django tar file. and extracted the content using 7zip 
> program.
> I did not know where to put it so I put it into the Python folder
>  
> when I open up a comand prompt for python I type in "import django" and 
> "django.get_version()" those commands seem to run fine
> but when I type in  
> "django-admin.py startproject mysite" I get an error message that say the 
> name admin is not define. Can you tell me what I am doing wrong?
>  
> Thank you for any help you can provide. And if anyone have any tip and best 
> practices that they can share with me about getting started in Django it will 
> be greatly appreciated
> 

I'm afraid I can't offer specific advice for Windows. But I can recommend that 
you use virtualenv and pip for everything involving python beyond your initial 
python installation. You will find your environment to be more maintainable and 
repeatable.

Good luck!

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


Re: django security

2013-09-06 Thread Tom Lockhart

On 2013-09-06, at 4:04 PM, Natko Perko  wrote:

> 
> Obviously not and obviously I couldnt google it.

Ah, of course. What is obviously not obvious to you is not obvious to the rest 
of us either.

Please be specific on what you did find and what you feel you are missing. Even 
if it is obvious. Or not.

hth

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


Re: djangoadmin: Multiple record created upon mulitple clicks on "Save" button

2013-09-05 Thread Tom Lockhart

On 2013-09-05, at 5:14 AM, Vincent Tou Liu <vin...@gmail.com> wrote:

> Dear all,
>  
> I am a newbie to djaogo and just started with the django doc 2 days ago.  I 
> have a problem with creating record in django admin page.  When I create new 
> poll record and click on "Save" button 3 times before the page reload, it 
> will create 3 records in the database.  How can I limit it to create just one 
> record?

Click the button once?

A more helpful suggestion would be to require the poll record to be unique so 
that your subsequent saves will fail. Look up the "unique=True" field attribute 
in the docs.

hth

 - Tom

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

Tom Lockhart
tlockhart1...@gmail.com



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

Re: else: invalid syntax

2013-08-29 Thread Tom Lockhart

On 2013-08-29, at 5:33 AM, Nagarajan Dharmar Sitha 
 wrote:

> if (os.stat('udacityLastFileNumberForL.txt').st_size == 0):
> MaxNumberFile = open("udacityLastFileNumberForL.txt", "w")
> self.udacityFileVersionNumberL = 1
> MaxNumberFile.write("DATA_VERSION_CONSTANT_M: %s" % 
> self.udacityFileVersionNumberL)
> MaxNumberFile.close()
> else:
> MaxNumberFile = open('udacityLastFileNumberForL.txt', "r")
> for LastFileNumber in MaxNumberFile.readlines():
> 
> 
> it show error:
> 
> else:
>^
> SyntaxError: invalid syntax
> 
> Kindly help me for debug this

It looks like your indenting might be off. The "else" must line up exactly with 
the "if".

hth

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


Re: recaptcha options... which one to choose

2013-08-23 Thread Tom Lockhart

On 2013-08-23, at 11:19 AM, TinyJaguar  wrote:

> I'm about to implement recaptcha in my feedbackform but I'm a bit confused by 
> all the possibilities.
> Should I use:   
> recaptcha-client 1.0.6 or recaptcha 1.0rc1. 
> django-recaptcha or django-recaptcha-works
> other options? what would be your sane choice?

fwiw I stuffed recaptcha-client into one of my forms as a one-liner and It Just 
Worked.

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


Re: Digest for django-users@googlegroups.com - 25 Messages in 3 Topics

2013-08-22 Thread Tom Lockhart

On 2013-08-22, at 9:39 AM, Tom Evans  wrote:

> On Thu, Aug 22, 2013 at 5:14 PM, Shahmi Junoh
>  wrote:
>> Dear admin,
>> 
>> Kindly remove my subscription of this mailing list. Or how do I achieve
>> this?
> 
> At the bottom of the email you just forwarded to the list was this text:
> 
> 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.
> 
> Don't you look silly now?

It sure looked to me like that is what he did yesterday. The to field on the 
original email was sent to the link (including the "+unsubscribe") but it came 
to the list instead.

Perhaps we could politely ask him to try again, or to go to google groups and 
unsubscribe manually (assuming that is possible).

hth

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


Re: ManyToManyField select only results that match

2013-08-21 Thread Tom Lockhart

On 2013-08-21, at 7:25 AM, Gerd Koetje  wrote:

> He Thomas, ur right i didnt explain myself very well.
> 
> 
> What im trying todo is this.
> 
> I have a mode that holds all my form field values in difrant group , name: 
> Keuzes  
> Now i want to populate multiple form fields with these values based on wich 
> groep i want them to be.
> I onloy seem to get this to work if i make a difrant model for each field, 
> cant i just use 1 model with a group field and select the value bases on the 
> group i ask for?
> 
> I think im still a bit confused what i should do i models and what i should 
> do in forms.
> 

Models set up the relationships and forms pull those together for presentation 
or manipulation. I think ;)

So now I'm not sure what you are asking for. Perhaps I could understand from 
the names you have chosen for fields and models, but I am still uncertain.

So you have a set of possible field values, and want to be able to group those 
into different sets for a form, right?

class FieldValues(models.Model):
  name = CharField()
  pass

class FieldGroups(models.Model):
  group_name = CharField()
  values = ManyToManyField(FieldValues, related_name="groups")
  pass

Unless I've got myself turned around, I think you can access fields from the 
groups model and groups from the fields model. Something like

MyGroups = FieldGroups.objects.all()
MyFields = FieldValues.objects.filter(groups__group_name="the group I want")

hth

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


Re: ManyToManyField select only results that match

2013-08-21 Thread Tom Lockhart

On 2013-08-21, at 3:46 AM, Gerd Koetje  wrote:

> anyone willing to help out?

I was confused by your original example, talking about a form but then showing 
just one field in a model definition. So I was waiting to learn something from 
a knowledgable response. Instead you are stuck with my guessing ;)

Assuming that those ManyToManyField lines are in a model, here is the problem. 
The related_name argument helps you to access the values in that model from 
Keuzes, using syntax like "keuzes_kleurogen__mykleurogenfield". But the model 
definitions will result in only one intermediate table to mediate the 
many-to-many relationship. You will want two separate intermediate tables for 
that, not one.

Look at the "through" attribute for ManyToManyField and define an extra 
intermediate table for one of those two relationships.

hth

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


Re: Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Tom Lockhart

On 2013-08-20, at 9:02 PM, Diek Kearney  wrote:

> I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
> current point everything was running smoothly, then I hit a wall that I 
> cannot figure out. Maybe I am too focused on following, anyways I need some 
> help.
> ...
> The next step is "Take a look in your browser, at “/polls/34/”. It’ll run the 
> detail() method and display whatever ID you provide in the URL. Try 
> “/polls/34/results/” and “/polls/34/vote/” too – these will display the 
> placeholder results and voting pages." I tried and nothing. It generates a 
> 404 error. Where exactly is the 34 coming from? I like to think things 
> through but as a beginner in django following a tutorial I need more when it 
> comes to this section.


Hmm. This *is* confusing since the tutorial should call out the "34" as an 
example but does not. And at that point in the tutorial it has not given you 
instruction to enter a particular poll, and not shown you how to get the poll 
id for any poll you actually did enter.

I was going to suggest that you go to "/polls" to see a list of available 
polls, but at that point in the tutorial the view for that does not yet exist 
so no luck there either.

You can try something like:

  python manage.py shell
from polls.models import Poll
Poll.objects.all().values()

which will give you a keyword:value list of all fields in your poll model, 
including the "id" field. That is the value to use in their example query, not 
the arbitrary "34". Once you have the id (primary key) for a poll, you can try 
the detailed view which they *have* defined!

You can also look in the database itself for the same info. Try

  python manage.py dbshell
select * from polls_poll;

hth

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


Re: Defining custom template tags in a new app

2013-08-20 Thread Tom Lockhart

On 2013-08-20, at 3:53 AM, kandelabr  wrote:

> Hello!
> 
> I want to define a new template tag and use it in a number of applications 
> inside my django project. The documentation says:
> 
> Custom template tags and filters must live inside a Django app. If they 
> relate to an existing app it makes sense to bundle them there; otherwise, you 
> should create a new app to hold them.
> 
> But I could not find a word in documentation on how to {% load %} tags from 
> another app. I added the new 'custom_tags' app it to INSTALLED_APPS, 
> registered, imported the tag, restarted the server, etc., but I couldn't get 
> past the error page: 
> 
> 'custom_tags' is not a valid tag library: Template library custom_tags not 
> found, tried 
> django.templatetags.custom_tags,django.contrib.staticfiles.templatetags.custom_tags,django.contrib.admin.templatetags.custom_tags
> 
> Could someone please explain where to put my custom tags so that I will be 
> able to reuse them throughout the project?

You have not explained exactly where you put your "custom_tags" app. Check the 
following things:

o The custom_tags/ directory should be in the same directory as your manage.py
o Your template tag(s) should be in, say, 
custom_tags/templatetags/custom_tags.py
o There should be two empty files, custom_tags/__init__.py and 
custom_tags/template_tags/__init__.py
o Use "{% load custom_tags %}" where the "custom_tags" here refers to the file 
name, not the app name

I'm guessing you have most of this but are missing the __init__.py files.

hth

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


Re: Returning random model objects - is order_by('?') on Postgres safe to use now?

2013-08-07 Thread Tom Lockhart
I haven't used the feature, but there is no reason to think that having the db 
backend do a random sort is any slower than you doing it yourself.

If your query can reduce the number of rows returned to a relatively small 
number, any "order by" should have acceptable performance. If not, it will be 
expensive no matter who does the work.

hth

- Tom

On 2013-08-07, at 6:55 PM, Victor Hooi  wrote:

> Hi,
> 
> We have some code to return randomised Django model instances.
> 
> Initially, I was using random.randint(), and returning objects by index 
> between 0 < max_id.
> 
> This was based on the Django docs:
> 
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by
> 
> specifically, the part:
> 
> Note: order_by('?') queries may be expensive and slow, depending on the 
> database backend you’re using.  
> 
> This blog post from February 2011 also seems to back that up:
> 
> http://www.peterbe.com/plog/getting-random-rows-postgresql-django
> 
> However, I just ran the benchmarks on my own box running Django 1.5 and 
> Postgres 9.2.4, and the ORDER BY RANDOM() approach was slower, but not 
> substantially so (certainly not to the extent hinted at by the blog post).
> 
> I'm curious - what are other people's experiences with using ORDERY BY RANDOM 
> versus other approaches? 
> 
> Has Postgres made some recent changes which makes ORDER BY RANDOM the better 
> option now?
> 
> Which database backends specifically should we be warned about when saying 
> that order_by('?') is expensive and slow?
> 
> Cheers,
> Victor
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


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




Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Tom Lockhart

On 2012-09-13, at 10:17 AM, Bob Aalsma wrote:

> Django 1.4.1
> Python 2.7.3
> OS X 10.7.4

Ah, OS X…

You need to (slightly) modify your manage.py file to add this near the top:

import os
os.environ.setdefault('LANG','en_CA')

substituting your favorite language setting of course.

hth

- Tom


> 
> 
> Op donderdag 13 september 2012 19:12:30 UTC+2 schreef creecode het volgende:
> Which version of django are you using?
> 
> On Thursday, September 13, 2012 7:58:11 AM UTC-7, Bob Aalsma wrote:
> 
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
> manage.py createsuperuser --username=joe --email=j...@example.com
> 
> Using this leads to an error, which I could match to the closed ticket #16017.
> 
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
> 
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I couldn't 
> find that either]
> 
> Toodle-loo.
> creecode 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/UnmJDyc7alQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Mac.... Won't Download, sync to python, or install... please help

2012-08-18 Thread Tom Lockhart

On 2012-08-18, at 1:28 PM, phil archambault wrote:

> Hey django users I'm trying to figure out how to dl and install django into 
> py, but I'm not having any luck with this issue. I have followed the 
> directions down to the tee and issue still stands, any help help would be 
> greatly appreciated!

Not sure what instructions you are following, and whether they are actually 
done the tee. You need to be more specific to get help.

If your instructions do not happen to use virtualenv you might want to find new 
instructions, especially if you are new at this. It makes it much easier to get 
a consistent installation.

hth

   - Tom

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