Re: Creating the testing db fails (django 1.8.5)

2015-10-15 Thread Uwe Schuerkamp

>
> I solved it myself... looks like I forgot to create the initial migrations 
> for the app. After running
>

python manage.py makemigrations club300
python  manage.py migrate --fake-initial

python manage.py test club300

appears to work fine. Sorry for the noise & thanks for your help!

Uwe

-- 
You received this message because you are subscribed to the Google Groups 
"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/db479740-90cb-4a3c-b263-8b011464d5ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating the testing db fails (django 1.8.5)

2015-10-15 Thread Uwe Schuerkamp
Here's some more info in case it helps: 

The "manage.py test" call seems to get as far as creating the table 
"django_migrations", then things break. The production DB has several more 
tables (25 in all) I'm not seeing in the output below, so I guess this 
issue must be related to the migrations table in some manner. 

All the best, Uwe


MariaDB [test_club300_owl]> show tables ; 
+-+
| Tables_in_test_club300_owl  |
+-+
| club300_alert   |
| club300_area|
| club300_bird|
| club300_birdcategory|
| club300_birdcategory_birdcategory_birds |
| club300_country |
| club300_location|
| club300_newsitem|
| club300_observation |
| club300_toplist |
| club300_toplist_toplist_birds   |
| club300_userprofile |
| django_migrations   |
+-+
13 rows in set (0.00 sec)




>

-- 
You received this message because you are subscribed to the Google Groups 
"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/1267ddd2-b62b-4509-bd71-b95c6a844375%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating the testing db fails (django 1.8.5)

2015-10-15 Thread Uwe Schuerkamp

>
> Hi Mike,
>

thanks for your quick reply.

I tried deleting the test database, but that didn't help either (actually I 
tried this several times before I posted here, I even set up a "fresh" 
production database  on my test machine and re-imported the live data in 
order to solve the problem).

All the best, 

Uwe

-- 
You received this message because you are subscribed to the Google Groups 
"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/12e76866-8880-4c10-9ce3-8876d2059a7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrade path for Django 1.4.9 to Django 1.6.0

2015-10-14 Thread Uwe Schuerkamp
Hi Mark,

I recently had the same issue, I went from 1.3.x to 1.4.21 and then to 
1.8.5 via 1.7.x without any major issues. 

