syncdb failure in new project with 1.4c2

2012-03-17 Thread Thomas Lockhart
I see this is an old ticket (#16017) but the same failure is showing in
1.4c2 and the code does not reflect the solution suggested in the ticket
comments:

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

You just installed Django's auth system, which means you don't have any
superusers defined.
Would you like to create one now? (yes/no): yes
Traceback (most recent call last):
  File "manage.py", line 9, in 
execute_from_command_line(sys.
argv)
  File
"/Users/lockhart/Desktop/bsi/django/vetest/lib/python2.7/site-packages/django/core/management/__init__.py",
line 443, in execute_from_command_line
utility.execute()
  File
"/Users/lockhart/Desktop/bsi/django/vetest/lib/python2.7/site-packages/django/core/management/__init__.py",
line 382, in execute
...
  File
"/Users/lockhart/Desktop/bsi/django/vetest/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
line 105, in get_default_username
default_username = get_system_username()
  File
"/Users/lockhart/Desktop/bsi/django/vetest/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
line 85, in get_system_username
return getpass.getuser().decode(locale.getdefaultlocale()[1])
TypeError: decode() argument 1 must be string, not None


locale.getdefaultlocale() should return something other than (None,None) if
environment variables are set but istm that this should fail gracefully (or
not fail at all; the ticket suggests a solution using a different call
which does return a non-None on my system).

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.



Re: Does Django guarantees to generate well Optimized SQL Query ??

2012-05-18 Thread Thomas Lockhart

On 5/18/12 10:02 AM, George Silva wrote:

Yes and no.
And it does not (can not) protect one from building a bad model which 
could result in bad performance. So having a requirement for high 
performance without having done some reading on data normalization and 
SQL schema design probably gets the new user out of the "guaranteed 
well-optimized" realm.


One should also know how to work with the underlying database to 
evaluate and update the optimizer information otherwise the optimizer 
might make bad guesses for an otherwise perfectly good query.


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.



Re: Python Web Development with Django by Wesley Chun

2012-05-22 Thread Thomas Lockhart

On 5/22/12 6:46 AM, Russell Keith-Magee wrote:

... We *will not* condone any
attempt to use official Django forums as a way to circumvent
copyright.


Thanks Russell!

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



Re: Django GeoIP Module not found; can't remedy

2012-05-28 Thread Thomas Lockhart

...
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", 
line 353, in __init__

self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/libGeoIP.dylib, 6): no suitable image 
found.  Did find:

/usr/local/lib/libGeoIP.dylib: mach-o, but wrong architecture"

I've been using macports and virtualenv so have not run into this 
(pretty much everything gets built and installed in /usr/local, 
including a new build of python itself).


But you are using Apple's python and a homebrew build of GeoIP and 
python is clearly complaining that you do not have a compatible build of 
the library.


Use the "file" command to examine the python installation and your 
libGeoIP library (example from my system; yours has some different paths):


$ otool -L /usr/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/Python 
(compatibility version 2.7.0, current version 2.7.1)

...
$ file /System/Library/Frameworks/Python.framework/Versions/2.7/Python
/System/Library/Frameworks/Python.framework/Versions/2.7/Python: Mach-O 
universal binary with 2 architectures
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (for 
architecture x86_64):  Mach-O 64-bit dynamically linked shared 
library x86_64
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (for 
architecture i386):Mach-O dynamically linked shared library i386


I would include the geoip library in my example but it is having trouble 
building from MacPorts. Am looking into that :/


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.



Re: How to use an optional ForeignKey to sites.Site and admin's "View on site"?

2012-05-29 Thread Thomas Lockhart

...

Hi,

I have a model which has a ForeignKey to the Django contrib sites.Site model. 
This field should be optional.

If it is optional it is not a foreign key. You can put a constraint on 
the field to have a non-null value be present in the other table, and 
perhaps there is a way to do this from a django model but I haven't 
looked at that.


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.



Re: how to tell apache to see my projects database file?

2012-05-30 Thread Thomas Lockhart

On 5/30/12 1:11 AM, doniyor wrote:
hey man, problem solved. i did *chown www-data. . *then *chmod 777 
dbfile *now everything is working fine. thank you so much for your 
time and help. 
I've lost track of the early parts of this thread, but chmod 777 on a 
database rarely indicates that everything is fine. The chown did not 
matter much once you gave everyone in the universe write access to the 
database.


This issue started as a permissions problem and still is a permissions 
problem. Figure out which user is actually accessing your database and 
get the permissions you need.


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.



Re: how to tell apache to see my projects database file?

2012-05-30 Thread Thomas Lockhart

On 12-05-30 7:04 AM, doniyor wrote:
what do you mean? should i do better chmod 755 which is more secure 
than 777?
You can do whatever you want. But the advice from the list is to figure 
out what account is actually accessing the database and keep the 
permissions on the DB the way they should be. That may be different for 
different databases.


So you have two things to figure out:
1) What is the effective user for your database accesses?
2) What permissions should be set on the database directories and files?

hth

- Tom




Am Mittwoch, 30. Mai 2012 14:29:14 UTC+2 schrieb Thomas:

On 5/30/12 1:11 AM, doniyor wrote:

hey man, problem solved. i did *chown www-data. . *then *chmod
777 dbfile *now everything is working fine. thank you so much for
your time and help. 

I've lost track of the early parts of this thread, but chmod 777
on a database rarely indicates that everything is fine. The chown
did not matter much once you gave everyone in the universe write
access to the database.

This issue started as a permissions problem and still is a
permissions problem. Figure out which user is actually accessing
your database and get the permissions you need.

hth

   - Tom

--
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/-/UOlT738Mi6gJ.

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.



Obtaining objects from a many-to-many relationship

2012-06-01 Thread Thomas Lockhart
I've got two models with one having a many-to-many relationship with the 
other:


class A(models.Model):
  name = models.CharField("name")

class B(models.Model):
  haveone = models.ManyToManyField(A)

What is the idiom for getting all instances of A which are referenced in 
B? I found this works:


A.objects.annotate(n=models.Count('b')).filter(n__gt=0)

But istm that there is probably a more concise and straightforward way 
to accomplish this (and the solution is probably obvious but it is 
escaping me). tia


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



Re: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Thomas Lockhart

On 12-06-02 1:15 AM, Kurtis Mullins wrote:

Have you tried b.haveone.all()?

Yes. Simplemindedly I wanted to try

B.haveone.all()

If I understand your suggestion, it would require iterating on instances 
of B to find all instances of A mentioned in B.


that would be something like

for b in B.objects.all():
  a = b.haveone.all()
  ...

which of course does work fine but may require visiting an instance of A 
more than once.


What I'm looking for is to select all unique instances of A which appear 
in B without iterating on B. Not all instances of A appearing in b (one 
specific instance of B).


tia

 - Tom



On Sat, Jun 2, 2012 at 12:36 AM, Thomas Lockhart 
mailto:tlockhart1...@gmail.com>> wrote:


I've got two models with one having a many-to-many relationship
with the other:

class A(models.Model):
 name = models.CharField("name")

class B(models.Model):
 haveone = models.ManyToManyField(A)

What is the idiom for getting all instances of A which are
referenced in B? I found this works:

A.objects.annotate(n=models.Count('b')).filter(n__gt=0)

But istm that there is probably a more concise and straightforward
way to accomplish this (and the solution is probably obvious but
it is escaping me). tia

 - 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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@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.


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



Re: Django unsupported locale settings

2012-06-05 Thread Thomas Lockhart

On 6/5/12 4:06 AM, Mo Mughrabi wrote:


I've been developing an application using Django for the past a year. 
The application was written in a Debian environment, the development 
and testing was entirely done in a debain machine.


Recently, I decided to move the application to my local Mac OS X based 
laptop. using port's I did a virtual environment and pulled my project 
from github. When I try to runserver, am getting "unsupported locale 
setting" exception.




Mac-based development is working great for me. But you do have to modify 
manage.py slightly, and add the following:


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

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.



Re: Where are my posts?

2012-06-16 Thread Thomas Lockhart

On 6/16/12 2:35 PM, Laurence MacNeill wrote:
How do I get privileges to post in this group?  I've posted two 
questions, and have not seen them pop up yet...  Who do I need to 
contact to get posting privileges?  I really was hoping to get these 
questions answered soon.
fwiw I've never seen my posts "pop up". If you send from gmail.com then 
it apparently filters out mail from yourself. I'll bet you see your 
posts in the archives...


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



Re: Django on Mac OS X

2012-06-16 Thread Thomas Lockhart

On 6/16/12 9:41 PM, Moshe Voloshin wrote:

I tried that too, but it didn't change anythin
Tried what too? I've had good luck with python, virtualenv, and 
postgresql from MacPorts and then using virtualenv and pip to get 
psycopg2, django, etc.


The library path from your error indicates that you are using the Apple 
python installation which is not what you would find with MacPorts. You 
do have /opt/local/bin in your path?


Try for a self-consistent installation and you should stop getting 
unresolved symbols.


You will likely need to give more details on what you are actually 
running and where it is installed for someone to give more help.


hth

   - Tom



On Saturday, June 16, 2012 9:21:38 PM UTC-7, Kurtis wrote:

Try using the Brew (or ports or whatever it's called on Mac)
system to install Python, PostgreSQL, and the postgresql
development libs.



--
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: Oracle: blank, null, and empty_strings_allowed

2012-06-20 Thread Thomas Lockhart

On 6/20/12 3:33 AM, Melvyn Sopacua wrote:

On 20-6-2012 0:49, André Pang wrote:

The idea is to try to ensure that no empty strings make it to the
database, so you're not allowed to insert them into the database. You
can ensure this at the Django (ORM) layer right now with blank=True for
the admin or by checking the blank attribute manually in your own code,
but there's no database-level restriction, which is what I'm after.

Because this would break consistency. Your application would behave
differently for different backends, which is rather confusing.
There is great value in enforcing data integrity at the database level. 
Django does a beautiful job of mapping code to database definitions and 
in some sense that might distract from the traditional approach of 
defining databases and integrity independent of the application. imho 
one should not feel shy about adding additional constraints or checks at 
the database level. If your app enforces everything you hope it does 
then your db constraints will never be triggered, and if your app has a 
hole in it then your database will catch it and keep bad data from 
polluting it.


There are other ways around this too: in Postgres at least you can 
define a rule which would substitute a null for a blank on data entry.


Breaking consistency between backends sounds bad, but designing to the 
least common denominator is not a requirement. This may just suggest 
that other backends which can distinguish between nulls and zero-length 
strings would be a better choice for some apps ;)


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.



Re: New to DJANGO

2012-06-21 Thread Thomas Lockhart

On 12-06-21 9:37 PM, LJ wrote:
I started out learning Django using the "Writing your first Django 
app" article:

https://docs.djangoproject.com/en/dev/intro/tutorial01/
This is a very well-written tutorial that goes through each part in 
detail.
+1 anyone starting with Django is wasting time if they do not go through 
the tutorial as a first step. They will end up there anyway sooner or 
later...


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



Re: Creating permalink for blog tags that have the Post class as foreign key

2012-06-25 Thread Thomas Lockhart

On 12-06-24 7:18 PM, Matthew Meyer wrote:
After making some changes debugging in the shell revealed, I have 
gotten it to work, thanks!!!

So what was the solution??!!!

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



Re: Custom SQL for creating django tables

2012-06-25 Thread Thomas Lockhart

On 12-06-25 1:35 AM, Mina Farid wrote:

Hello guys,
I am connection from django to Apache Derby. I am using IBM DB2 driver 
backend.
Django tables are created in DB2 syntax, which is not very compatible 
with Derby.


Is there any way that I can force django to customize the creation of 
SQL to a certain (say SQL standard) syntax?



That is what the database backends do.

If you are looking for "SQL standard" syntax, try using the Postgres 
backend. The standards documents were used to implement the Postgres 
parser (most other DBs did their own thing in some areas or have legacy 
syntax to support).


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.



Re: ForeignKey problem

2012-06-25 Thread Thomas Lockhart

On 12-06-25 10:02 AM, Adrian Bool wrote:

On 25 Jun 2012, at 17:53, Soviet wrote:


Thank you kind sir for your fast response, that worked brilliantly.
Can I be cheeky and ask why does it work? :)

Magic! ;-)

The mechanism must involve deferred resolution of the second model by 
passing the model class name in as a string. Without string syntax 
python insists on knowing what that class is at the time it sees the 
reference. Don't know more than that though ;)


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



Re: ManyToManyField is this right?

2012-06-27 Thread Thomas Lockhart

On 12-06-27 6:57 AM, David Wagner wrote:
I'm a self taught programmer who hasn't done much of anything for 
years so please forgive me if this question is naive. I have a hard 
time sometimes understanding some of the lingo used by trained 
programmers.


With that said, I'm having trouble wrapping my brain around the 
ManyToMany and Many-To-One and OneToOne concepts. I'm trying to create 
a multi-select option for a user profile in which a user can have 
multiple attributes of a certain kind. Right now I'm just working on 
the model. This is what I have, is it right?


# Different licenses for instructors to select from
class Licenses(models.Model):
nra = models.BooleanField()
ccl = models.BooleanField()
I am not familiar with the licenses you are referring to. But if "nra" 
and "ccl" are each a kind of license rather than attributes for each 
kind of license (google implies this involves gun licensing??!!) you 
will want a separate record for each license type. Something like


class Licenses(models.Model):
name = models.CharField(_("Name"), max_length=20)

then populate the license table with an entry for each license type 
"nra" and "ccl".


The "many to many" relationship you are modeling would have multiple 
license entries for multiple users and this is done by having multiple 
entries for each model rather than stacking multiple choices into a 
single model.



# User Profile Model
class UserProfile(models.Model):
user = models.OneToOneField(User)

 #...

licensed_instructor = models.ManyToManyField(Licenses)
You may want to name this field "licenses" rather than 
"licensed_instructor" for convenience and by convention.


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.



Re: ManyToManyField is this right?

2012-06-27 Thread Thomas Lockhart

On 12-06-27 8:02 AM, David Wagner wrote:
Thanks for all the replies and I think I'm getting it now but it gets 
more complex too.


So NRA Licenses is essentialy going to become a type of several 
certifications. For instance.


NRA Instructor

  * Home Firearm Safety Instructor
  * Refuse to be a Victim Workshop
  * and many more could be selected.

CCL (or CCW in some states)

  * State in Which your Certified (possibility of multiple states)

Many more different types of licenses and certifications are going to 
be added eventually so as you can see these relationships are going to 
get complex. So If I'm grasping this correctly let me try some code to 
see if I'm on the right track


