Re: Any benefit in storing shorter strings or numbers to represent data for a choice char field?

2014-12-17 Thread Radomir Wojcik
the data up into more models at the time. I would use something like haystack with elasticsearch to index the human readable names if I needed them and that display function is a life saver. Thanks all. On Wednesday, 17 December 2014 11:56:08 UTC-5, Radomir Wojcik wrote: > > The official djan

Re: Any benefit in storing shorter strings or numbers to represent data for a choice char field?

2014-12-17 Thread Radomir Wojcik
> > So to answer my own question, you wouldn't use the short version in the db if > you plan to do like/contains queries on them. Correct me if I'm wrong. > > Unless I plan to use haystack later and index the human readable form later. I think I understand now, thanks -- You received this

Re: Any benefit in storing shorter strings or numbers to represent data for a choice char field?

2014-12-17 Thread Radomir Wojcik
> > Thanks for the insight, I'm on the same page as you. > > My only real concern is that I will have to use a function, such as this one to get the human readable version of the stored data, then you need to lookup the value from the dict. And if you're doing querying on that object using

Any benefit in storing shorter strings or numbers to represent data for a choice char field?

2014-12-17 Thread Radomir Wojcik
The official django doc uses this as an example (see below). Is there any point to storing 'FR' instead of 'Freshman" so the choice matches what is stored? Is it faster at all? Saves room? What about for querying the data? Then you have to lookup the symbol 'FR' in the tuple if someone wants to

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I have to run some benchmarks and see. I am using SQLite and I have heard some people say that it cannot handle concurrent transactions. From what I read it can handle some 50,000 transactions/ sec depending on your disk IO. For a small deli website I take it should be fine, even if the user

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
Hey Kamil, Isn't that overkill though? templatetag was an easy solution but you still do a query on the locations model on each page load. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I simply added an assignment tag instead as follows: @register.assignment_tag def get_locations(): from store.models import Location locations = list(Location.objects.all()) return locations And use it like so in template {% get_locations as all_locations %} then

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I am actually thinking using some sort of templatetag now instead of passing the query each time since its used in base.html. It can return the exact html string that can be displayed in base.html. Right now I have the " locations = Location.objects.all() " passed to the template in every

Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I wanted to add location address in the menu. I have a model called locations so this is easy enough to do. But now I have to add the queryset to every view, because every view has a template that extends base.html. So do I have to add this queryset as such to every view now? locations =

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Yeah I figured that its python as per the message. I didn't know I had to add it to every source that has the chars but thanks for the tip. I was trying it out to see if the issue was related to the database encoding or not, a UTF-8 conversion on the data completely fixed my issue. This is

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
# Django settings for mandala project. # -*- coding: utf-8 -*- But django says its not declared. Where should I put 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

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Michael I already have this on top of my settings.py file all along, but djanog does not pick it up.. #django project # encoding line is 2nd in settings.py -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Thanks a bunch. Yeah when I did a full convert to UTF-8 I no longer have the issue. I still have the case sensitive login issue which came with the PostgreSQL upgrade. Do you have the same issue? Is this normal? Logging in as Rad no longer works, I have to use exact case as it is in the

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
This fixed it iconv -f ISO_8859-1 -t UTF-8 mandala.postgres.sql > mandala.postgres.utf8.sql Now it takes the accents in as utf-8. I guess it didnt' like the LATIN1 encoding mixed with UTF-8 -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Xavier , which encoding do you use for french characters with django? UTF-8 does not like *é*, But it says it exists in utf-8:U+00E9éc3 a9LATIN SMALL LETTER E WITH ACUTE http://www.utf8-chartable.de -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Xavier, what do you mean file is latin1 encoded? You lost me. By the way, one of the Non UTF-8 data that it complains about is the accent over the e in Neguac: * Néguac* New Brunswick See my error above given by psql db < file.sql -- You received this message because you are subscribed to

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
So when I changed the encoding in the sql file from LATIN1 to UTF-8 I get import errors: (1 row) ERROR: invalid byte sequence for encoding "UTF8": 0xe9 0x67 0x75 CONTEXT: COPY locations_location, line 31 setval So what encoding can I use that is safe with french accents but at the same

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
So is it normal that without adding the u' to a string that contains french accents will give the error: ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128) ? Are french characters UTF-8 Compliant? Would this insertion process not fail if the data contained within

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
MySQL would also somehow make the built in django contrib views login case insensitive, and now its case sensitive. Since it takes the request as a parameter and request.POST is immutable I will have to write my own login without using the batteries built in solution since I cannot do a

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
This must be my problem all along: *By the way, if you're using python 2, you shouldn't be using 'string' notation for character strings and should be using the u'string' one. 'string' is a binary string while u'string' is a text string. This is misleading with python 2 as there's implicit

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
> > Russ like I said before, I used COPY to get the data back in and it was > accepted by postgres with the schema it crated using django (See step 5 > below) 1) Export each table individually from MySQL into csv format. 2) Have Django re-create the models schema from django on its own. 3)

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
> > From what I read, SQLite is production grade and its the most used > database in the world.. besides the point. So other than Postgres not picking up my encoding (UTF-8 or Latin-1) , both did not work. How can I get the login to be case insensitive again? This will really be a bummer if

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Thanks Xavier, I had this at the top of my settings.py file, tried changing it to latin-1 and it didn't make a difference. # -*- coding: utf-8 -*- So right now I am using the UTF-8 database as shown above: mandala | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | The data contains

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Also getting a bunch of these too: Non-ASCII character '\xc3' in file /var/web/mandala_env/mandala/alarms/views.py on line 329, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details (views.py, line 329) Is this normal? PostgreSQL is more strict with character

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Adding the unicode u to the 'string' as such u'string' fixes the issue but now I have to add this u to every string that will potentially have a character with a french accent in it? How come MySQL didn't need this? There must be a straight forward answer to this, something that will make

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
Also why did from django.contrib.auth.views.login become case sensitive? I have users that login with User and user, in PostgreSQL this is treated as 2 different things. Using MySQL it always saw it as one.. all very frustrating. I will try SQLite tomorrow maybe instead, been up 2 days

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-22 Thread Radomir Wojcik
> > Its not a problem with the conversion process. I re-created the schema > using django syncdb and then I went table by table putting the data back in > using csv files I exported from MySQL. I took the long way to get this all > in and PostgreSQL had no problems taking my csv data as input.

Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-21 Thread Radomir Wojcik
And I tried with both UTF8 and LATIN1 database encodings, both produce the same error: List of databases Name| Owner | Encoding | Collate |Ctype| Access privileg es

Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-21 Thread Radomir Wojcik
my code worked fine up until I switched to PostgreSQL from MySQL. Now I am bombarded with these errors whenever I have french accents in my strings. My database is correctly configured with LATIN1 (as UTF8 didn't like the accents when trying to import them from MySQL, the default was UTF8). My

Re: export .csv file from database

2013-06-19 Thread Radomir Wojcik
> > this might come of use, it exports any query set to csv. I use it a lot: > > def queryset_export_csv(qs): import csv #from django.db.models.loading import get_model response = HttpResponse(mimetype='text/csv') # force download. response['Content-Disposition'] =

South not picking up changes to model, app crashes

2013-05-17 Thread Radomir Wojcik
So I created a service record model like this: class ServiceRecord(models.Model): location = models.ForeignKey(Location, related_name='service_records') created = models.DateTimeField(auto_now_add=True, null=True) modified = models.DateTimeField(auto_now=True, null=True) active =

Re: Setting up Django on GoDaddy Deluxe Shared Hosting

2013-05-10 Thread Radomir Wojcik
I was looking for the answer to this today and I wrote a tutorial on how to do this based on all the stuff I found on the net: With the economy class Linux hosting its a bit tricky. For starters you don't have root access to the site packages so you cannot install for example MySQL-Python. 1.

Re: a simple form confirmation before commit instance to database

2013-05-07 Thread Radomir Wojcik
Thanks I'll stick to simple JavaScript here. -- You received this message because you are subscribed to the Google Groups "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,

a simple form confirmation before commit instance to database

2013-05-06 Thread Radomir Wojcik
I was looking at examples using 'raise ValidationError' but I don't want to raise an error based on the value of something. I always want the user to be prompted with a "Are you sure you want to save this?" every time they hit "save" : if request.method == 'POST': form =