Granted my application isn't too complex and doesn't use too many of 
Django's internal bells and whistles, but the major obstacles for me were 
adding some new entries to settings.py, creating a new manage.py script and 
properly escaping / quoting arguements to [% url %}, so nothing that could 
not be fixed by a bit of googling (the problems I'm having with the testing 
setup is another matter, though and may be entirely due to me not really 
knowing what I'm doing ;) 

Cheers, Uwe

-- 
You received this message because you are subscribed to the Google Groups 
"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/ac1db1a8-65b3-4bdc-8018-3c12c9c2de23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Creating the testing db fails (django 1.8.5)

2015-10-14 Thread Uwe Schuerkamp
Hi folks,

this is my first posting in this group, so I'm sorry in advance if I'm 
breaking any rules or missing some vital information.

My setup: 

Ubuntu Server 14.04.x
Python 2.7.6
Django 1.8.4 (updated to 1.8.5 recently) installed via "pip"
MariaDB 5.5.44

I'm trying to set up a test framework for a little internal project which 
I've been working on since the Django 1.3 days. I've recently migrated the 
project to Django 1.8.4/5 via Django 1.7, and everything appears to be 
working fine. 

Trying to set up a testing framework for the first time to get out of my 
bad "non-testing" habit and increase the test coverage above "0%" for the 
first time ever, I've run into a problem when the manage.py script tries to 
create the test database (permissions on the MySQL side are ok, i've tested 
createdb, dropping, creating and changing tables in the test db manually): 

http://pastebin.com/XDRiqaqL

I've been googling for quite some time and have tried creating the 
migrations via "--fake-initial", but nothing has helped to work around the 
problem. 

I've read it could be some foreign key problem (MariaDB 5.5.x backend), but 
I'm at a loss on how to analyze things further except for randomly 
reordering my models which seems a bit silly. 8( 

Thanks in advance for any pointers, 

Uwe

-- 
You received this message because you are subscribed to the Google Groups 
"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/6d0a3eee-fa06-4ba4-b8ac-5447c073e830%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Authenticating from a mysql database

2011-05-24 Thread Uwe Schuerkamp


On 24 Mai, 00:17, Jonas Geiregat  wrote:

> > In case I'd decide to migrate the existing users over to the new
> > database, how could I make sure the passwords end up in django
> > correctly? All I have is the old_password()-crypted user passwords,
> > can I simply insert those as values into the auth_user db field?
>
> That might be one of the bigger things to overcome.
>
> In order to succeed you must find out how django stores passwords and how 
> your current passwords are stored.
> That way you can start converting , probably by writing some python 
> conversion script.
> You can find out more on how django stores it's passwords 
> herehttp://docs.djangoproject.com/en/dev/topics/auth/#passwords

I think I may have found a solution by simply comparing the password
the user enters to the result of the old_password() function in mysql,
and if that matches I can store the password in the auth_user table
using the set_password() call which will convert the hash to "modern"
django standards.

Once I call save() on the new user object, the user should be found in
django's auth_user table from then on, correct? I've already managed
to connect to the old database using django's multiple dababase
feature and some raw() sql queries on the old user table.



All the best, Uwe

-- 
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: Authenticating from a mysql database

2011-05-23 Thread Uwe Schuerkamp
Hello Jonas,

thanks again for your reply. I think migrating the database over to
django may be a good idea, however it's still being used as a legacy
authentication database for other projects.

In case I'd decide to migrate the existing users over to the new
database, how could I make sure the passwords end up in django
correctly? All I have is the old_password()-crypted user passwords,
can I simply insert those as values into the auth_user db field?

All the best, Uwe

-- 
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: Authenticating from a mysql database

2011-05-23 Thread Uwe Schuerkamp
Thanks much for your reply Jonas, I'll give it a try later.

SimpleUserFolder is a Zope "Product" that allows for authentication
via other mechanisms than Zope's built-in user management. I'm sure
there is a way to bend Django around the database tables in some way,
but as i've never tried that before I thought it a good idea to ask
the experts first.

The database table is called "users" and has, among others, the
following columns:

mysql> desc users;
+-++--+-
+---++
| Field   | Type   | Null | Key |
Default   | Extra  |
+-++--+-
+---++
| user_id | int(11)| NO   | PRI |
NULL  | auto_increment |
| login   | varchar(16)| NO   | UNI
|   ||
| name| varchar(80)| NO   | MUL
|   ||
| password| varchar(16)| YES  | |
NULL  ||
| role| set('Manager','User','Driver') | YES  | MUL |
Driver||

The password is encrypted using mysql's password() function, but I
guess that would not pose too much of a problem, right?

All the best, Uwe


On 23 Mai, 00:16, Jonas Geiregat <jo...@geiregat.org> wrote:
> Hello,
>
> I've never worked with Zope so SompleUserFolder doesn't ring a bell.
> I'm assuming it's a database table name.
>
> You can always extend the default user's profile.
>
> This is done by creating a class , most people use UserProfile
>
> class UserProfile(models.Model):
>         user = models.ForeignKey(User, unique=True, related_name='profile')
>         #your fields that point to your SimpleUserFolder
>
> Then add the following to your settings.py file to let django use your class
>
> AUTH_PROFILE_MODULE = 'accounts.UserProfile' # assuming you have created a 
> accounts application
>
> Op 22-mei-2011, om 17:31 heeft Uwe Schuerkamp het volgende geschreven:
>
>
>
>
>
>
>
>
>
> > Hi folks,
>
> > I'm in the process of migrating (or re-designing for that matter) a
> > Zope-based user database /ranking system over to Django with roughly
> > 30,000 accounts in it. The Zope instance uses SimpleUserFolder for
> > authentication, so I was wondering if there is a way to authenticate
> > django users from within the existing mysql database.
>
> > Would it be possible to extract roles information from the user table
> > as well?
>
> > Thanks in advance for any ideas,
>
> > Uwe
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> Jonas Geiregat
> jo...@geiregat.org

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



Authenticating from a mysql database

2011-05-22 Thread Uwe Schuerkamp
Hi folks,

I'm in the process of migrating (or re-designing for that matter) a
Zope-based user database /ranking system over to Django with roughly
30,000 accounts in it. The Zope instance uses SimpleUserFolder for
authentication, so I was wondering if there is a way to authenticate
django users from within the existing mysql database.

Would it be possible to extract roles information from the user table
as well?

Thanks in advance for any ideas,

Uwe

-- 
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 selecting a distinct set of values from a queryset

2010-09-19 Thread Uwe Schuerkamp
Sorry to follow up on my own drivel, but I think I've found a solution
in the fine django docs:

obs =
Observation.objects.filter(observer=o.id,location__location_area__area_country__country_abbrev=country_code).values("bird_id").annotate(Count("bird"))

seems to do the job nicely for all combinations of areas, countries
and so on. The key seems to be the usage of the Count() aggregate
function.

Thanks for listening,

Uwe

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



Need help selecting a distinct set of values from a queryset

2010-09-19 Thread Uwe Schuerkamp
Hi folks,

some of you may remember I'm working on a site for birders where they
can enter and keep track of their observations of various birds.

Multiple viewings of a species can be entered at different observation
locations, so for the ranking page (which considers only the number of
distinct species), I need to find the set of observed species with
multiple viewing dropped from the set.

I've tried something like this:

birds_observed = {}
for o in observations:
   birds_observed[o.bird.id] = 1

number_of observations = len(birds_observed)

and then repeat that loop for every observer in the database. Using
the excellent debug snippet from djangosnippets.org, I've found this
creates about 3,000  sql queries total on the database of the form

select bird_id from club300_birds where .

for each and every observation in the above set, rinse and repeat for
every observer being ranked.

My question: Is it possible to have Django select the distinct()
bird_ids from a set of observations for a given observer?

I've tried using raw SQL queries, but it feels and looks like a hack
and a definite break of the DRY principle, and usage of the django
distinct() query function sadly eludes me.

Thanks in advance for your comments,

Uwe

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



Re: How to create navigation urls in an intelligent manner

2010-08-26 Thread Uwe Schuerkamp
On 26 Aug., 17:08, bruno desthuilliers 
wrote:
> > So would it be possible to access the request.path property from
> > within a custom template tag?
>
> Of course, as long as
> 1/ you pass it explicitely or
> 2/ the request.path is available in the context passed to the tag's
> render() method.
>
> You may want to have a look at context_processors and ContextRequest
> in the fine manual.

Hello Bruno,

thanks for your answer. I'm already using a custom context_processor
(yay! ;-), so I'll follow that suggestion, too. I've tried wrapping my
head around the process_view function, but I'm not exactly clear on
how it works just yet. So juet for laffs, I wrote my first custom
template tag (another yay! ;-) and it does the job nicely:

# snip snip
from django import template
import re
area_pattern=re.compile(r"/(?P[a-z]{2})/(?P[a-
z]{2,3})/")
country_pattern=re.compile(r"/(?P[a-z]{2})/")
register = template.Library()
def pathfinder(request):
result = area_pattern.match(request.path)
if result:
return result.group()[:-1]

result = country_pattern.match(request.path)
if result:
return result.group()[:-1]

return ""

register.simple_tag(pathfinder)

### snip snip

so now in my navigation bar (actually it's just a table ), I can
employ the following syntax:

 add observation

and the URL will change according to the path via which I'm accessing
the view.

It's probably not a good idea to have google groups archive this ugly
hack with my name on it, but right now it seems to do the job nicely.
Storing the data in the request object also seems like a great idea,
I'll certainly look into that! Of course you're right about having to
change two spots in case I ever decide to redesign my URL's, so a
refactoring is in order!

All the best,

Uwe

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



Re: How to create navigation urls in an intelligent manner

2010-08-26 Thread Uwe Schuerkamp
On 26 Aug., 15:56, joconnell  wrote:
> Hi Uwe,
>
> You might be able to leverage the 'url' template tag which comes with
> django?
>

Hi John & Bruno,

thanks for your answer.

I've looked at the url tag, but sadly it doesn't help me with
customizing the url's in the left navigation. The idea is that those
url's should change according to the URL of the page, so the
add_observation view (which accepts those parrameters you mention,
btw ;-) can change from

/add_observation
/de/add_observation
/de/hf/add_observation

and so should all others like location_ranking (a ranking of locations
where birds have been observed), observer_ranking (rankings of
observers and so on.

I think right now it would be easiest to add a custom tag called
"pathfinder" someting similar which does the following:

- check if request.path matches a /??/???/ pattern (/country_code/
aread_code/)
- check if it matches /??/ (just country_code)
- or none of the above, and according to what matched, return a simple
string I can prepend to the {% url club300.views.add_observation %}
for instance.

The URL pattern won't exceed two levels of "area designation" as I'll
be using iso country codes and 3-letter codes for the areas in a
country (german car number plates come in handy as they also represent
the districts I'm interesting in ranking).

So would it be possible to access the request.path property from
within a custom template tag?

All the best & thanks again for your guidance,

Uwe

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



Re: How to create navigation urls in an intelligent manner

2010-08-26 Thread Uwe Schuerkamp
Thanks Bruno,

I'll look into the custom template tags you mentioned. I had no idea
when I started out with this project that I'd be knee deep into
advanced django after a couple of weeks ;-)

BTW, can you recommend the "pro django" book?

All the best & thanks again for your help,
Uwe

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



How to create navigation urls in an intelligent manner

2010-08-25 Thread Uwe Schuerkamp
Hi folks,

this posting sort of refers to my previous problem from last week as
I'm still working on the birdwatcher's site. I cannot wrap my head
around how to create intelligent navigation links from the current
context or http request. For instance, if the user enters via the url

/de/observers/ranking

for a germany wide ranking display or even

/de/hf/observers/ranking

I need to find an elegant way to render the navigation links to the
other site functions like "ranking by location"," add a new
observation" and so on which should look like this, depending on the
URL above:

/de/observations/add

to add an observation that will limit the list of locations to those
in "de"  or maybe

/de/hf/observations/add

to add an observation for the hf district.

I've played around with including
django.core.context_processors.request in my processors list which
results in the request.path variable being available, but I somehow
refuse to believe that this problem hasn't been solved before in some
clever, django-ish way.

Thanks much in advance for any help or input,

Uwe

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



Re: Need some help with URL layout

2010-08-22 Thread Uwe Schuerkamp
Hi folks,

one more thing: In order to allow chaning of countries / regions, I
was thinking of adding a bit of html to the top of each page where a
user can select the country in the first popup, then the region popup
populates (pun intended ;-) the the regions for the selected country,
and one "submit" button that sets the new area of interest.

Naturally, all of the navigation urts on the left side of the page
would have to change as well, say from ranking/gr/ back to ranking/def/
hf/

How could that be accomplished? My Javascript-Fu is rather weak, and
I'd like to keep the mechanisms on the pages as simple as possible.

All the best & thanks again in advance for your comments & ideas,

Uwe

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



Re: Need some help with URL layout

2010-08-21 Thread Uwe Schuerkamp
thanks for your comments guys, I guess I'm more or less on the right
track!

All the best,

Uwe

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



Need some help with URL layout

2010-08-21 Thread Uwe Schuerkamp
Hi folks,

please excuse this long-winded post, but I'm a bit stuck with the
layout of my urls.py. Let me try to explain what the site I'm using
Django for does at the moment: Basically it's a website where local
birdwatchers (the ones with feathers, not boobies ;-) can log their
observations. By "local", I mean the local district of Herford.

Noiw after several months of the site being live, I keep getting
requests from users to widen the site's scope to all of Germany or
even world-wide, which I think is a rather nice idea. So right now the
entire site lives under a common URL called "ranking", so I thought I
could restrict and calculate local and nationwide rankings using the
following URL structure:

ranking/de/hf   Country: Germany, District: Herford (I'll be using
german number plates here to discriminate among districts
/ranking/de/_ALL Nation-Wide Ranking for Germany
/ranking/gr/agnAgios Nikolaos, Greece: Ranking of observers in
Agios Nik. on Crete, Greece
/ranking/_ALL/_ALL  world-wide ranking

I hope you get the idea.

Ideally, I'd use the url structure to restrict the list of birds,
observations, observers and region by whatever the user provides in
the request.

I've read about mappings that you can use to pass parameters into
functions in urls.py (for instance, {"region": "_ALL"} if only a
country code is provided in the URL), but of course that means I have
to check those parameters in each and every view I write, filter()ing
and excluding within the view as I retrieve the applicable objects
from the database, which seems rather cumbersome and probably breaks
the DRY principle in a big way.

So here's my question as a relative Django noob: Is this the best way
to go about such a layout, or am I missing some critical feature
Django provides already and that I just don't know about yet? I've
read the Definite Guide to Django Book front to back FWIW.

All the best & thanks in advance for your comments & ideas,

Uwe

PS: The site in question is available at http://www.birders-hf.de/ranking/
just in case you want to check it out.

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