class NRA_Certs(models.Model):
CRSO = models.BooleanField(blank=True, null=True, "Chief Range 
Safety Officer")
HFS = models.BooleanField(blank=True, null=True, "Home Firearm 
Safety")
MCR = models.BooleanField(blank=True, null=True, "Metallic 
Cartridge Reloading")
PPH = models.BooleanField(blank=True, null=True, "Personal 
Protection in the Home")
PPO = models.BooleanField(blank=True, null=True, "Personal 
Protection Outside the Home")

PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell 
Reloading")

SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be 
a Victim Workshop")
RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a 
Victim Online")
NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA 
Muzzleloading Pistol Shooting")
NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA 
Muzzleloading Rifle Shooting")
NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA 
Muzzleloading Shotgun Shooting")


class NRA(models.Model):
cert_type = models.ForeignKey(NRA_Certs)
name = models.CharField() # Is this necessary? Can the name be set 
to text in the boolean fields from NRA_Certs?

expiration = models.DateField(blank=True, null=True)

Does that look right or am I missing it completely. I'm not sure sure 
on the NRA_Certs all being boolean, my thinking is that whether they 
have that certification should be as simple as true/false.



Probably not. What happens if another new cert gets added to the the 
list? You will want a separate table entry for each kind of cert so when 
"Howitzer" gets added you can make that available without changing your 
models, only changing your data in the database.


afaict your new proposed class "NRA" does not add value here. Have 
certs, and have users. Should be enough.


You do have more than one piece of info for the cert model: an acronym 
and a long name or description. Those should be two fields in the model. 
Then use the many to many relation to allow multiple certs for each user 
and to allow multiple users to have the same cert.


hth

- Tom


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



Re: ManyToManyField is this right?

2012-06-27 Thread Thomas Lockhart

On 6/27/12 11:48 AM, David Wagner wrote:
Looking at that I think I may need to add a foreignkey to cert_types 
relating to person since a person can have multiple certification 
types (NRA Instructor, CCL Instructor, etc).

No. See below.


On Wed, Jun 27, 2012 at 11:40 AM, David Wagner > wrote:


i think I may just be over thinking this. The last time I did any
significant coding for the web as pre-php5 and so this whole MVC
thing is something to adapt too for sure.


Yes you are :)



I think I need to start thinking of the Model in the same way I
would design a database back in the day with phpMyAdmin. I think
I'm getting bogged down in trying to understand how it will relate
to the View. Perhaps I need to just put the View out of my mind
for the time being.

Yes. If you've done databases (that is some of my background too) then 
the models (always the first step here) should become comfortable fairly 
quickly, even if you are rusty. See below...



So thinking of this as just a database schema it would be
something like (in psuedo-code)

cert_types

  * type
  * date_created

certs

  * type = foreignkey(cert_types)
  * name
  * state (optional)
  * date_created

person

  * name
  * etc...
  * certificates = foreignkey(certs)

OK, "cert_types" is good (or at least a good start). "person" needs to 
have a manytomany on cert_types rather than a foreign key on certs. And 
"certs" can be the explicit intermediate table used for the manytomany 
relationship and can hold things like dates. Look at the django docs on 
how to explicitly define the intermediate table, but it is in the 
musician and musical group example; google for "paul ringo django extra 
fields" :)


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.



Re: am new bird to django,need some suggestion...please please do reply friend..

2012-07-02 Thread Thomas Lockhart

On 7/2/12 10:38 AM, manish girdhar wrote:
h i will try my best.actually i have already read that 
documentation but when i went to make application,then i got problem 
in using filter functions..and this kind of functions are not 
mentioned in the documentation.thats why i was facing 
problem.anyhow i will again read this...but friend can you send me 
the link of a basic small application..so that i just hang into that...
Hello Manish. The tutorial gives you a basic small application. You will 
have better luck on the mailing list if you can take the time to follow 
the advise you have already received.


The documentation does discuss filters. Please google it if you have 
trouble finding it directly.


I am relatively new to Django, but have been consistently impressed with 
the level of documentation. Take advantage of it yourself too.


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.



Re: Foreign Key needs quotes?

2012-07-02 Thread Thomas Lockhart

...

So I wanted to know, which is the right way to go or it does not matter?
I prefer without quotes for most cases. But for cases when a model is 
not yet defined (for example, you want to define a foreign key to a 
model which comes later in the source file) then you need to use the 
quotes to keep python from complaining about an undefined class.


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.



Re: 1.4: Emails to BCC addresses not sent

2012-07-06 Thread Thomas Lockhart

...


If that fails as well, I guess a ticket is in order, but like I said
"works for me" (in version 1.4).
If that doesn't fail, then make sure cco is filled.

fwiw it works for me too in 1.4 using virtualenv. Thanks Melvyn for the 
simple example.


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



Re: If using South, does it even matter what the underlying database is?

2012-07-06 Thread Thomas Lockhart

On 12-07-06 8:56 AM, Houmie wrote:
Today I have started my first steps into postgresql, since its 
recommended by the Django team.

I came across several issues, that I solved patiently one by one.

(disclaimer: I'm a Postgres homer)

These issues *should* come up with a well-designed database.
1) Creating tables under postgresql requires to login as a different 
OS login, from which you don't even know the password.  Fine, I found 
the solution and created the database.

I'm guessing you are not there yet.

If using a system-supplied Postgres installation, there is likely a 
pre-defined Postgres user. Some installations set this up as a nologin 
account. But you can "su postgres" to have the right permissions to 
start creating users (or roles) in the database.


You should define a user other than the postgres user to own the 
database for your Django installation. Use the "createuser" command as 
the postgres user, and make your first one the admin user for your 
databases (give it the superuser permissions; createuser will ask you 
about that). From then on you can use that account to interact with your 
database, including creating tables and other users as needed.


Another way to do this is to create a separate installation. For the 
server you just need to define PGDATA to point to your new data area 
(with proper permissions; 700 for the top-level) and PGPORT as another 
port number to avoid colliding with your default installation. For 
clients you just need PGPORT and (possibly) PGHOST, but of course you 
can also specify those in settings.py.


If you are using postgres, spend a few minutes to get familiar with the 
docs. They are quite complete and should be your friend.


2) After running syncdb, you can't simply execute a simple insert sql 
like this:


INSERT INTO App_contacttype (contact_type, company_id) VALUES 
('Buyer', 1),('Seller', 1);
Who is using caps for "App_contacttype" in the first place? If you are 
coming from MySQL then you should use the conversion program for that 
(it used to be packaged with Postgres and probably still is).
Since Django creates it with quotes the table becomes case sensitive, 
hence it has to be like this:


INSERT INTO "App_contacttype" (contact_type, company_id) VALUES 
('Buyer', 1),('Seller', 1);
The SQL standard does not support mixed-case table or field names 
without using quotes. That might be a reason to stay away from 
mixed-case app names; thanks for discovering that for me ;)
But the problems seem never to end. Now suddenly the execution of the 
insert script says


ERROR: value too long for type character varying(40)
SQL state: 22001

In MySQL this was no problem. I don't know, right now I am getting a 
bit of cold feet, maybe I should just stick to MySQL.
Uh, if you have fields too long for the maximum length you defined 
wouldn't you want to fix that? Either define the schema with a longer 
field or switch to a text type.
The only reason I was considering postgresql was that some research 
suggested postgresql has much better support for changing Schemas 
along the way than MySQL.
There are (many) other reasons to consider postgresql. Don't give up; 
there are just a few new things to pick up and you'll be using an 
industrial-strength standards-compliant database which will scale as 
well as any and better than most.


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.



Re: ForeignKey problem

2012-07-06 Thread Thomas Lockhart

On 12-07-06 10:14 AM, Soviet wrote:
Thanks, but damn, isn't that overly complicated (for me). Using 
through looks like a easier way, but then I have to add Wheel four 
times and can't just type '4' in some field, since I don't need it to 
exist in database four time, just an information that there are four 
wheels.
This is Legos. At some point you will only have 3 wheels because the dog 
ate the fourth one...


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



Re: Hello!

2012-07-14 Thread Thomas Lockhart

On 7/14/12 12:04 PM, Shubz wrote:
Hi! I'm new to Python and Django. I feel like I'm jumping in deep end, 
but I have previous PHP and Java knowledge so what the hey.


I was wondering if anybody could be kind enough to point me in the 
right direction to a broken down tut on installation for Mac?


I use MacPorts to get python, postgres, and virtualenv. Everything else 
is covered nicely in the Django tutorial.


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.



Re: Query Distance from User

2012-07-15 Thread Thomas Lockhart

On 7/15/12 4:41 PM, JJ Zolper wrote:
Yeah I'm trying to get GeoDjango set up as we speak. GeoDjango sounds 
awesome.

I have postgresql and Im trying to install postgis but im getting this:
FIx your errors in the configure step before bothering to try building. 
In this case you need libxml2 installed; should be available in your 
distro (as is Postgres). If you are using the distro Postgres then you 
will probably want to install postgis as root.


hth

   - Tom



jjz@jjz-Laptop:~$ wget 
http://postgis.refractions.net/download/postgis-1.5.2.tar.gz
--2012-07-15 19:40:12-- 
 http://postgis.refractions.net/download/postgis-1.5.2.tar.gz
Resolving postgis.refractions.net (postgis.refractions.net)... 
199.103.56.11
Connecting to postgis.refractions.net 
(postgis.refractions.net)|199.103.56.11|:80... connected.

HTTP request sent, awaiting response... 200 OK
Length: 3749293 (3.6M) [application/x-gzip]
Saving to: `postgis-1.5.2.tar.gz'

100%[==>] 3,749,293345K/s   in 
7.1s


2012-07-15 19:40:20 (516 KB/s) - `postgis-1.5.2.tar.gz' saved 
[3749293/3749293]


jjz@jjz-Laptop:~$ tar xzf postgis-1.5.2.tar.gz
jjz@jjz-Laptop:~$ cd postgis-1.52
bash: cd: postgis-1.52: No such file or directory
jjz@jjz-Laptop:~$ cd postgis-1.5.2
jjz@jjz-Laptop:~/postgis-1.5.2$ ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared 
libraries... yes

checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking whether we are using the GNU C++ compiler... (cached) no
checking whether g++ accepts -g... (cached) no
checking if gcc supports -Wall... yes
checking if gcc supports -Wmissing-prototypes... yes
checking if gcc supports -ffloat-store... yes
checking for flex... no
checking for lex... no
checking for bison... no
checking for byacc... no
checking ieee

Re: Newbie -- issue with psycoppg2

2012-07-21 Thread Thomas Lockhart

On 12-07-21 3:57 AM, Quincy Kwende wrote:

create a database using PostgreSQL

Try googling "create a database using PostgreSQL"

The first hit is the chapter you want in the Postgres docs.

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.



Re: how to make template for startapp and startproyect?

2012-07-24 Thread Thomas Lockhart

On 7/24/12 11:24 AM, kase wrote:
hello..  i wish make my templates  for  django-admin.py  startproyect 
and startapp  but i dont know how, and i dont find documentation to 
explain how to make it (i find documentation from how to use, but not 
how to make)
There may be a better way suggested by others, but you can use the 
examples from the tutorial as your starting point.


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.



Re: No timezone support for TimeField?

2012-07-31 Thread Thomas Lockhart

On 7/31/12 1:34 PM, Tejinder Singh wrote:
Django 1.4 does not store aware times for TimeField, it only does for 
DateTimeField. Its really annoying, as python datetime.time object 
does support TZINFO just like datetime.datetime objects. I wonder if 
it is a bug? Btw i have tested it on postgres 9.1 database server
Time zones have no meaning without a date attached, so having a time 
zone travel with a time of day does not lead to something useful. fwiw I 
implemented the Postgres date/time types back in the day...


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



Re: PostGIS 2.0.0 problems

2012-08-03 Thread Thomas Lockhart

On 8/3/12 3:39 PM, Oleg Korsak wrote:

looks like GeoDjango is dead, it is not solved for almost half of the year
Really? What is the use case requiring a version 2.0.0? Seems that the 
previous 1.x version works as advertised.


And typically folks don't jump on a x.0.0 of anything, expecting to see 
it settle down after release with some minor fixes and additional 
releases. That may be the case with the GeoDjango folks though I don't 
know for sure.


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.



Re: Do I understand the support schedule correctly?

2012-08-06 Thread Thomas Lockhart

I'd be interested in hearing  other opinions about this. Out there in

> the "real world" (™), how long does Long Term Support have to be in
> order to be practically useful?

Two years to be able to stick with a single version? Just fine imho.

A few points you have probably heard before:

Django is just one layer of the stack. Extending support because other 
layers don't have a critical mass or a release cycle to provide new 
versions may not be a problem that Django should be expected to solve.


Growing the number of supported versions competes with evolving and 
keeping fresh. And evolution is critical for attracting and keeping 
contributing developers; LTS is not the interesting place to be in the 
long run.


Diverting (free) developer resources to keeping "large organizations" 
happy may be at odds with the benefits and tradeoffs of an open source 
project. If large organizations want to pony up developers or money then 
I'll bet they can keep an LTS release going indefinitely so there isn't 
really a conflict there. In my experience those organizations will 
provide those resources if they feel the added value is important to them.


If independent or contract developers are hoping to use Django to 
deliver software to other organizations then the support cycle needs to 
match the customers' needs. But that is between the developer and the 
customer to work out the best set of tools for the job.


If an organization won't consider a tool stack because it does not have 
an LTS plan matching their requirements, then I know of at least one 
organization which should not use that tool stack. They are making the 
tradeoffs, and can choose the best solution for their needs.


But in my experience, when someone locks onto a version for a 
substantial period of time, they will end up orphaning the product or 
they have (perhaps unwittingly) deferred the modest pain in keeping 
fresh on versions to feeling a large amount of pain later on when they 
upgrade. I prefer the pain to arrive in smaller doses.


Thanks for asking ;)

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



Re: Right approach to create simple CRM

2012-09-02 Thread Thomas Lockhart

...

3. Get opensource CRM and configure for your needs.
4'. ... and add plugins if needed.

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.



Re: Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread Thomas Lockhart

On 9/5/12 6:00 AM, Mattias Linnap wrote:

I've found two solutions: setting "editable=False" in the model's
field definition (which removes the field completely from admin), or
adding it to readonly_fields list in the ModelAdmin (which keeps the
data visible).

Perhaps it will be possible to subclass ModelAdmin, and make all
editable=False fields show up as readonly: after all, their data is
still interesting to look at, just should not be editable.

Looking at millions of read-only entries should lead to hours of 
enjoyment ;)


What good is that volume of data displayed to a user or admin? How about 
showing a rollup of the number of values and then allowing a 
click-through to a detailed display if necessary?


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



Re: newbie: which settings file? ["settings.DATABASES is improperly configured. "]

2012-09-10 Thread Thomas Lockhart

On 9/10/12 11:30 AM, Bob Aalsma wrote:


I'm in Chapter 5 of the tutorial, configuring the database.
I think I've done everything correct to set the DATABASE_ENGINE = 
'sqlite3'.

Then I check the settings and see an error:
ImproperlyConfigured: settings.DATABASES is improperly configured. 
Please supply the ENGINE value. Check settings documentation for more 
details.



You are mixing an older tutorial with a newer version of Django.

Find instructions which describe setting "ENGINE" in the "DATABASES" 
structure. You see that the error message mentions "DATABASES" and 
"ENGINES", not "DATABASE_ENGINE" which is the clue here.


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.



Re: Django newbie with issues

2012-09-11 Thread Thomas Lockhart

On 9/11/12 6:29 AM, Morrti wrote:

Hi,

We did try things with v1.5, but that also failed. Looking further it 
seems that my branch on git was wrong.
Moving to the correct one for 1.1 has seemed to have corrected things, 
well we got past that issue.

I'm going to continue with the tutorial now and see how that goes.
Please take the advice and use 1.4.1. And on the Mac I strongly 
recommend using virtualenv; it is hard to keep things straight otherwise.


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.



Re: Django and LDAP

2012-09-11 Thread Thomas Lockhart

On 9/11/12 2:49 PM, Ivan Pavlović wrote:
Thank you Mike for your answer. I started this topic, because i have 
an assignment at my Faculty, which requires connection between Django 
and an LDAP (assistant insisted on 389ds). I installed Django, enabled 
admin, logged in through Firefox. I can't make up my mind, do i need 
to connect Django and LDAP like so that all users from LDAP can login 
through e.g. localhost:8000/admin, or do i need to make a 
register/login page, where users from LDAP server can login and onlu 
admin can login from admin page? The second is mpre logical to me, but 
i don't know, because i am new to Django and Python.
I believe that you will write a (small) middleware function which will 
be added to the tuple PASSWORD_HASHERS in your settings.py. The 
middleware will take the username and password already provided by the 
user from an existing login page and then access your LDAP server for 
the authentication.


You can probably find example code for that middleware function in 
Django; I needed to use existing Drupal (ugh) passwords for a content 
conversion to Mezzanine and found an example, probably on django-snippets.


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.



Re: not picking up new template

2012-09-12 Thread Thomas Lockhart

On 9/12/12 8:27 AM, Larry Martell wrote:

On my Mac, I changed a template, and the change was picked up, no
problem. I checked my change into git, went to another machine, a
CentOS box, pulled the change down, but django is not picking it up.
I've tried everything I can think of - bounced the server, restarted
the browser, cleared the cache and cookies, tried 3 different
browsers, deleted it, re-pulled from git, but when I look at the code
in the debugger, it's clearly using the old template. There are no
errors in the apache log, permissions are fine, I'm tearing my hair
out here. Anyone have any ideas as to what's preventing it from
picking up the new template, or what I can check to figure out what's
going on?


Need to collect static content for your production server?

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



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

2012-09-13 Thread Thomas Lockhart

On 9/13/12 10:37 AM, Bob Aalsma wrote:
Hmm, I'd seen this solution in 
http://keeyai.com/2012/02/17/django-deployment-create-superuser-fails-with-locale-error/ 
but was reluctant to use this as " I have no idea if this causes any 
negative side effects."

A running system is not usually considered a negative side effect ;)

Everything will fail without this mod afaik.


So that is the official repair?
Mac OS does not set the default language environment in a way that 
python (at least) recognizes. This is true for python installations done 
from MacPorts so I think it is independent of the installation 
technique. You will need to do this (slight) mod to manage.py to have 
things work.


Since you are on Mac OS X, I *strongly* recommend using virtualenv to do 
your basic installation of packages. Once you get a mix of python libs 
which may install under the original python installation, or may install 
under the MacPorts installation area, or may install somewhere else, you 
will slowly go nuts trying to keep it straight.


virtualenv gets you a consistent development and runtime environment and 
is very repeatable.


I'm not remembering when in the process you will find failures if you 
are missing that mod to manage.py; I have not tracked down your links to 
other places. Do you want to post the exact error you are seeing?


hth

   - Tom


OK.
Thanks!

Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:


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]

Regards,
Bob

--
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/-/LbEFlfhWbVoJ.

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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-14 Thread Thomas Lockhart

On 9/14/12 3:47 AM, Bob Aalsma wrote:

SOLVED by Tom Evans:
insert
unset LC_CTYPE ; export LANG="nl_NL.UTF-8"
into .bash_profile
That is a solution, but depends on who is running and whether it is a 
login shell.


I strongly recommend adding the lines I mentioned earlier to the top of 
your manage.py so your Django installation will run properly under other 
accounts and startup environments. I'm not sure why you had trouble 
doing that or what your symptoms were.


hth

 - Tom





Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:


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]

Regards,
Bob

--
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/-/Lb8favCcs-YJ.

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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-14 Thread Thomas Lockhart

On 9/14/12 10:07 AM, Bob Aalsma wrote:
Well, I have tried your suggestion in all places I could think of and 
none of those helped: the createsuperuser kept returning the same 
error message. I posted this as a reply some 24 hours ago.
Yes, with no details of what "all the places I could think of" means. 
They are two lines, and placed near the top should have worked for you.


I'll send you my manage.py directly.

 - Tom






Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:


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]

Regards,
Bob

--
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/-/WnCSyDEH9WYJ.

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: My "Contributors" page Conundrum

2012-09-20 Thread Thomas Lockhart

On 9/20/12 5:28 PM, JJ Zolper wrote:

Anyone have any ideas?

Yes, Melvyn did.

hth

  - Tom



Thanks!

JJ Zolper

On Tuesday, August 28, 2012 2:24:03 AM UTC-4, Melvyn Sopacua wrote:

On 28-8-2012 6:58, JJ Zolper wrote:

> My problem is that I want each contributor to have their own
separate page.
> So if the first guys name for some example is Mike Smith then if
you were
> to click his name for example you would be sent to
> /about/contributor/mikesmith and so on.


>

and make sure you read the permalink bit.
-- 
Melvyn Sopacua


--
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/-/uFK1RTmzm5MJ.

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: Incorrect Python Version Being Used

2012-11-06 Thread Thomas Lockhart

On 11/6/12 7:09 AM, Bestrafung wrote:
I have been running into this problem for a long while trying to setup 
my first Django project and I keep coming back to this problem. I am 
relatively new when it come to Linux, I'm learning but still have a 
long way to go. I am using CentOS 5.8 cPanel which comes with Python 
2.4. Following instructions I found online for setting up Django with 
cPanel I compiled/installed Python 2.7 from source to /opt/python2.7 
and set an alias (alias python="/opt/python2.7/bin/python") in the 
root and user's .bash_profile and python 2.7 launches as expected when 
you use the python command. Every time I try to start a project or 
work with it however the system default python 2.4 keeps popping up. I 
think this may be the single cause of all of my issues. When starting 
a project I have just appended the python command to make sure it 
started with the correct version. I believe that once the project is 
started it isn't working because everything is still trying to use 
2.4. Is there a way to make Django use my 2.7 install instead of 2.4 
without breaking the system by making the 2.7 system default?

Use virtualenv. Always.

- Tom

--
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/-/WqpZIEJqalcJ.

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: need help with postgres installation and set-up for doing tutorials

2012-11-21 Thread Thomas Lockhart

*On 11/21/12 5:58 AM, Luisa Beck wrote:**
*

*Thank you for your thoughts! I have a few follow-up questions: *
*
*
*The reason that I’m trying to figure out postgres is that I’m helping 
some folks with a development project and they’re using postgres. I’m 
trying to do the tutorial with that so that I can get familiar with 
postgres and the pgAdmin III interface. And also with how Django, 
Python and Postgres work together (your explanation has been very 
helpful with that).


Regarding your explanations:

I have a bash “Terminal” and an SQL Shell. I also have virtual 
environments in a folder ~/Sites/django_test (i.e. when I tell the 
bash Terminal to “activate” this folder, it puts me in a an (env)).
However ,when I run “python manage.py runserver" at the bash Terminal 
command line, I get an error message saying “can't open file 
'manage.py': [Errno 2] No such file or directory”.
Even when I run the command in the (env), I get the error message: 
/Library/Frameworks/Python.framework/Versions/3.2/Resources/Python.app/Contents/MacOS/Python: 
can't open file 'manage.py': [Errno 2] No such file or directory(Which 
I presume is telling me that the path is still set on an incorrect 
version of Python (3.2), even though I want to use version 2.7 and 
trashed the 3.2 version from my system. )

*
*It sounds like you have a damaged virtual environment. They are easy to 
build so just create a new one.**

**
**For the Mac I'm using MacPorts to get packages, and virtualenv to 
build my python environment. I highly recommend both. MacPorts puts 
packages underneath /opt/local so you can figure out where something is 
located (the Apple packages are harder to track down imo). Install 
py27-virtualenv and py27-pip from MacPorts and that should get you the 
basics, including python 2.7. Make sure that /opt/local/bin is in your 
path. Create your virtualenv using "virtualenv-2.7". Use pip to grab 
python packages once you have your basic virtualenv created and activated.**

*


I think that there are a few gaps in my understanding here:

  * I don’t understand the difference between typing in commands into
my bash Terminal versus my SQL shell

*"SQL shell" is pgAdmin? In any case, they are just two different 
environments, where for the latter case you are talking directly to your 
database server.**

*


  * Is running “python manage.py runserver” the same as running Python
programs with an IDE like IDLE?

*Probably not, but in any case follow the tutorial using your terminal 
windows.**

*


  * How and where do I adjust your $PATH environment variable so that
the correct python occurs first on the path?

*Your ~/.bashrc file is the place to put in path changes appropriate for 
all of your work. Adjust the path e**lsewhere if you only want the path 
changed sometimes.**


hth

 - Tom
*


  * I think that I installed the correct Python version into the
virtual environment using pip install. Why am I still receiving a
“No such file or directory” error?
  * Why does Python version 3.2 still appear in the path indicated by
my error message is I trashed it?


If you could help me with these questions, or simply list links with 
any tutorials that explain this, that would be much appreciated. Or 
perhaps you know how I can access ‘freenode’ so that I can ask in the 
discussion forum? Thanks!


Also, I'm having trouble entering freenode because it says
that "#Django Cannot join channel (+r) - you need to be
identified with services"

And lastly, if someone could forward me a tutorial about how
the databases, python files,
virtual environments and Django work together (I am new to all
of these) that would be much appreciated!

Thanks in advance!
Luisa


I'm no Mac expert, but I'll offer a couple of thoughts.

First, you shouldn't need to solve both the PostgreSQL
installation issue and learning Django at the same time. sqlite3
is adequate to the tutorial, and is built in to modern pythons
(e.g.; 2.7), and I presume that's true on the Mac as well.

Django is written in Python, which requires no pre-compilation,
but must be run with a python interpreter, e.g.; "python manage.py
runserver" at the command line.  The tutorial is written with the
assumption that you will be running it from the command line.  If
you have more than one python installed on your system, you can
specify which one to use by including the path on the command
line, such as "~/bin/python manage.py runserver", or you can
adjust your $PATH environment variable so that the correct python
occurs first on the path.  This last is what virtualenv does: the
activate code (which you must "source", not run, e.g.; "source
~/venvs/djtutorial/bin/activate") adjusts the PATH (and prompt) of
the shell that sources it so that the virtualenv's python is found
first*, and defines a "d

Re: Model method versus overriding save()

2012-12-08 Thread Thomas Lockhart

On 12/8/12 5:37 AM, Derek wrote:
Rather than use a trigger (which is DB-specific and also hard to debug 
because not part of your code base), suggest you use signals[1].
Hmm. Triggers have advantages over application-level code where they can 
be used. They are likely more efficient (no data needs to be transferred 
to the client) and are more likely to ensure data integrity (by 
operating within a database transaction in an atomic fashion, and 
without application-level edge case failures). For cases like this one, 
debugging should be pretty easy because one can add or increment values 
in a table and watch the trigger do the additional work.


That's not to say that signals aren't a great feature, just that compact 
trigger code can have advantages and, well, that code is part of the 
code base too.


  - Tom



Derek

[1] https://docs.djangoproject.com/en/dev/topics/signals/

On Saturday, 8 December 2012 04:27:50 UTC+2, Chris Cogdon wrote:

It's a simple performance vs storage question.

Storing a calculatable field also risks it getting out of sync
with reality, but if you're doing the query on that _so_ much,
then its usualyl worth it.

Also, with the right database and a trigger, that's something the
database can ensure for you. Ie, a field that the database updates
for you.


On Friday, December 7, 2012 5:54:37 PM UTC-8, Victor Hooi wrote:

Hi,

I have a "ranking" field for an item that returns an integer
between 1 to 10 based on a number of criteria of each item.

My question is - what are the pros and cons of using a model
method to return this, versus overriding the save() method and
saving it directly into a normal IntegerField on that item?

I understand that model methods *won't* let me use them within
QuerySet filters on that item - is there any way around that?

If I just override the model's save() method to get it
recalculate and save that field each time, I can use it within
QuerySet filters. Any cons with that approach?

What do you guys tend to use in your projects?

Cheers,
Victor

--
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/-/G7fp5OLkapgJ.

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: RSS combinator

2013-03-07 Thread Thomas Lockhart

On 3/7/13 7:24 PM, Lachlan Musicman wrote:

Hola,

>
> Does anyone know of a django app that would take a number of rss
> feeds and turn it into a single blog feed/stream?

I'm using feedjack and I think it has features to amalgamate the feeds; 
I use it to subscribe to feeds then choose sets of feeds to display locally.


  - Tom

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




Re: Getting Started with Mac OS X

2013-07-14 Thread Thomas Lockhart

On 7/14/13 1:26 PM, Mando wrote:

Hi,

This is the way I have it set up my osx


$ sudo pip install virtualenv
$ virtualenv --distribute pytho_projects
$ source python_projects/bin/activate
$ (python projects) pip install django
$ django-admin.py startproject myblog

and that should get you past that. using virtualenv just makes it a 
lot more clean and organized imo. Let me know if that helped you out some.


+1 on that. pip is the only way to go.

And I would suggest installing PostgreSQL from MacPorts or an equivalent 
package manager to give yourself more control over your database 
versioning and contents. Otherwise you are relying on whatever is in 
Apple's current update which may change or be different from what you 
might need for reasons of your own.


I've also installed python and related packages from MacPorts so then 
the virtualenv will point to that installation when it initializes. That 
also gives you more control over versioning.


hth

   - Tom






On Saturday, July 13, 2013 2:25:06 PM UTC-5, Kayode Alayode wrote:

Yea I think they wanted you to add this "*django-admin.py
startproject mysite*"  at the cd commandpromopt I am stuck here as
well and don't really know how to proceed as well.


On Monday, February 27, 2012 7:36:21 PM UTC-5, JChlipala wrote:

Hello,

I am a Django beginner, and am trying to get Django set up in
Mac OS
X.  I am going through the tutorial, but getting stuck very early
(essentially at the beginning).  I have installed Python and
Django.
The next instruction is to enter the command "django-admin.py
startproject mysite".  When I do this, I get the following error:

File "", line 1
django-admin.py startproject mysite
^

SyntaxError:  invalid syntax

Does anybody know why I am getting this error?  The tutorial
has a
note for Mac OS X users explaining what to do if you get a
"permission
denied" error, but that is obviously not what is happening to me.

Thank you for any help!

--
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: Django installation on vanilla Mac OSX 10.8.2 mountain lion

2013-08-02 Thread Thomas Lockhart

On 8/2/13 7:41 AM, Sithembewena Lloyd Dube wrote:

Hi everyone,

I just began using a new Mac at work (running OSX 10.8.2 Mountain 
Lion) and it seems such a mission to install Django. Python 2.7.2. is 
already installed. Following the official Django installation 
instructions, I get no further than trying to get wget-> which I will 
ned to compile with a C Compiler -> which I can get by downloading 1+ 
gigs of xCode. Really?


Could somebody please point out a safe and straight-forward way to 
install Django on Mountain Lion?


For me, "safe and straight-forward" includes getting my machine set up 
as a full development environment in a reproducible way to support 
multiple projects. If the priority is *not* saving disk space (or 
minimizing download bandwidth), I would suggest the following components:


XCode (compilers etc)
MacPorts (third party apps)
PostgreSQL (from MacPorts postgresql92-server)
virtualenv (from MacPorts py27-virtualenv; this will also probably get 
you python-2.7)


You will want to set up your path to find executables in /opt/local/bin/

Use virtualenv to set up a standalone python installation, and pip to 
get the packages you need for django.


Use the postgres installation to provide more control over versioning 
and the location of your database, setting PGDATA and PGPORT environment 
variables to find your server. When developing, I run my server from the 
command line.


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: URL Mapping Confusion

2013-09-09 Thread Thomas Lockhart

On 9/9/13 3:30 PM, Chris Kavanagh wrote:
I haven't used this group in a long time, so I hope I do everything 
correctly. If I don't, I apologize in advance.


I thought I understand the way django uses URL's in the urlconf to 
match URL's, but I was wrong. Here's my question:


Here's my urlconf. . .
url(r'^all/$', 'article.views.articles'),
url(r'^get/(?P\d+)/$', 'article.views.article'),
url(r'^language/(?P[a-z\-]+)/$', 'article.views.language'),
url(r'^create/$', 'article.views.create'),)

and here's the other one in the site directory.
urlpatterns = patterns('',

(r'^articles/', include('article.urls')),
url(r'^accounts/login/$', 'mysite.views.login'),
url(r'^accounts/auth/$', 'mysite.views.auth_view'),
url(r'^accounts/logout/$', 'mysite.views.logout'),
url(r'^accounts/loggedin/$', 'mysite.views.loggedin'),
url(r'^accounts/invalid/$', 'mysite.views.invalid_login'),
url(r'^accounts/register/$', 'mysite.views.register_user'),
url(r'^accounts/register_success/$', 
'mysite.views.register_success'),)


Here's the question: If I have the URL 
"http://127.0.0.1:8000/articles/create/"; it works fine and takes me to 
the correct page. But why does it work when I have the "/article" in 
the url. According to the urlconf last entry r'^create/$', it should 
only match a url with "/create" NOT a url with "/article/create". The 
caret means "starts with" and the $ means "end with", so to get to the 
"create" page it should be a url with just "/create/" in it, right?
I'm a bit confused by your question. All of your "urlconf" paths will 
need to have "/articles" in the path to be found. Although regex does 
use "^" and "$" to denote beginning and end, you have split your pattern 
matching into two stages so they are just matching the pattern available 
in each stage.


Was your mention of "/article" above a typo and you meant "/articles"?

You might want to follow up with a description of what behavior you need 
to help folks give you a solution.


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: URL Mapping Confusion

2013-09-09 Thread Thomas Lockhart



Tom, thanks so much for the reply. . .Yes, that was a typo, it
should've been "/articles" not "/article".

 I know this is going to be a stupid question, but why do my "urlconf" 
paths need to have "/articles"

in it as you said?

There are three steps in the interpretation of the pattern.
1) If the pattern starts with "/articles", try matching within your 
"urlconf" file.
2) If the remaining portion of the url matches a pattern in the 
"urlconf" file, stop there.
3) If the remaining portion does not match in the "urlconf" file, keep 
looking farther down your main url file.


If you don't want the /articles prefix in your paths, write your 
patterns more explicitly at the top level.


It *is* pretty typical to have separate apps have distinct prefixes in 
their URL paths.


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: URL Mapping Confusion

2013-09-09 Thread Thomas Lockhart

On 9/9/13 5:40 PM, Chris Kavanagh wrote:
This is just a tutorial I'm going through Tom. I'm not trying to write 
anything, just trying to understand this part. And I apologize for 
making my question(s) confusing, I'm not exactly sure how to ask it.


Let's back up for a second. I'm not trying to match anything, I was 
telling you what I already had in my files (from the tutorial). What I 
do not understand is why the "/articles/" part of the url needs be 
included when I want to go to my  "/create/" view? In other words, why 
does the url need to be "http://127.0.0.1:8000/articles/create"; 
INSTEAD OF "http://127.0.0.1:8000/create"; ? Am I making sense, lol?


I have "url(r'^create/$', 'article.views.create')" in my urlconf, so 
why must I include "/article/" when I want to go to 
"http://127.0.0.1:8000/create";? You said "All of your "urlconf" paths 
will need to have "/articles" in the path to be found". Why? That is 
my question? I'm obviously not understanding something that I should 
already know. I get that I also have "(r'^articles/', 
include('article.urls'))" in my main urlconf. I thought this line of 
code just linked up the other urlconf in my app package and that's all 
it did.
Well, no it is not "just linked up". Since you put a pattern 
"^/articles/$" to be matched in the primary urls.py file, and since the 
next argument is "include('article.urls')", that secondary 
"article.urls" will never be seen to be matched unless you get a match 
on the leading "/articles/". Go back to my previous response and look at 
the three steps in matching a nested URL.


hth

 - Tom




I hope I made my question a little clearer, lol. I'm not sure how to 
ask what I want to know. But again, THANKS for the help Tom!




On Mon, Sep 9, 2013 at 7:48 PM, Thomas Lockhart 
mailto:tlockhart1...@gmail.com>> wrote:




Tom, thanks so much for the reply. . .Yes, that was a typo,
it should've been "/articles" not "/article".

 I know this is going to be a stupid question, but why do my
"urlconf" paths need to have "/articles"
in it as you said?

There are three steps in the interpretation of the pattern.
1) If the pattern starts with "/articles", try matching within
your "urlconf" file.
2) If the remaining portion of the url matches a pattern in the
"urlconf" file, stop there.
3) If the remaining portion does not match in the "urlconf" file,
keep looking farther down your main url file.

If you don't want the /articles prefix in your paths, write your
patterns more explicitly at the top level.

It *is* pretty typical to have separate apps have distinct
prefixes in their URL paths.

hth

  - Tom
-- 
You received this message because you are subscribed to a topic in

the Google Groups "Django users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/django-users/43W4LSOuUUw/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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.


--
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: Workflow/tools assistance

2013-09-12 Thread Thomas Lockhart

On 9/12/13 6:44 AM, Sayth Renshaw wrote:



On Thursday, September 12, 2013, Germán Larraín wrote:

Some comments:

* why use sqlalchemy if Django has its own ORM?
* you mentioned parsing SQL entries; watch out!
* if you are starting a new project, I seriously recommend you to
use PostreSQL, not MySQL/Maria DB


+1
I was just googling for methods and examples of how people do this. Of 
the very  scarce info out there Sqlalchemy was in it.

That would be a red herring.


In the django docs it has initial fixtures.

https://docs.djangoproject.com/en/1.2/howto/initial-data/#providing-initial-data-with-fixtures

But this doesn't seem to provide the functionality of loading 
recurring data via XML data thru ORM to database.


I would write a python script to stuff it in to the database directly or 
if you want others to be able to upload files to be read in then 
integrate an upload capability with some backend python code. If the 
files are large then you will want to have a separate thread do the 
work. And if the files need validation you may want to break this into 
two pieces so the file is uploaded and the file name is stashed in a 
model, then another thread or cron job can pick it up and do some 
processing, maybe keeping track of the status in the database also.


For a separate python script you may need to write some simple SQL, but 
for the django portions you would not need to touch that.


Write your models for the dataflow you need, then fill in the other 
pieces with some code.


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: How to prevent label wrap in Django Administration

2015-04-19 Thread Thomas Lockhart

On 4/19/15 4:21 AM, Bernd Wechner wrote:


I'm just playing around with Django and have cut a simple model and 
all is working fine. The Django administration tool works a charm, and 
I can move onto some views and forms. But what puzzles me immensely is 
why editing a tuple looks like this (with crazy label wrap). Can I fix 
this any way? It's not an impressive use of screen real estate:...


Maybe my answer will provoke a better one, which would be a good thing, 
but...


For non-admin pages you can tailor the labeling to whatever you want 
your users to see; for admin you might want to show that more compactly 
and efficiently.


How about making model labels which are shorter? Typically I use 
something with a dozen characters or (much) less, and then put hints 
about how to use it or other details into the help field. So "Trueskill 
Initial Standard Deviation (phi0)" might be as simple (and 
uninteresting) as "stddev" and the help might be "Enter an initial 
standard deviation".


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/5533B6D2.7040601%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: can i use sqlite for big project?

2015-06-26 Thread Thomas Lockhart

On 6/25/15 7:08 AM, Arindam sarkar wrote:
i need to develop a job portal . is there any problem if i use sqlite 
? coz i am having problem to setup mysql or postgresql . please help.
As others have suggested, use Postgres from the start. Spend a few 
minutes to understand the setup; it will be worth it.


Feel free to ask more specific questions if you continue to have trouble.

- 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/558D9BFC.6030707%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using unique_together with foreign key fields which may be None

2013-10-01 Thread Thomas Lockhart

On 10/1/13 6:36 AM, Derek wrote:
We encountered the same problem for a complex model ... we ended up 
defining "acceptable" default values that are used instead of 
None/NULL, but essentially mean the same thing to the user.  (We are 
using MySQL which adopts the same approach as Postgresql - I believe 
Oracle does it otherwise).
(Just meant for general discussion, not specific to other suggestions in 
this thread)


This would seem to be a problem that explicit constraints are meant to 
solve. One could check that the row is unique either with or without the 
foreign key, depending on whether it is specified. Postgres supports 
those very well (others may also nowadays), and if necessary one could 
use python or another language supported by the backend to implement 
complex logic.


That does not solve the validation problem at the user level, but keeps 
invalid data from leaking into the database.


hth

   - Tom



On Monday, 30 September 2013 23:17:00 UTC+2, Karen Tracey wrote:

On Mon, Sep 30, 2013 at 4:55 PM, Berndt Jung > wrote:

Because the lookup_value of a null field is None, the
validation check is aborted entirely.  This seems wrong to me,
and I'm wondering if I'm doing something wrong here.
 Redefining the models is not something I can do at this point.


None in Python corresponds to NULL in SQL. SQL defines that NULL
!= NULL. So when checking for unique values the database will not
consider two NULLs to be the same value; the NULLs will be
considered to be different and will not violate the unique
constraint. The Django code is doing the same check for uniquess
that the database will be enforcing. There is no way I know of to
make a database enforce uniqueness among NULL values...


--
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/75c02ade-18a4-4e38-a75c-f75b756f831f%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/524B3547.8000607%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: having trouble with virtualenvwrapper - need to run 'source ~/.profile' every time.

2013-10-16 Thread Thomas Lockhart

On 10/16/13 8:29 AM, Jimmy Pants wrote:
...every time I open a terminal, that is. As I understand it, .profile 
is the file to edit in Linux Mint, and it does exist, with some basic 
code in it, in my home dir. So, per this tutorial 
, I 
added the following to .profile:
Your terminal is being opened without specifying it as a "login shell". 
Not sure which terminal program you are using so you will need to check 
on options; for xterm it is the -ls option.


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/525EB29F.2070008%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django sample (without admin site)

2013-10-18 Thread Thomas Lockhart

On 10/18/13 10:04 AM, Sanjaya Vitharana wrote:

Hi,

I am newbie to django looking for a simple sample.
I'd suggest picking up a package built on top of Django. Maybe Mezzanine 
(I've enjoyed working with that). But there are several which will get 
you going quickly.


hth

   - Tom


What I need:
1.) simple template may be with 2-4 fields/text boxes with "save" button.

What it should do:
Just save the data in the text boxes to a database when i press the 
"save" button.


2.) may be another template with button "Show DB" to list all the data 
in the DB.


3.) This should NOT use django admin site which covered in the 
tutorial. (I hate that)


4.) What should cover in the sample:
just
* Template
* Form
* View
* Model
functionality work together to save and retrieve the data from 
database and display it.


4.) May be 1-2 page documentation/tutorial might help.

If someone knows please point me. (I DON"T think big books or 1 months 
reading tutorials will help me. Looking for a shorter one)


Thanks in advance.

Sanjaya Vitharana

--
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/82221f34-9467-4b8d-9e63-8fca37c172be%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/5261800A.4080306%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Python shell displays Segmentation Fault: 11 after upgrade to Mavericks OS

2013-10-24 Thread Thomas Lockhart

On 10/24/13 2:34 PM, Don Fox wrote:

...

Segmentation fault: 11



This type of thing just started after upgrade. I assume there's a 
connection.


I found a similar symptom with another application after doing piecemeal 
updates in MacPorts packages, and my problems went away with a more 
rigorous rebuild of packages.


You might try cleaning out your compiled code (if any) and your python 
compiled files (the .pyc 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5269958E.9040203%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Errors on Django Tests Tutorial 5, how to fix.

2013-12-04 Thread Thomas Lockhart

On 12/4/13 9:18 AM, Matt Schloepp wrote:
I'm running Django on Windows with PostgreSQL database. I'm in 
tutorial 5 and have copy/pasted the code after it's initial failure. 
I've been following the tutorials to this point, with only a little 
side experimentation, and everything has been working. It looks like 
it DB related since I'm not using SQLite. I'm lost. What do I need to 
add or modify to get the tests to work?
What version of Django are you running? I think an issue with starting 
up tests with PostgreSQL were fixed for 1.6 (but I haven't tried it 
myself). fwiw PostgreSQL is supported as well or better than any other 
choice, and SQLite just postpones the inevitable transition to something 
which is full-featured.


hth

   - Tom



Output:

==

ERROR: test_was_published_recently_with_future_poll
(polls.tests.PollMethodTests)

--

Traceback (most recent call last):

File "C:\python27\lib\site-packages\django\test\testcases.py",
line 178, in __call__

self._pre_setup()

File "C:\python27\lib\site-packages\django\test\testcases.py",
line 749, in _pre_setup

self._fixture_setup()

File "C:\python27\lib\site-packages\django\test\testcases.py",
line 861, in _fixture_setup

if not connections_support_transactions():

File "C:\python27\lib\site-packages\django\test\testcases.py",
line 848, in connections_support_transactions

for conn in connections.all())

File "C:\python27\lib\site-packages\django\test\testcases.py",
line 848, in 

for conn in connections.all())

File
"C:\python27\lib\site-packages\django\utils\functional.py",
line 49, in __get__

res = instance.__dict__[self.func.__name__] = self.func(instance)

File
"C:\python27\lib\site-packages\django\db\backends\__init__.py", line
664, in supports_transactions

self.connection.leave_transaction_management()

File
"C:\python27\lib\site-packages\django\db\backends\__init__.py", line
317, in leave_transaction_management

if managed == self.get_autocommit():

File
"C:\python27\lib\site-packages\django\db\backends\__init__.py", line
324, in get_autocommit

self.ensure_connection()

File
"C:\python27\lib\site-packages\django\db\backends\__init__.py", line
124, in ensure_connection

self.connect()

File "C:\python27\lib\site-packages\django\db\utils.py", line
86, in __exit__

db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)

AttributeError: 'DatabaseWrapper' object has no attribute
'Database'


--

Ran 0 tests in 0.001s


FAILED (errors=1)


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

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b0067a22-b212-4ffa-ad5d-7fab897f9ca7%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/529FAA27.509%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 Thomas Lockhart

On 12/5/13 3:55 PM, Ricardo wrote:

Hi Thomas.
Even entering rende_value = False does not. The password keeps popping 
up as text.
did not quite understand how that password1 is inserted before the 
check password2.

I could not see this problem.
You have found the limits of my knowledge. If it were me I would 
download the Mezzanine code (which solves this nicely) and borrow a few 
lines. That is what I did...


hth

   - Tom



Em quinta-feira, 5 de dezembro de 2013 17h54min44s UTC-2, Ricardo 
escreveu:


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

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/85425291-ba1d-4946-8f2c-2d91f532d1f5%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/52A114AA.7000507%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Installing Django

2013-12-12 Thread Thomas Lockhart

On 12/12/13 1:55 PM, Frederick Miller wrote:
For Windows XP, should Django be installed under the Python27 folder?  
Or should Django be on the root of the C: drive?


I have no experience with Windows installations, but for other platforms 
virtualenv and pip are a real help for getting repeatable, consistent 
installations with a minimum of effort. I believe that is the case for 
Windows boxes too.


If you use virtualenv, then you will have a complete python and django 
installation in a location of your choosing, independent of the system 
installation areas.


hth

 - Tom


Frederick Miller
--
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/303094d2-2a45-4c56-bcf8-4884e97be365%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/52AA33D3.2060409%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: NameError "SignUpAdmin"

2014-01-02 Thread Thomas Lockhart

On 1/2/14 7:02 PM, Eddie29 wrote:

Hi Guys,
I am really new to Django and Python. I have recently started learning 
them from a course on Udemy and I got stuck on the first example, 
making a web app. I'm not sure what I have done wrong but when I run 
my Django server it comes up with a NameError. I think the app is 
supposed to handle user data, such as first name,last name and email.
I'm not familiar with the course, and haven't tried to set up your 
project to test.


But I can recommend that you start with the Django tutorial in the 
Django docs (whichever doc version matches the version of Django you are 
using). You might then find it easier to spot small problems in other 
projects such as when you go back to your course.


hth

   - Tom


Thanks in advance :)


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

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/468b9c2b-5ff6-412a-bc4f-e3c26aa3ddaf%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/52C63201.6040207%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Decompression Failed

2014-01-29 Thread Thomas Lockhart

On 1/29/14 2:23 PM, James Kinsley wrote:
I have just downloaded Python 2.7.6 on my Mac (running OSX 10.7.5 and 
I tried to download Django, but it keeps failing to decompress - any 
ideas ? Thanks.
You may have already seen mention of virtualenv and pip wrt Django 
development. I think there is a general consensus (among those who use 
it anyway!) that it is essential for development (and I would recommend 
it for deployment also).


Previous threads have described the advantages, but particularly for 
Macs -- with their deep and otherwise non-standard and inscrutable 
places to stash libraries and versions of tools -- the advantages of 
using virtualenv and pip should not be ignored.


That said, I've *never* had an issue installing Django on my Mac (Lion 
and MtnLion) using those tools. I also use MacPorts to give me control 
over versioning for the base python, postgres, etc.


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/52E99EFC.9080909%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: windows perl (3.3) stops printing output to console

2014-02-09 Thread Thomas Lockhart

On 2/9/14 1:13 AM, Mike wrote:
I am working through the Django tutorial.  Python was working.  Python 
directory is still in my PATH.  I made it through part 2 up until I 
tried to add the TEMPLATE_DIRS statement into mysite\settings.py.  I 
don't know where the source of Django is so in the command prompt I 
began typing:


I'm guessing that you are still in the python interpreter. Try typing 
"quit()" and see if you can exit back to the console.


  - Tom


python -c"
import sys
sys.path = sys.path[1:]
import django
print(django.__path__)"

Of course, hitting enter after the, python -c " part didn't work so well and I 
laughed at myself for a second.
But after that, invoking python from the command propmt does not produce errors 
or results. The interpreter does not load this way anymore, it just dumps me 
back at the propmt without feedback.
Since .py files are associated to python, I tried running a couple scripts by 
name alone.  That works fine.  What happened to my interpreter?

Thank you,
Mike

--
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/2840eb0e-4e1e-4841-b8b6-3938de7d1ab0%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/52F7F21D.8010001%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Terrible performance when dropping into raw SQL Oracle

2014-02-26 Thread Thomas Lockhart

On 2/26/14 2:41 PM, Shawn H wrote:
Because this worked so well, I've gone directly to cx_Oracle in my 
django view and used that to get the result in the 4 seconds.  There 
is definitely a problem with the Django implementation - I wonder if 
perhaps the indexes on the tables aren't being used properly.

That would seem unlikely since you are specifying the query directly.

If you suspect that Django *is* modifying your query, can you look at 
the query as it arrives to the Oracle backend and compare the two test 
cases?


hth

- Tom


On Wednesday, February 26, 2014 3:49:47 PM UTC-6, Shawn H wrote:

3.8 seconds.  It seems to be django, not cx_Oracle.

On Wednesday, February 26, 2014 2:50:58 PM UTC-6, Shawn H wrote:

Good idea.  I'll try that and report back

On Wednesday, February 26, 2014 1:22:52 PM UTC-6, Tom Evans
wrote:

On Wed, Feb 26, 2014 at 6:16 PM, Shawn H
 wrote:
> Yes.  I've tested with several case numbers, and I'm
using a similar
> parameterized approach in my gui Oracle client as well,
with the same
> results.  It's always about 3 to 4 times slower running
via django.  I've
> tried it both on my local development web server as well
as my production
> apache linux box, and it always takes much longer
running via django.
>
>

If you write a standard python program, ie not using
django, but still
using whatever oracle DB adapter Django uses, that
connects to your
oracle server and executes the query, is it still slow?

IE is the problem something django does, or how the
adapter works.

Cheers

Tom

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

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c4ff4ee0-43b8-4d1f-9ef0-6ef93546dcad%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/530E7179.4000306%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Bus Error on Development Server

2014-02-28 Thread Thomas Lockhart

On 2/28/14 6:16 PM, Gkpetrak wrote:

Hello,

I was trying to process Images with some python scripts, when I 
receive bus error. After that I had many bus errors on different programs.
Finally I tried to start django' development server, and I received 
the same error.
The "after that I had many bus errors on different programs" is the clue 
that perhaps your physical memory has a bad spot.


Your image processing might have used more physical memory than your 
typical computer load uses, and ended up in a bad part of memory.


I would recommend running an intensive memory test (e.g. memtest86+) to 
isolate which memory chip is at fault, and either yank it or replace it.


hth

- Tom


I know that this error happens when a process is trying to access memory
that the CPU cannot physically address.

I checked my log files and the output of the error is the following:

T02:13:26.879355+02:00 suse-pc kernel: [ 9976.488797] ata1.00: exception Emask 
0x0 SAct 0x1 SErr 0x0 action 0x0

2014-03-01T02:13:26.879402+02:00 suse-pc kernel: [ 9976.488806] ata1.00: 
irq_stat 0x4008

2014-03-01T02:13:26.879413+02:00 suse-pc kernel: [ 9976.488813] ata1.00: failed 
command: READ FPDMA QUEUED

2014-03-01T02:13:26.879419+02:00 suse-pc kernel: [
9976.488826] ata1.00: cmd 60/08:00:50:8d:75/00:00:39:00:00/40 tag 0 ncq
4096 in

2014-03-01T02:13:26.879428+02:00 suse-pc kernel: [
9976.488826]  res 41/40:08:51:8d:75/00:00:39:00:00/00 Emask
0x409 (mediaerror) 
2014-03-01T02:13:26.879434+02:00 suse-pc kernel: [ 9976.488832] ata1.00: 
status: { DRDY ERR }

2014-03-01T02:13:26.879437+02:00 suse-pc kernel: [ 9976.488836] ata1.00:error: 
{ UNC }

2014-03-01T02:13:26.948294+02:00 suse-pc kernel: [ 9976.557999] ata1.00: 
configured for UDMA/133

2014-03-01T02:13:26.948313+02:00 suse-pc kernel: [ 9976.558034] sd 0:0:0:0: 
[sda] Unhandled sense code

2014-03-01T02:13:26.948315+02:00 suse-pc kernel: [ 9976.558040] sd 0:0:0:0: 
[sda]

2014-03-01T02:13:26.948316+02:00 suse-pc kernel: [ 9976.558044] Result: 
hostbyte=DID_OK driverbyte=DRIVER_SENSE

2014-03-01T02:13:26.948317+02:00 suse-pc kernel: [ 9976.558048] sd 0:0:0:0: 
[sda]

2014-03-01T02:13:26.948318+02:00 suse-pc kernel: [ 9976.558052] Sense Key : 
MediumError  [current] [descriptor]

2014-03-01T02:13:26.948320+02:00 suse-pc kernel: [ 9976.558059] Descriptor 
sense data with sense descriptors (in hex):

2014-03-01T02:13:26.948321+02:00 suse-pc kernel: [ 9976.558062] 72 03 
11 04 00 00 00 0c 00 0a 80 00 00 00 00 00

2014-03-01T02:13:26.948321+02:00 suse-pc kernel: [ 9976.558081] 39 75 
8d 51

2014-03-01T02:13:26.948335+02:00 suse-pc kernel: [ 9976.558090] sd 0:0:0:0: 
[sda]

2014-03-01T02:13:26.948338+02:00 suse-pc kernel: [ 9976.558095] Add. Sense: 
Unrecovered readerror  - auto reallocate failed

2014-03-01T02:13:26.948339+02:00 suse-pc kernel: [ 9976.558099] sd 0:0:0:0: 
[sda] CDB:

2014-03-01T02:13:26.948340+02:00 suse-pc kernel: [ 9976.558102] Read(10): 28 00 
39 75 8d 50 00 00 08 00

2014-03-01T02:13:26.948341+02:00 suse-pc kernel: [ 9976.558119] end_request: 
I/Oerror, dev sda, sector 964005201

2014-03-01T02:13:26.948342+02:00 suse-pc kernel: [ 9976.558207] ata1: EH 
complete



Any ideas ?

How can I fix it ?

Regards,
George

--
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/33d3ed3a-fd7a-49a4-a897-b0a80ee7c77e%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/53114E0B.2090606%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: populating my postgres with openpyxl

2014-03-27 Thread Thomas Lockhart


I keep getting this error, saying that there is 0207.xlsx is not there, 
but it is in the directory.


File "hsdata.py", line 34, in 
wb = load_workbook(filename = fname, use_iterators=True)
  File 
"/home/william/.virtualenvs/hsdata/local/lib/python2.7/site-packages/openpyxl/reader/excel.py", 
line 125, in load_workbook

raise InvalidFileException(unicode(e))
openpyxl.shared.exc.InvalidFileException: [Errno 2] No such file or 
directory: '0207.xlsx'



It looks like os.walk() needs you to add the starting point (BASEDIR) to 
the resulting file name.


Something like

... load_workbook(filename = os.path.join(BASEDIR, fname),...)

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/53349DA3.4050309%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Union in Django queryset

2014-04-17 Thread Thomas Lockhart

On 4/16/14 11:51 PM, Shoaib Ijaz wrote:

I don't want use SQL query in django

OK. You *could* have class B inherit from class A:

class B(A):
  link = models.IntegerField(blank=True, null=True)

and then do your query on A:

ulist = A.objects.all()

hth

- Tom



On Thursday, 17 April 2014 04:39:09 UTC+5, Russell Keith-Magee wrote:

On Wed, Apr 16, 2014 at 9:30 PM, Shoaib Ijaz > wrote:
> Sorry for duplicate post How to create Union
>
> I am using Django REST Framework in project and I want to create
union two
> different Models.
>
> My Models
>
> class A(models.Model):
> name = models.CharField(max_length=240, blank=True)
> geometry = models.GeometryField(blank=True, null=True)
> abwrapper= models.ForeignKey(ABWrapper)
>
> class Meta:
> db_table = 'tbl_a'
>
> class B(models.Model):
> name = models.CharField(max_length=240, blank=True)
> link = models.IntegerField(blank=True, null=True)
> geometry = models.GeometryField(blank=True, null=True)
> abwrapper= models.ForeignKey(ABWrapper)
>
> class Meta:
> db_table = 'tbl_b'
>
> I am trying to create this query
>
> SELECT id,name FROM tbl_a UNION (SELECT b.id
,b.name  From tbl_b b)
>
> My attempt for union
>
> a = A.objects.values_list('id')
> b = B.objects.values_list('id')
> queryset = a | b



--
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/534FE2D0.1080508%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Database Switching Issue

2014-07-11 Thread Thomas Lockhart

On 7/11/14 9:27 AM, G Z wrote:
So I tracked down an issue, whenever I change my database from 
development to production which have the same exact schema
it still uses the data from development although my settings.py file 
is set to the production database and it even swtiches the user I have
to log in with to the one associated with production but all of the 
data is development.


I have tried running sync db and sql. Nothing seems to work I know 
this is a django ism but not sure how to fix it .

Django only knows what you tell it.

If the production setup is really specifying the production database 
(make sure you don't have a local_settings.py overriding your 
settings.py values), perhaps you should check your caching setup next?


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/53C01104.6000702%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Database Switching Issue

2014-07-11 Thread Thomas Lockhart

On 7/11/14 11:30 AM, G Z wrote:

Thomas,

I have no cache setup, Django is all set to default right now there is 
no local_settings file I have actually changed every settings file 
that exist for django to match my production db yet still the wrong data.
Well, you will have to give more details on your setup. Which database? 
What are the database settings? Do you have NFS involved?


I would guess that if you remove your development db you will see a 
different error ;)


  - Tom



On Friday, July 11, 2014 10:30:23 AM UTC-6, Thomas wrote:

On 7/11/14 9:27 AM, G Z wrote:
> So I tracked down an issue, whenever I change my database from
> development to production which have the same exact schema
> it still uses the data from development although my settings.py
file
> is set to the production database and it even swtiches the user
I have
> to log in with to the one associated with production but all of the
> data is development.
>
> I have tried running sync db and sql. Nothing seems to work I know
> this is a django ism but not sure how to fix it .
Django only knows what you tell it.

If the production setup is really specifying the production database
(make sure you don't have a local_settings.py overriding your
settings.py values), perhaps you should check your caching setup
next?

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/66e147de-875c-46af-be8d-1e02844f9408%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/53C02ED5.3050004%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: urls not maching

2014-07-13 Thread Thomas Lockhart

On 7/13/14 7:19 AM, ngangsia akumbo wrote:
no am not using two slashes, i just want my block links to output the 
content details but i keep having the error above

i need some help here
You are getting some help here. The details you have provided so far 
seem to indicate that you are providing a URL with two slashes. You will 
need to provide more details to clarify that this is not the case.


Try cut and pasting the actual URL from your client into your next email.

hth

   - Tom



On Sunday, July 13, 2014 12:52:20 PM UTC+1, Jonathan Querubina wrote:

It seems tha you are using blog// (two slashes) on the url. Try blog/


--
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/873f6340-0192-465b-b47b-931e2b9d%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/53C2CB16.9010706%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie: Complete environment setup(virtualenv, pip, eclipse, git...)

2014-07-19 Thread Thomas Lockhart

On 7/19/14 6:41 PM, Martin Torre Castro wrote:

Hello,

my name is Martin and I'm a computer engineer from Spain. I'm going to 
start a new project with a colleague and I decided to use Django 
because we searched for free opensource tools and I'm in love with Python.


We have made a couple of tutorials (the official one and "Tango with 
django"). I've also bought the book "Two scoops of Django" for the 1.6 
Django edition. We're starting the project soon as well as we finish 
the design, but I'm concerned about setting up the new environment. 
We're thinking of using:


  * postgresql
  * Python/Django [ of course ;-) ]
  * Eclipse/Pydev
  * Git
  * jQuery


All good choices. pip and virtualenv provide for a reproducible and 
robust installation. PostgreSQL is imho far superior to other options 
for db. I don't have experience with using Eclipse in this environment 
so can't comment there.


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/53CB297D.7040808%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't save input to database

2014-12-30 Thread Thomas Lockhart

On 12/30/14 11:42 AM, Ronis wrote:
Hi guys, I can't save the input from a custom form to database. I 
don't know what I am missing.
I'm not sure either. But the html form you posted looks a *lot* like any 
template you might find in a django deployment. If it were me I'd look 
harder at just tying that in to the "usual places" and be done with it. 
That will give you form validation etc nearly for free and save the next 
person who is looking at your code from having to figure out what you 
did. Patterns and idioms save a lot of thinking best used elsewhere...


hth

- Tom



Because it's using a downloaded template from the web, I'm not using 
the django forms. Instead, I'm trying to simply save the input from 
the html form to the database. Im using the standard database when you 
create a django project. When I checked the admin the inputs are not 
saved.


Here is my code:


Views.py -> https://dpaste.de/SCBi

Models.py -> https://dpaste.de/3NX3

Admin.py -> https://dpaste.de/OWLS

htmlform -> https://dpaste.de/11DP

I'm a newbie programmer btw, this may be simple solution but I've 
spent some time and couldn't figure it 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/ca13d351-0075-4000-902d-3f8755cb775e%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/54A3043E.10401%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: migration error "geo_db_type" when using postgres as second database for geodjango

2015-09-14 Thread Thomas Lockhart

On 9/14/15 7:10 PM, Wenyao Xue wrote:

Thanks, I guess I have to wait for 1.9 to release then

在 2015年9月15日星期二 UTC+8上午12:21:58,Tim Graham写道:

This is a bug that will be fixed in Django 1.9.


https://github.com/django/django/commit/0cc059cd104cdb70340bd08e597d403d80dc42a6



The fix seems to be fairly compact. Any chance of getting it into the 
1.8.x LTS branch?


- Tom


On Monday, September 14, 2015 at 7:35:15 AM UTC-4, Wenyao Xue wrote:

I upgraded my router using allow_migrate, but it didn't solve
my problem

在 2015年9月14日星期一 UTC+8下午6:37:56,Jani Tiainen写道:

I guess you need to write a bit more:


https://docs.djangoproject.com/en/1.8/topics/db/multi-db/#allow_migrate



And sync_db is deprecated...

On 14.09.2015 13:07, Wenyao Xue wrote:

Following is my router for world app.  No router for
other two apps, since default database is used
Settings:
DATABASE_ROUTERS = ['world.routers.GisRouter']

router.py in world app:
class GisRouter(object):
"""
A router to control all database operations on models
in the
auth application.
"""
def db_for_read(self, model, **hints):
if model._meta.app_label == 'world':
return 'geodjango'
return None

def db_for_write(self, model, **hints):
"""
Attempts to write auth models go to auth_db.
"""
if model._meta.app_label == 'world':
return 'geodjango'
return None

def allow_relation(self, obj1, obj2, **hints):
"""
Allow relations if a model in the auth app is
involved.
"""
if obj1._meta.app_label == 'world' or \
   obj2._meta.app_label == 'world':
   return True
return None

def allow_syncdb(self, db, model):
"""
Make sure the auth app only appears in the 'auth_db'
database.
"""
if db == 'geodjango':
return model._meta.app_label == 'world'
elif model._meta.app_label == 'world':
return False
return None

在 2015年9月14日星期一 UTC+8下午5:40:55,Jani Tiainen写道:



On 14.09.2015 11:58, Wenyao Xue wrote:

Hi,
I use mysql as default database and postgres for
geodjango related appliction.
my settings:
DATABASE_ROUTERS = ['world.routers.GisRouter',
'rest_shop.routers.ShopRouter',
'rest_client.routers.ClientRouter']

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'fddd',
'USER': **,
'PASSWORD': **,
'HOST': SERVER_HOST,
'PORT': '3306',
},
'geodjango': {
'ENGINE':
'django.contrib.gis.db.backends.postgis',
'NAME': 'geo',
'USER': *,
'PASSWORD': ***,
'HOST': SERVER_HOST,
}
}

during migration, error raised:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm
4.5.4\helpers\pycharm\django_manage.py", line 41, in

run_module(manage_file, None, '__main__', True)
  File "C:\Python27\lib\runpy.py", line 176, in
run_module
fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 82, in
_run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
  File "D:\src\fddd_backend\manage.py", line 10, in

execute_from_command_line(sys.argv)
  File

"C:\Python27\lib\site-packages\django-1.8.4-py2.7.egg\django\core\management\__init__.py",
line 338, in execute_from_command_line
utility.execute()
   

Re: Postgis - as an afterthought?

2015-10-25 Thread Thomas Lockhart

On 10/25/15 11:20 AM, Joakim Hove wrote:

Hello, I have started developing a Django application. Currently it is not 
ready for it, but in the future I see that I would probably like to use the 
GeoDjango application/extension. Will I be able to add that a later stage, or 
do I need to design the application for that from the start?

I am using Postgres on Heroku currently.

You can add it in anytime. In older versions of Django you may need to 
do minor changes if you add geo fields to existing apps.


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/562D46EA.2050600%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where is all the time going?

2017-05-22 Thread Thomas Lockhart

On 5/22/17 10:12 PM, Bernd Wechner wrote:

James,

If you have the fortitude and kind heart to look at it, sure the code 
base (just checked in) is here:


https://github.com/bernd-wechner/CoGs

it's the Create view on the Session model that is taking 30s to 
render, no other model, and that one is the central model of interest 
with a custom form that needs related model forms as well, to wit is a 
tad complex and I'm experimenting with keeping it as generic as I can 
for reuse later (DRY), though it is highly experimental and hacked up 
as I'm learning on the fly.
In my experience long "render times" have always come from an unintended 
very long list in a menu of candidates for filling out a form. Make sure 
that the input choices are small in number!


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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6759a167-50f9-2c01-b588-a963fd9ec24b%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deprecating model field (Deleting model field, but keeping DB column)

2017-07-05 Thread Thomas Lockhart

> On Jul 4, 2017, at 8:39 PM, tay...@cedar.com wrote:
> 
> I am having some trouble figuring out the best way to remove model fields in 
> Django. If I remove a field from a model and then run makemigrations, it 
> creates a RemoveField operation in a migration. That is great, but if I 
> decide to run the migration before releasing the new code, the existing code 
> will break (for a short time between running the migration and releasing the 
> new code) because the old code is still querying for the removed column 
> (Django queries for all columns by default). I could run the migration after 
> the release, but that won't work if I also have an AddField operation because 
> the new code needs the new column, so it needs to be run before. I am 
> wondering if anyone has solved this issue?


A common practice is to do this in several upgrade steps:

1) Add new field as nullable.
2) Add code to populate and use new field, and migrate.
3) Remove code using old field.
4) Remove old field, and migrate.

With a large development team the work flow is perhaps not much different that 
managing production releases, since you may not want to have broken 
installations. It also gives needed practice at managing deployed releases for 
upgrades.

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/722E4F78-636D-4FEB-A9D5-783CA3227A9C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django timezone problem

2019-02-06 Thread Thomas Lockhart
If you want this to happen without the user registering and giving you an 
address, you could use a geolocation and ip address database. I think yahoo and 
google both provide these services (I used yahoo because their terms of service 
were less restrictive). If the user allows the browser to report a location, 
use that. Or if not then use the apparent IP address to estimate a time zone. 
Neither are fool proof and in particular a casual user to your site will likely 
be put off by the browser asking to share the location.

hth

- Tom

> On Feb 4, 2019, at 6:04 AM, Mikko Meronen  wrote:
> 
> Hi,
> 
> Thank you for your answer. I tried timezone.now without parentheses, but it 
> gave me server error. I have also tried datetime, but I face the same issue.
> 
> The issue I have:
> I want people to see what happened today in the past. So I created a database 
> where is a story or stories what happened in the history on this day(date). 
> My view should be able to pick a right story from the database based on the 
> users timezone. If Australian visits my webpage at this moment, he should be 
> able to see what happened on February 5 in the past (it's already February 5 
> there). However he sees what happened on February 4, because it is February 4 
> here (in Finland or England, not sure what timezone I'm using). So I want to 
> make my view to understand the end user's local time, so it can pick the 
> right story from the database for the webpage visitor.
> 
> -Mikko
> 
> ma 4. helmik. 2019 klo 10.15 'Amitesh Sahay' via Django users 
> (django-users@googlegroups.com ) 
> kirjoitti:
> Hello Mikko,
> 
> There are basically two ways which I know . One is the timezone module that 
> you are using another is datetime module. I believe that timezone module is 
> more effective one.
> But instead of calling timezone.now() , call timezone.now.
> 
> Or what is the exact issue are you facing?
> 
> 
> Regards,
> Amitesh Sahay
> 91-750 797 8619
> 
> 
> On Monday, 4 February, 2019, 12:30:07 AM IST, Mikko Meronen 
> mailto:mikkovillemero...@gmail.com>> wrote:
> 
> 
> Hi,
> 
> Is there any easy way in Django to catch end user's local time when end user 
> access the webpage?
> 
> I have read django documentation and tried to google solutions, but I get 
> quite confused. Below you will find my code. In short the code should show a 
> story on my webpage what happened in the past on the current day. However it 
> doesn't take into account the endusers local time, and thus doesn't work 
> properly.
> 
> 
> Views.py
> from django.utils import timezone
> 
> t = timezone.now() [This should somehow react to endusers local time]
> dm = t.strftime('%m-%d')
> history = history.objects.filter(monthday__exact=dm)
> historystory = random.sample(list(history), 1)
> args = {'historystory':historystory}
> return render(request, "news/home.html", args)
> 
> home.html
> [in html I have just the basic things to show the content]
> 
> 
> 
> {% for x in historystory %}
>{{ x.title }} 
>{{ x.subtitle }} 
> 
>{{ x.content }} 
>   {% endfor %}
>   
> 
> 
> 
> Settings.py
> LANGUAGE_CODE = 'en-us'
> TIME_ZONE = 'UTC'
> USE_I18N = True
> USE_L10N = True
> USE_TZ = True
> 
> You can check my webpage (http://www.topithenewsdoggy.com/ 
> ) to get better understanding what I'm 
> doing. The part is under Additional info.
> 
> -Mikko
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAGD0jj%2Bh_1Pd50eE0e0zXt8P-yozqCnZeYYXTe6bj6Tt6UopxA%40mail.gmail.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@googlegroups.com 
> .
> Visit this group at https://groups.g

Re: MySQL CRUD

2019-02-25 Thread Thomas Lockhart
A good way to get started is to follow the Django tutorial on the polling app. 
The mailing list will be happy to answer specific questions you might have. 
Good luck!

- Tom

> On Feb 25, 2019, at 10:12 AM, Darshan Gohel  
> wrote:
> 
> How to Create tables using Django ?
> And how to insert values into it using django itself ?
> 
> Thank you !
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/89896f83-148f-4b2d-b061-9f2fad665fe3%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/FF2D2EA5-7531-4FAB-87D5-E5055AC11A3D%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Print data from Database in Django

2019-05-05 Thread Thomas Lockhart
Your context variable for all students is “stud”. Try changing that to 
“Student” as you refer to it in your template.

- Tom

> On May 5, 2019, at 7:09 AM, anchal agarwal  wrote:
> 
> I want to display the name of all the students from the Student model using 
> cards , i have set it all up but it isn't displaying anything, here are my 
> files  
> 
> models.py
> 
> from django.db import models
> from django.utils import timezone
> from datetime import date
> from ckeditor.fields import RichTextField
> 
> class Student(models.Model):
> full_name=models.CharField(max_length=70)
> D_O_B=models.TextField()
> def _str_(self):
> return self.full_name
> 
> class Article(models.Model):
> pub_date=models.DateField(default=timezone.now())
> headline=models.CharField(max_length=70)
> content=RichTextField()
> reporter=models.ForeignKey(Student,on_delete=models.CASCADE)
> 
> 
> 
> urls.py
> 
> from django.urls import path
> from . import views
> 
> app_name="students"
> 
> urlpatterns=[
> path('Students.html/',views.homepage,name='homepage'),
> path("/",views.detail,name='detail'),]
> 
> 
> views.py 
> 
> from django.shortcuts import render
> from django.http import HttpResponse
> from .models import Student
> 
> 
> def homepage(request):
> context={"stud": Student.objects.all}
> print(Student.objects.all)
> return render(request,"students/Students.html",context)
> 
> def detail(request,full_name):
> return HttpResponse("You are looking %s!!" % full_name)
> 
> Students.html
> 
> 
>  href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css
>  
> ">
> 
> 
>  src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js
>  
> <https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js>">
> 
>
> 
> {% for stud in Student %}
> 
>   
> 
>   {{stud.full_name}}
>   {{stud.D_O_B}}
> 
> 
>   This is a link
>   This is a link
> 
>   
> 
> {% endfor %}
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAMT%3DisXCa7Yc-vM3%2B5c0jWdCX8hgwJFN2tRtCqkK2NbzzqX-nA%40mail.gmail.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

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


Re: HELP With Scraping and Storing Data to DB from a Search Engine!!

2020-09-13 Thread Thomas Lockhart
Use Python and Beautiful Soup for scraping in an external program. Then send 
the results to your Django app using the Django Rest Framework JSON API. If you 
need your scraping program to get candidate sites from your app, then use the 
DRF API to get those.

hth

- Tom

> On Sep 13, 2020, at 1:39 AM, Raheel Asghar  wrote:
> 
> I am working on a project where i require to search for data related to 
> shopping, save it to my DB and show it to my users. But I cant find a way to 
> do so. PLEASE HELP
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/588cb39a-7a5c-4103-b408-b16156ce6da7n%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/088B507F-AFFD-4989-A099-9219E3C807BB%40gmail.com.


Re: Problem with Postgresql-11.9 ??

2020-10-12 Thread Thomas Lockhart
No one has answered yet, so here is some useless info…

I’ve been using various combinations of Postgres and Django (currently 12.4 and 
3.1.2, respectively) and would think I would have stumbled on this at some 
point when using postgresql-11. But I probably haven’t tried 11.x with 3.1.2 
specifically…

- Tom

> On Oct 12, 2020, at 9:24 AM, Joakim Hove  wrote:
> 
> 
> [ This question is also posted to StackOverflow: 
> https://stackoverflow.com/questions/64320386/django-postgresql-model-with-only-foreign-keys
>  
> 
>  ]
> 
> I have a model which looks like this:
> 
> class InputTypeMap(models.Model):
> input_type = models.ForeignKey(InputType, on_delete=models.CASCADE)
> training = models.ForeignKey(Training, on_delete=models.CASCADE)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> gender = models.ForeignKey(Gender, on_delete=models.CASCADE)
> When I try to create instances of this model with:
> 
> InputTypeMap.objects.create(input_type=input_type,
> training=training,
> gender=gender,
> category=category)
> I get an exception when using Postgres-11.9:
> 
> Traceback (most recent call last):
>   File 
> "/home/hove/sleipner/venv/lib/python3.7/site-packages/django/db/backends/utils.py",
>  line 84, in _execute
> return self.cursor.execute(sql, params)
> psycopg2.errors.NotNullViolation: null value in column "id" violates not-null 
> constraint
> DETAIL:  Failing row contains (null, Maintenance, Female, MareGielding, No).
> From the error message it seems to me that a ID key for the new entry is not 
> generated. This code has worked as I expected for quite some time, but has 
> "suddenly" started to fail locally - probably after a apt get upgrade. When I 
> run the same code with sqlite or Postgres-10.14 thing continue to work as 
> before. It is not clear to me whether this is a bug in my code (most probable 
> ...), Django or Postgres. I am using Django version 3.1.2 
> 
> Any hints appreciated.
> 
> Regards - Joakim Hove
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CALKD1M-YbR80USkq%2BLLyWHR7iem66ALcc9bH6dYGOEP9ywWkfA%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1C816206-3EC7-4696-806E-FD810E76C251%40gmail.com.


Re: Library for calculating distance between ZIP codes

2021-02-16 Thread Thomas Lockhart
Pre-calculating is pretty expensive: 81939*81938/2 = 3,356,958,891 entries make 
a pretty big table. Calculating on the fly is probably not horribly expensive 
and you could calculate and save, thereby caching values which have been used 
before.

Anyway, geodjango might be what you need. Plus the info on the geodetic 
coordinates for each zip code of course.

hth

- Tom

> On Feb 16, 2021, at 8:27 PM, Ram  wrote:
> 
> Hi,
> 
> We've USA ZIP codes table with the following values. and we have a total of 
> 81,939 ZIP codes.
> 
> INSERT INTO pages_zip_code (id, zip, city, st) VALUES
> (1, '00501', 'Holtsville', 'NY'),
> (2, '00544', 'Holtsville', 'NY'),
> (3, '00601', 'Adjuntas', 'PR'),
> (4, '00602', 'Aguada', 'PR'),
> (5, '00603', 'Aguadilla', 'PR'),
> ...
> 
> We need to calculate the distance between each zip code and save the distance 
> value in table like "zip_codes_distance" with the following table columns
> 
> zip_codes_distance table
> id | from_zip | to_zip | distancev
> 
> We're looking for an appropriate library that might be available in 
> Python/Django to calculate the distance easily instead of using any API. We 
> know we can use Google's distance API with allowable requests, but we are 
> trying to see if any Python library out there that is capable of doing the 
> same calculation.
> 
> I would appreciate expert advice on this.
> 
> Best regards
> ~Ram
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CA%2BOi5F1-E-70zWo-8EPu0%2BrWD%2BCjFqZaCVaUEtbb9mRNKjpMNQ%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6921E387-014E-4C71-AAB8-80295C7A5C5D%40gmail.com.


Re: Python libraries for visualisations

2021-03-15 Thread Thomas Lockhart
If you are working with larger scientific datasets then bokeh may be of 
interest. For my cases all of the code is done in python.

hth

- Tom

> On Mar 14, 2021, at 9:49 PM, GEETHANJALI S P  
> wrote:
> 
> Hi..How to build a dashboard using django and python libraries for creating 
> visualisations?. Please let me know .Thanks in advance!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAMKAcO%2BJqqp0kYMbWaWqjqJDcmMT9xMndv%3DD%2BNHbtYBvqL9CQg%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/AF71C3F4-536E-44AF-B1B2-F0BE246C175F%40gmail.com.


Re: View / Query Set not showing with filter

2021-03-19 Thread Thomas Lockhart
Almost certainly start_date and end_date are not what you expect.

Do the types match? In any case print them out and see what you are actually 
getting.

hth

- Tom

> On Mar 19, 2021, at 6:00 AM, Manuel Buri  wrote:
> 
> Hi,
> 
> I am having this query set in my view:
> context['bookings']=Booking.objects.filter( 
> Q(organization_id=request.user.organization_id), Q(booking_time__range= 
> (start_date, end_date)))
> 
> It produces a non-empty query set!
> However, I am NOT able to display it in my template.
> 
> If I get rid of Q(booking_time__range= (start_date, end_date) and only do:
> context['bookings']=Booking.objects.filter( 
> Q(organization_id=request.user.organization_id))
> then it is also non-empty AND it is displaying it in my template.
> 
> What am I missing here?
> 
> Thank you for your help.
> 
> Manuel
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/76f85c72-19f9-4ad3-a39b-01dc60aa6da5n%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83B24C06-8DA4-4F38-9384-FF4C19DBE262%40gmail.com.


Re: View / Query Set not showing with filter

2021-03-19 Thread Thomas Lockhart
Why use Q? afaict simple filter syntax should get you what you want.

Booking.objects.filter(organization_id=request.user.organization_id, 
booking_time__range= (start_date, end_date))

Not sure if this will get you closer to the query you expect.

You might also find it useful to use "./manage.py shell" to test the queries by 
hand. Import a few models, put in “11” for the organization_id, and see what 
happens.

- Tom

> On Mar 19, 2021, at 2:11 PM, Manuel Buri  wrote:
> 
> I want to fetch all bookings for the users organization_id between start_date 
> and end_date.
> I am achieving this via this queryset, however, as soon as I add the second 
> filter (bold), it is not rendered in the template anymore and I, therefore, 
> do not see it in my HTML file.
> context['bookings']=Booking.objects.filter( 
> Q(organization_id=request.user.organization_id), Q(booking_time__range= 
> (start_date, end_date)))
> 
> Thank you so much for your help.
> Best wishes,
> 
> Manuel
> 
> 
> 
> Manuel Buri
> T:  +41 79 933 01 11 
> M: manuel.b...@gmail.com
> W: www.manuelburi.com
> 
> 
> On Fri, 19 Mar 2021 at 22:07, Anornymous u  wrote:
> I mean what you want to fetch and the conditions
> 
> On Fri, Mar 19, 2021, 16:01 Manuel Buri  wrote:
> Hi,
> 
> I am having this query set in my view:
> context['bookings']=Booking.objects.filter( 
> Q(organization_id=request.user.organization_id), Q(booking_time__range= 
> (start_date, end_date)))
> 
> It produces a non-empty query set!
> However, I am NOT able to display it in my template.
> 
> If I get rid of Q(booking_time__range= (start_date, end_date) and only do:
> context['bookings']=Booking.objects.filter( 
> Q(organization_id=request.user.organization_id))
> then it is also non-empty AND it is displaying it in my template.
> 
> What am I missing here?
> 
> Thank you for your help.
> 
> Manuel
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/76f85c72-19f9-4ad3-a39b-01dc60aa6da5n%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/2DC9EY75yuM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAMXTB%3DcsfYRqGPbhXncaHNTjKqVhgskST8BDEAY-2fYonemfdg%40mail.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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CACx7KOQEEWWNu6hQwMXdEP_nZ6%2Bex9HZ9KEiVubrvd89%3DTP%3DuQ%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7C87F855-5ECE-4470-A8CA-916B64F7CFF5%40gmail.com.


Re: Server balance

2021-05-15 Thread Thomas Lockhart
You will find a lot of useful information just by searching for “scaling 
Django”. Then you can ask specific questions here.

hth

- Tom

> On May 14, 2021, at 9:29 PM, Shashank Vijendra  
> wrote:
> 
> If suddenly Users are increased for our site our site capacity is lets take 
> 1000 
> so what should i do or how to manage that site in Django plz anyone explain 
> this
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/27c119c6-b76e-4e6f-a95e-9425e8c2174en%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/AC862BB2-A47D-4AAC-8FEF-A2811FE41009%40gmail.com.


Re: Creating dynamic chart / graphs with Django

2021-05-15 Thread Thomas Lockhart
Django integration is fairly easy with Bokeh. For very large datasets you will 
want to also use Datashader and Holoviews so that high-density data gets 
rendered with meaningful interpolations.

hth

- Tom

> On Apr 12, 2021, at 7:16 AM, Lars Liedtke  wrote:
> 
> Hey,
> 
> this is quite good https://bokeh.org  it can create 
> dynamic html/js as well, but I don't know how the interagion into django is.
> 
> Cheers
> 
> Lars
> 
> Am 12.04.21 um 15:32 schrieb Walter Randazzo:
>> Hi Tristan,
>> 
>> i have used this one just once. 
>> 
>> 
>> https://www.highcharts.com/demo 
>> 
>> Check it, it easy to setup.
>> 
>> Regards,
>> 
>> 
>> 
>> 
>> El lun, 12 abr 2021 a las 10:05, tristant (> >) escribió:
>> I am looking to build site with a variety of charts and graphs. A quick 
>> search shows quite a lot of packages out there, as listed here Django 
>> Packages : Charts 
>> 
>> Has anyone used any of these packages and could provide some advice on which 
>> is better? For my task, I am looking to create both typical 2D charts as 
>> well as possible 3D plots. The charts need to be interactive ( as in user 
>> can tweak inputs and expect the charts to respond).
>> 
>> I have done similar charts with R Shiny. I am wondering which of these 
>> packages can do similar things?
>> 
>> I notice in the link, some packages mention "offline". Does this mean they 
>> cannot create interactive charts?
>> 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/efe61d41-1e8c-4c56-899f-8164c0384bf3n%40googlegroups.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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAL7Dry50qF%3DJ0A5f3p%3DUMpVhzhnAV2s4nRmUr4g37LZ5Qju3%3Dg%40mail.gmail.com
>>  
>> .
> -- 
> ---
> punkt.de GmbH
> Lars Liedtke
> .infrastructure
> 
> Kaiserallee 13a   
> 76133 Karlsruhe
> 
> Tel. +49 721 9109 500
> https://infrastructure.punkt.de 
> i...@punkt.de 
> 
> AG Mannheim 108285
> Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/b1a86516-79e5-faf1-9d6d-87edbf3301bc%40punkt.de
>  
> .

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4C6F8FF6-9CAF-4CA2-AE0A-5A8BB072B131%40gmail.com.


Re: How to fix this error

2021-05-24 Thread Thomas Lockhart
A “not null constraint failed” is in the error message. So you have a field 
which is not being set and the database itself is complaining.

It looks like you have extended the user profile to include a foreign key to 
“babyinfo” and that is empty apparently.

Either change the model to allow a null field or make sure that it is filled in.

hth

- Tom

> On May 24, 2021, at 6:01 AM, Hugh Frost  wrote:
> 
> 
> Request Method: POST  <>Request URL: http://127.0.0.1:8000/profile/  <> 
> <>Django Version: 3.1.7  <>Python Version: 3.9.2  <>Installed Applications:  
> <>['django.contrib.admin',  <>'django.contrib.auth',  
> <>'django.contrib.contenttypes',  <>'django.contrib.sessions',  
> <>'django.contrib.messages', <>'django.contrib.staticfiles',  <>'bootstrap4', 
>  <>'crispy_forms',  <>'userapp',  <>'rest_framework',  
> <>'rest_framework.authtoken']  <>Installed Middleware:  
> <>['django.middleware.security.SecurityMiddleware',  
> <>'django.contrib.sessions.middleware.SessionMiddleware', 
> <>'django.middleware.common.CommonMiddleware',  
> <>'django.contrib.auth.middleware.AuthenticationMiddleware', 
> <>'django.contrib.messages.middleware.MessageMiddleware',  
> <>'django.middleware.clickjacking.XFrameOptionsMiddleware']  <> <> <> 
> <>Traceback (most recent call last):  <>File 
> "D:\envi\lib\site-packages\django\db\backends\utils.py", line 84, in _execute 
>  <>return self.cursor.execute(sql, params)  <>File 
> "D:\envi\lib\site-packages\django\db\backends\sqlite3\base.py", line 413, in 
> execute  <>return Database.Cursor.execute(self, query, params)  <> <>The 
> above exception (NOT NULL constraint failed: userapp_profile.babyinfo_id) was 
> the direct cause of the following exception:  <>File 
> "D:\envi\lib\site-packages\django\core\handlers\exception.py", line 47, in 
> inner  <>response = get_response(request)  <>File 
> "D:\envi\lib\site-packages\django\core\handlers\base.py", line 181, in 
> _get_response  <>response = wrapped_callback(request, *callback_args, 
> **callback_kwargs) <>File "D:\project_kuttystory\userapp\views.py", line 35, 
> in detail  <>baby_form2.save()  <>File 
> "D:\envi\lib\site-packages\django\forms\models.py", line 460, in save  
> <>self.instance.save()  <>File 
> "D:\envi\lib\site-packages\django\db\models\base.py", line 753, in save  
> <>self.save_base(using=using, force_insert=force_insert,  <>File 
> "D:\envi\lib\site-packages\django\db\models\base.py", line 790, in save_base  
> <>updated = self._save_table(  <>File 
> "D:\envi\lib\site-packages\django\db\models\base.py", line 895, in 
> _save_table  <>results = self._do_insert(cls._base_manager, using, fields, 
> returning_fields, raw)  <>File 
> "D:\envi\lib\site-packages\django\db\models\base.py", line 933, in _do_insert 
>  <>return manager._insert(  <>File 
> "D:\envi\lib\site-packages\django\db\models\manager.py", line 85, in 
> manager_method  <>return getattr(self.get_queryset(), name)(*args, **kwargs) 
> <>File "D:\envi\lib\site-packages\django\db\models\query.py", line 1254, in 
> _insert  <>return 
> query.get_compiler(using=using).execute_sql(returning_fields)  <>File 
> "D:\envi\lib\site-packages\django\db\models\sql\compiler.py", line 1397, in 
> execute_sql  <>cursor.execute(sql, params)  <>File 
> "D:\envi\lib\site-packages\django\db\backends\utils.py", line 98, in execute  
> <>return super().execute(sql, params)  <>File 
> "D:\envi\lib\site-packages\django\db\backends\utils.py", line 66, in execute  
> <>return self._execute_with_wrappers(sql, params, many=False, 
> executor=self._execute)  <>File 
> "D:\envi\lib\site-packages\django\db\backends\utils.py", line 75, in 
> _execute_with_wrappers  <>return executor(sql, params, many, context)  <>File 
> "D:\envi\lib\site-packages\django\db\backends\utils.py", line 84, in _execute 
>  <>return self.cursor.execute(sql, params)  <>File 
> "D:\envi\lib\site-packages\django\db\utils.py", line 90, in __exit__  <>raise 
> dj_exc_value.with_traceback(traceback) from exc_value  <>File 
> "D:\envi\lib\site-packages\django\db\backends\utils.py", line 84, in _execute 
>  <>return self.cursor.execute(sql, params)  <>File 
> "D:\envi\lib\site-packages\django\db\backends\sqlite3\base.py", line 413, in 
> execute  <>return Database.Cursor.execute(self, query, params)  <> 
> <>Exception Type: IntegrityError at /profile/  <>Exception Value: NOT NULL 
> constraint failed: userapp_profile.babyinfo_id
> 
> Request Method: POST  <>Request URL: http://127.0.0.1:8000/profile/  <> 
> <>Django Version: 3.1.7  <>Python Version: 3.9.2  <>Installed Applications:  
> <>['django.contrib.admin',  <>'django.contrib.auth',  
> <>'django.contrib.contenttypes',  <>'django.contrib.sessions',  
> <>'django.contrib.messages', <>'django.contrib.staticfiles',  <>'bootstrap4', 
>  <>'crispy_forms',  <>'userapp',  <>'rest_framework',  
> <>'rest_framework.authtoken']  <>Installed Middleware:  
> <>['django.middleware.security.SecurityMiddleware',  
> <>'django.contrib.sessions.middleware.Se

Re: How does django-admin work?

2021-05-31 Thread Thomas Lockhart
Welcome to Django!

Django does not add django-admin to your path. Rather, when Django is installed 
it (sometimes) happens to be installed into a place which is already in your 
path. Otherwise, you need to add it to your path or use a packaging system such 
as anaconda which helps do that for you.

startproject simply copies a set of files to your directories, filling in a few 
details and changing the file names to match what you want to create since you 
give it the name of your new project.

hth

- Tom

> On May 31, 2021, at 5:43 PM, J Lee  wrote:
> 
> I'm new to Django, and I've just been dazzled by the magic of Django. My main 
> question is how does Django add django-admin to my path automatically and how 
> does django-admin startproject create my files?
> 
> It may be wy over my head, but I welcome any and all response. I would 
> like to learn from this. 
> 
> Thank you.
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/5b022968-ac51-4e49-873d-f9a3b7b88ba4n%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8834A390-1F46-4405-826D-E7A3A1DCE384%40gmail.com.


Re: how does Django handle outbound requests?

2021-06-27 Thread Thomas Lockhart
It is quite often recommended to keep it simple and then optimize if you need 
to. The optimization woiuld be to decouple the external request using a queue, 
then provide a response to the client separately. Just as you suggest.

You can also design your API to allow this optimization, without actually 
implementing the queue feature yet. But adding a work queue using celery is 
pretty darn easy (at least after you have done the first one) so that is 
probably the easiest part of your future work.

If you already think you know your likely range of loading, then you can also 
use a test rig to load your system and see if it can keep up without bogging 
down Django or your other components. Then optimize if needed before you go 
into production...

hth

- Tom


> On Jun 25, 2021, at 2:41 PM, Glenn Rutkowski  wrote:
> 
> Can anyone point me in the right direction?  We are using Django as an API 
> Endpoint that accepts a request and then repackages it and sends it to an 
> external service and waits for a response.  I'm interested in the external 
> call and how it is handled.  If it times out or takes forever, what it the 
> effect on the Django server?  Am I blocking any other execution from 
> happening while waiting for the response?  
> 
> From what I have read it seems as if the best idea is to pass the job off to 
> a queue and then check for job status alerts or updates.  If I have to 
> rethink this - I'd rather do it now. 
> 
> Thanks for reading, looking forward to responses!
> 
> -g
> 
> 
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/20152777-2847-4b94-974c-27be70ee04can%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/330695DC-104E-4BCC-AEE2-EB044B0B2106%40gmail.com.


Re: TypeError: 'str' object is not callable

2021-08-30 Thread Thomas Lockhart
Just guessing that you need to write

messages.success = “Your ad is successfully posted”

But without more information from you that is only a guess.

How is messages.success defined?

- Tom

> On Aug 30, 2021, at 8:57 PM, Salima Begum  
> wrote:
> 
> Hi all,
> In my project for each functionality I have written code for confirmation 
> messages. For example
> ```
> messages.success("Your ad is successfully posted")
> ```
> Every functionality is breaking because of confirmation messages after 
> deployment. How to fix it? Can anyone help me? 
> 
> Thank you
> ~Salima
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3831F4E1-0003-4F5A-922D-F6E1534E1B87%40gmail.com.


Re: Creating test databases in parallel

2020-04-01 Thread Thomas Lockhart
If you are trying to optimize the test flow, then you may want to spend some 
time shrinking your test databases to a more manageable size. Or have two sets; 
abbreviated and full, with the larger one to exercise your (unknown) edge cases.

hth

- Tom

> On Apr 1, 2020, at 2:25 AM, cool-RR  wrote:
> 
> Hi guys,
> 
> I'm trying to optimize our Django testing workflow.
> 
> We have 7 different databases, and Django spends a lot of time on these 
> lines: 
> 
> Creating test database for alias 'main_database'...
> Creating test database for alias 'foo_database'...
> Creating test database for alias 'bar_database'...
> Creating test database for alias 'baz_database'...
> 
> This is especially annoying when you're running just one test, but have to 
> wait 1:30 minutes just for these test databases.
> 
> Is there any way to speed this up? Either by parallelizing it or in any other 
> way. A few months ago I tried some naive code that parallelizes these 
> actions, but it failed. (Unfortunately I don't have the error message saved.)
> 
> 
> Thanks,
> Ram.
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43DDD6E9-EAA8-4162-BDB3-665F3CCA00E0%40gmail.com.


Re: gdal installed still

2020-05-12 Thread Thomas Lockhart
It looks like you are running on Windows which I’m not familiar with. But most 
likely your gdal installation is in a different Python installation than your 
django installation.

- Tom

> On May 12, 2020, at 3:53 AM, mick  wrote:
> 
> django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library 
> (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is GDAL 
> installed? If it is, try setting GDAL_LIBRARY_PATH in your setting
> s.
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f5552467-2dfb-48d3-88f5-f66ab5abc258%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98C19BF8-FD13-43F2-B9EF-4D8546F19E64%40gmail.com.


Re: Python 3.8 Installed, yet Django 1.11 is Automatically Being Installed on Mac

2020-06-08 Thread Thomas Lockhart
virtualenv or (probably even better) conda (Anaconda) will be easier 
environments to manage. I know that MacPorts will also have the packages you’ll 
need.

hth

- Tom

> On Jun 8, 2020, at 7:37 PM, arhoon io  wrote:
> 
> Hello,
> 
> I have installed and successfully confirmed that Python 3.8 works on my Mac.  
> However, when I pip installed the latest version of Django, it automatically 
> installed Django 1.11 even though I have Python 3.8.
> 
> When typing in "python" into terminal, it runs Python 2.7 - so that is my 
> guess. 
> 
> If that is true, how do I get the actual latest version of Django (3.0)?
> 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d02c23bd-0c04-47c1-8602-63c74e35e144o%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/A0BF061C-E821-4658-91D9-8BD077597E00%40gmail.com.


Re: Django 3.1 release candidate 1 released

2020-08-04 Thread Thomas Lockhart
Mariusz announced the final release a few hours before you posted this. To this 
same email list ;)

- Tom

> On Aug 3, 2020, at 10:14 PM, 'Nikhilanj Venkata Pelluri (Software 
> Development)' via Django users  wrote:
> 
> Hi,
> Has the final version for v3.1 been released ?
> 
> On Monday, July 20, 2020 at 12:13:27 PM UTC+5:30 Mariusz Felisiak wrote:
> Details are available on the Django project weblog: 
> 
> https://www.djangoproject.com/weblog/2020/jul/20/django-31-release-candidate-1-released/
>  
> 
>  
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f29faf93-d26e-491b-81b3-9e7fd8107bf8n%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/A7B3321A-B7F3-49D4-AA19-1E249CC1DCFA%40gmail.com.


Re: form.is_valid() is always return false please help

2019-08-22 Thread Thomas Lockhart
Post your form code please.

- Tom

> On Aug 22, 2019, at 12:56 PM, Shubham Chauhan  
> wrote:
> 
> form.is_valid() is always return false please help 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/206e042a-738b-4491-8f4d-9c172f61e56d%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12E7B9A4-E03E-4371-B6AA-1E97A8173C87%40gmail.com.


Re: Postgre sql problem

2019-09-06 Thread Thomas Lockhart
You need the python-devel package installed for the version of python you are 
running.

- Tom

> On Sep 6, 2019, at 12:49 PM, Elmaco7  wrote:
> 
> Hello, I'm trying to use Postresql with my django project, but when i try to 
> install psycopg2(with this command 'pip3 install psycopg2')  this problem 
> appears:
> 
> Collecting psycopg2
>   Using cached 
> https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
> Building wheels for collected packages: psycopg2
>   Building wheel for psycopg2 (setup.py) ... error
>   ERROR: Command errored out with exit status 1:
>command: /home/user/myproject/myprojectenv/bin/python3 -u -c 'import sys, 
> setuptools, tokenize; sys.argv[0] = 
> '"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"'; 
> __file__='"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"';f=getattr(tokenize,
>  '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
> bdist_wheel -d /tmp/pip-wheel-mkc6kj2i --python-tag cp36
>cwd: /tmp/pip-install-t391_oat/psycopg2/
>   Complete output (40 lines):
>   running bdist_wheel
>   running build
>   running build_py
>   creating build
>   creating build/lib.linux-x86_64-3.6
>   creating build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/compat.py -> build/lib.linux-x86_64-3.6/psycopg2
>   copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2
>   running build_ext
>   building 'psycopg2._psycopg' extension
>   creating build/temp.linux-x86_64-3.6
>   creating build/temp.linux-x86_64-3.6/psycopg
>   x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g 
> -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
> -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) 
> -DPG_VERSION_NUM=100010 -DHAVE_LO64=1 -I/usr/include/python3.6m 
> -I/home/user/myproject/myprojectenv/include/python3.6m -I. 
> -I/usr/include/postgresql -I/usr/include/postgresql/10/server -c 
> psycopg/psycopgmodule.c -o 
> build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o 
> -Wdeclaration-after-statement
>   In file included from psycopg/psycopgmodule.c:27:0:
>   ./psycopg/psycopg.h:34:10: fatal error: Python.h: No such file or directory
>#include 
> ^~
>   compilation terminated.
>   
>   It appears you are missing some prerequisite to build the package from 
> source.
>   
>   You may install a binary package by installing 'psycopg2-binary' from PyPI.
>   If you want to install psycopg2 from source, please install the packages
>   required for the build and try again.
>   
>   For further information please check the 'doc/src/install.rst' file (also at
>   ).
>   
>   error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>   
>   ERROR: Failed building wheel for psycopg2
>   Running setup.py clean for psycopg2
> Failed to build psycopg2
> Installing collected packages: psycopg2
>   Running setup.py install for psycopg2 ... error
> ERROR: Command errored out with exit status 1:
>  command: /home/user/myproject/myprojectenv/bin/python3 -u -c 'import 
> sys, setuptools, tokenize; sys.argv[0] = 
> '"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"'; 
> __file__='"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"';f=getattr(tokenize,
>  '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
> install --record /tmp/pip-record-bl1kkv0m/install-record.txt 
> --single-version-externally-managed --compile --install-headers 
> /home/user/myproject/myprojectenv/include/site/python3.6/psycopg2
>  cwd: /tmp/pip-install-t391_oat/psycopg2/
> Complete output (40 lines):
> running install
> running build
> running build_py
> creating build
> creating build/lib.linux-x86_64-3.6
> creating build/lib.linux-x86_64-3.6/psycopg2
> copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
> copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
> copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2
>  

Re: __init__() got an unexpected keyword argument 'on delete' when make migrations

2021-12-05 Thread Thomas Lockhart
Please use polite language. Thank you.

- Tom

> On Dec 5, 2021, at 5:21 PM, Anurag Agarwal  wrote:
> 
> Why are you fucking passing the args
> On_delete in manytomany . Class
> 
>promotion = models.ManyToManyField(Promotions, on_delete=models.CASCADE)
> 
> 
> On Sun, Dec 5, 2021, 21:09 Samuel Nogueira  > wrote:
> Please, can you take some prints of your models?
> 
> Em dom., 5 de dez. de 2021 12:34, Khánh Hoàng  > escreveu:
> Hi everyone, I am new to programming, more than 4 months, I had an issue when 
> making  migrations for my apps. 
> 
> I run :" python manage.py makemigrations " and  I got a error.
>  It said:  TypeError: __init__() got an unexpected keyword argument 'on 
> delete'
> I'm Using Django 3.2.9 
> Can someone explain it for me? And how to fix it.
> 
> Thanks and Regards,
> Khanh Hoang
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/b5adebe5-05b0-4c33-b164-85fda53e13cbn%40googlegroups.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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAOJT-cB8%3DxmYBFPykbRxAdagN-PoDQQRne-r8MjHLZk2MX7j9w%40mail.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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAOuTKWKubiOk%3D%3DezHsSfP_k%2BamwPma7FUP1Goe%3DKBxcvWu03pQ%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/190AFFA2-900F-4D18-A7A7-ED1925586E37%40gmail.com.


Re: Declarative mechanism for Django model rows

2021-12-08 Thread Thomas Lockhart
I may be completely misunderstanding your use case, but just in case…

You can have different views in your application, and if you don’t want to 
expose the data as separate pages then you might consider django-rest-framework 
to provide data in various ways, including across models. You’ll end up doing a 
bit of javascript but not have to dive back into your database for changes in 
how you want things to be accessed.

Flexible searches on attributes might be best supported by folding in 
ElasticSearch or something similar. It might seem like a heavy addition to a 
small-ish application, but once it it running it is flexible and trouble-free.

hth

- Tom

> On Dec 8, 2021, at 11:25 AM, Alex Dehnert  wrote:
> 
> With some frequency, I end up with models who contents are approximately 
> constant. Are there good ways of handling this?
> 
> For example, I might have a set of plans that users can sign up for, with 
> various attributes -- ID, name, order in the list of plans, cost, whether the 
> purchaser needs to be a student/FOSS project/etc.. I'm going to rarely 
> add/remove/change rows, and when I do there's likely going to be code changes 
> too (eg, to change landing pages), so I'd like the contents of the model (not 
> just the schema) to be managed in the code rather than through the Django 
> admin (and consequently use pull requests to manage them, make sure test 
> deploys are in sync, etc.). I'd also like it to be in the database, though, 
> so I can select them using any column of the model, filter for things like 
> "show me any project owned by a paid account", etc..
> 
> I think my ideal would be something like "have a list of model instances in 
> my code, and either Django's ORM magically pretends they're actually in the 
> database, or makemigrations makes data migrations for me", but I don't think 
> that exists?
> 
> The two workable approaches that come to mind are to either write data 
> migrations by hand or use regular classes (or dicts) and write whatever 
> getters and filters I actually want by hand.
> 
> Data migrations give me all the Django ORM functionality I might want, but 
> any time I change a row I need to write a migration by hand, and figuring out 
> the actual state involves either looking in the Django admin or looking 
> through all the data migrations to figure out their combined impact. (Oh, and 
> if somebody accidentally deletes the objects in the database (most likely on 
> a test install...) or a migration is screwy recovering will be a mess.)
> 
> Just using non-ORM classes in the source is a clearer, more declarative 
> approach, but I need to add replacements for many things I might normally do 
> in the ORM (.objects.get(...), __plan__is_student, 
> .values(plan__is_student).annotate(...), etc.).
> 
> Which of these approaches is better presumably depends on how much ORM 
> functionality I actually want and how often I expect to be changing things.
> 
> Are there other good approaches for this? Am I missing some Django feature 
> (or add-on) that makes this easier?
> 
> Thanks,
> Alex
> 
> P.S. I previously asked this on StackOverflow at 
> https://stackoverflow.com/questions/70204467/declarative-mechanism-for-django-model-rows,
>  but I'm realising this list is probably better.
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/alpine.DEB.2.21.2112081409120.12786%40novgorod.mit.edu.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ADF2C45E-6CFD-469C-8B11-F61056D67853%40gmail.com.


  1   2   >