Re: What is different of handling character code between pure Python and Django?

2014-05-26 Thread Sugita Shinsuke
Hello Tom

I finally resolved the problem.

I used subprocess.Popen's option "shell=False"
And, make cm by list.

I resolved.

Thank you.


2014年5月8日木曜日 17時45分52秒 UTC+9 Tom Evans:
>
> On Thu, May 8, 2014 at 5:05 AM, Sugita Shinsuke 
>  
> wrote: 
> > Hello Tom Evans 
> > 
> > 
> >> plain single and double quotes - " and ', not “ and ‘. 
> > My e-mail client is Gmail web client. 
> > 
> >>What version of Python? 2.x or 3.x? 
> > Python version is 2.7.5 
> > And, Django version is 1.3.7 
>
> Django 1.3.7 is very old, it has known security holes in it and is not 
> maintained. What I talk about from here on down is not relevant for 
> 1.3 - upgrade to at least 1.6. 
>
> In Python 2, you should mark your strings as unicode if they contain 
> anything other than ascii. 
>
>   u'This is a unicode string' 
>
>  'This is a byte string' 
>
> The characters within the string should be in the encoding specified 
> for the current file. See: 
>
>
> https://docs.python.org/2/howto/unicode.html#unicode-literals-in-python-source-code
>  
>
> Unicode strings are converted to the correct encoding for your 
> environment when output (running a command "outputs" the string to the 
> shell). 
>
> So, if you want your management command to output UTF-8: 
>
> 1) Mark the strings in your program as unicode 
> 2) Mark the files containing unicode string literals to denote the 
> character encoding used by the string literals 
> 3) Ensure the environment that django is run in has the locale 
> correctly specified. 
> 4) Ensure your management command either: 
>   a) Activates a fixed language prior to outputting unicode or 
>   b) Instructs django to use locale from the environment 
>   See 
> https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales
>  
>
> Cheers 
>
> Tom 
>
> > 
> >>There was an old case to force Django to use UTF-8: 
> > I added 
> > sys.stdout = codecs.getwriter('utf-8')(sys.stdout) 
> > But, I couldn't resolve... 
> > 
> >>language that user requests (if supported and USE_i18N=True) or 
> > LANGUAGE_CODE otherwise. 
> > 
> > Both of them are True. 
> > USE_I18N = True 
> > USE_L10N = True 
> > 
> > 
> > 2014年5月8日木曜日 1時23分01秒 UTC+9 Tom Evans: 
> >> 
> >> On Sun, Apr 27, 2014 at 7:13 AM, Sugita Shinsuke  
> >> wrote: 
> >> > Hi there 
> >> > 
> >> > I’d like to run Java code via Django. 
> >> > 
> >> > The Java code, javaprogram use like below. 
> >> > 
> >> > — 
> >> > java javaprogram [text] [file_name] 
> >> > — 
> >> > 
> >> > text is parameter. multi-byte character is also okey. 
> >> > file_name is generate file name. 
> >> > 
> >> > So, I run the stand-alone Python program like below could run fine. 
> >> > — 
> >> > java_file = ‘javaprogram’ 
> >> > file_name = ‘filename’ 
> >> > text = ‘あいうえお’ #Japanese character 
> >> > java_file_path = ‘/path/to/‘ 
> >> > class_path = ‘-cp ' + java_file_path 
> >> > 
> >> > cmd = “java {0} {1} {2} {3}".format(class_path, java_file, text, 
> >> > file_name) 
> >> 
> >> What version of Python? 2.x or 3.x? 
> >> 
> >> Presumably your email client is converting plain single and double 
> >> quotes to smart quotes and backticks, and in your source code they are 
> >> plain single and double quotes - " and ', not “ and ‘. 
> >> 
> >> Django does something explicitly to force management commands to be 
> >> ascii, see here: 
> >> 
> >> 
> >> 
> https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales
>  
> >> 
> >> There was an old case to force Django to use UTF-8: 
> >> https://code.djangoproject.com/ticket/5877 
> >> 
> >> It was closed wontfix on the basis that Django respects your locale, 
> >> which it no longer does by default. There are several workarounds 
> >> listed on the first link that will restore that behaviour. Within a 
> >> view code, the rules are different, it will activate either the 
> >> language that user requests (if supported and USE_i18N=True) or 
> >> LANGUAGE_CODE otherwise. 
> >> 
> >> 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/3b2f1139-3d02-4a72-a218-4133aa5d8c38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Data + admin design problem

2014-05-26 Thread Wojtas
Hi there!
I didn't know where to ask. I'm doing Django for couple of years, and I 
encountered following problem.

I'm doing a website which manages warehouse of company which lends music 
instruments.

I have 3 types of products:
serial -> which exist only in amount of 1
countable -> which exist in many amounts, like for example jack cable - 
they don't need information which one is broken for instance, so just 
information how many can we take
*serial+countable* -> normally it doesn't matter which is which, in case 
sth is lost or broken.

I'm using of course django admin to manage the data. 

Let's call the  warehouse product Stuff
It's not a big problem to save the data and manage it, but I have some 
specific requirements for serial+countable:
1. Reserve stuff for period of time. All 3 types in specific amount ( if 
available at this time)
2. Move specific amount of items from one warehouse to another (for 
instance one serial+countable object gets broken and we need to move them 
to repair warehouse from main)
3. every serial+countable object should have own history of events + 
comment history attached to it)
4. List of items (change_list in admin) shouldn't have 5 items of 
serial+countable, just one, with listing of serial numbers and status of 
each one of them inside the edit view.


What I achieved so far:
I have models:
Stuff
Event with M2M to Stuff which is through intermediate table with extra 
count field. So I can check for two basic types of stuff how many are busy 
at this time.

So far there is no any definition of serial+countable in the models except 
for char choice field.

So there's a FK from Stuff to Warehouse model, which is not enough.

I hope my problem description is complete. 

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c5ce27d0-187a-45fb-9afd-75b5ccc1cd3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Proxy problem (permissions denied)

2014-05-26 Thread Me Sulphur
Sorry, logging in after a while. Hopefully you have solved the problem by
now. Answering just in case some one stumbles upon through Google.

The problem is not the proxy, it is that you are accessing SITE B
(localhost:*8080*) from SITE A (localhost:*8000*) from within the browser,
which is disallowed by default and can be permitted by setting appropriate
HTTP Headers. (SO
Answer
).

Alternatively you can have SITE A "play" reverse
proxyfor SITE B.


On 28 March 2014 11:46, rmu  wrote:

> Hi, I have been stuck in the same *proxy* thing. While I tried to get wfs
> point layer from geoserver in openlayers i got error in the chrome console:
>
>1. OPTIONS http://localhost:8080/geoserver/EMIS/wfs No
>'Access-Control-Allow-Origin' header is present on the requested resource.
>Origin 'http://localhost:8000' is therefore not allowed access.
>
> OpenLayers.js:1188
>
> XMLHttpRequest cannot load http://localhost:8080/geoserver/EMIS/wfs. No
> 'Access-Control-Allow-Origin' header is present on the requested resource.
> Origin 'http://localhost:8000 ' is therefore not
> allowed access.
> I believe you have solved it using GeoNodes Proxy. I am just starting
> django and Geodjango. I have few questions:
> 1. Is the Proxy an app of the GeoNode?
> a. Can I copy the Proxy folder inside by project directory and include
> it in installed apps of the settings.py file.
> 2. Would you guide me to use the proxy/view.py. How did you use it?
>
> please help me!!
> Sincerely,
> Ram Shrestha
>
> On Saturday, February 1, 2014 9:17:27 PM UTC+5:45, Gkpetrak wrote:
>>
>> Hi Me Sulphur,
>>
>> Thank you so much my friend !
>> A two weeks problem solved !!
>> The problem was the csrfmiddleware token in my POST request.
>>
>> Thank you in advance,
>> George
>>
>  --
> 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/u57bbBirVuY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f246303b-4eca-4e59-a9b7-3bcc90f6814f%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/CABSvzZD%3DLuqfEo_vHmBdg8b2HfT3DGOsRs5AXv-VpRZ_J3kz4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


OneToOne? Inheritance? Another solution for nested model relationships?

2014-05-26 Thread Daniele Procida
I've an application that's been happily running for a few years, that does this:

class Person(Model):
   # everyone's a Person

class Researcher(Model):
# a Researcher is Person who publishes research
person = models.OneToOneField(Person)

class Publication(Model):
author = models.ForeignKey(Researcher)


But this is no longer enough: now I also need to distinguish between 
Researchers who are research students and members of staff. Those who are 
students will need new fields such as "thesis_title" and "supervisors".

But, I will *still* need the Researcher class independently of the new 
ResearchStudent and ResearchStaff classes, because it's needed for 
Publication.author.

So now it might look something like this:

class Person(Model):
   # everyone's a Person

class Researcher(Model):
# a Researcher is Person who publishes research
person = models.OneToOneField(Person)

class ResearchStaff(Model):
   researcher = models.OneToOneField(Researcher)

class ResearchStudent(Model):
   researcher = models.OneToOneField(Researcher)
   supervisors = models.ManyToManyField(ResearchStaff)

class Publication(Model):
author = models.ForeignKey(Researcher)


How manageable is this going to be? Is there a better way of doing what I need 
to do, perhaps through inheritance?

Thanks,

Daniele

-- 
You received this message because you are subscribed to the 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/20140526213320.1042853662%40mail.wservices.ch.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone interested in reviewing the code of a small project - BookMarker

2014-05-26 Thread Aseem Bansal
I am using webbrowser library because this project is supposed to store 
bookmarks instead of my browser. Storing bookmarks in a app is useful only 
if there is a way to open them via the app. I was initially serving the 
bookmarks as hyperlinks but then came across a problem. Web browser's were 
not allowing me to open locally stored web pages. So I decided to open the 
webpages through webbrowser library as client viewing the page and server 
are on same machine.

Relevant discussion on this 
forum https://groups.google.com/forum/#!topic/django-users/rSqSftkl5mg

Ask in case any confusions.

On Monday, May 26, 2014 9:49:47 PM UTC+5:30, Andre Terra (airstrike) wrote:
>
> Why are you using the webbrowser library? I don't see how it makes sense..
>
>
> Cheers,
> AT
>
>
> On Mon, May 26, 2014 at 12:32 PM, Aseem Bansal 
>  > wrote:
>
>> Thanks Shmengie. I was thinking of using class based views as it was 
>> pointed in tutorial that they are better but I was not sure which ones are 
>> good here. So I decided to prioritize making it work and then go for 
>> refactoring. CSS location I will change. 
>>
>> The tutorials used include's but I didn't get the benefit of using that 
>> in a small project. I mean in a program I can think of independent units 
>> and turn them into functions but in HTML how do you go about breaking it 
>> into parts? I mean the thought process for deciding the parts. If I have 
>> many files then I can extract the common things but for a single file I am 
>> not sure how to go about that.
>>
>> Partials refers to the sub-templates. Correct?
>>
>> Custom template tags - I'll put that on my TODO list for later reading.
>>
>> On Monday, May 26, 2014 7:28:02 PM UTC+5:30, shmengie wrote:
>>>
>>> Looks like you're getting a handle on django.
>>> You're not using Class Based Views, but you import generic.  Since 
>>> you're getting familiar with django, you *might* want to hold off on 
>>> delving into CBVs.  They're very powerful and can reduce coding, but can be 
>>> difficult to wrap your head around.  
>>>
>>> Once you've created your app with functions, then perhaps go back and 
>>> wrap 'em in CBV's.  CBV's have a lot of power, but while learning the 
>>> basics, sticking with functions can be a lot less assimilate all at once.
>>>
>>> In your template, you have CSS at the bottom. CSS is typically linked in 
>>> the  section.  I suppose most web browsers today are okay 
>>> either way.  Javascript/jquery is typically near the end of the html, as 
>>> you have it.
>>>
>>> I wish w3c/html5 spec'd tags for  and  
>>> locations.  Javascript more than css links seem feel sloppy to me, ahh 
>>> well, it is what it is.
>>>
>>> Next, I suspect you might want to work on a base.html and working with 
>>> {{include's}}.  It's a fairly easy concept to grasp and some of the beauty 
>>> of django's templating.  I wouldn't recommend delving into custom template 
>>> tags yet, but it's good to know they exist.
>>>
>>> You're template is not complex, being familiar with partials is an easy 
>>> way to keep it *simpler.*
>>>
>>> -Joe
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/33c0987a-9edb-42dc-b37a-28c6273d2253%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/44ba1e07-457c-40b7-b205-c179bf9de010%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


A bug found when bad file paths

2014-05-26 Thread Gox Dávalos Camarena
I downloaded django 1.6.5 and tried to migrate an old application (from 
Django 1.3).

Then when i go into the admin i got an error (see the image error2.jpg). As 
you can see, there is impossible to figure out what can be the reason of 
the problem.

Then I tried to replicate in my old environment I finally i replicate it 
(see the image error1.jpg). It helped me to see that the problem was 
because my MEDIA_ROOT doesn't have "/" at the end.

So I added the "/" on my updated application and it worked,

I think this is an error of django 1.6, not sure if it occurs on 1.5 but i 
open this discussion for developers.

-- 
You received this message because you are subscribed to the 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/a2c897fc-be70-4e56-8029-824f40a23c75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone interested in reviewing the code of a small project - BookMarker

2014-05-26 Thread Andre Terra
Why are you using the webbrowser library? I don't see how it makes sense..


Cheers,
AT


On Mon, May 26, 2014 at 12:32 PM, Aseem Bansal  wrote:

> Thanks Shmengie. I was thinking of using class based views as it was
> pointed in tutorial that they are better but I was not sure which ones are
> good here. So I decided to prioritize making it work and then go for
> refactoring. CSS location I will change.
>
> The tutorials used include's but I didn't get the benefit of using that in
> a small project. I mean in a program I can think of independent units and
> turn them into functions but in HTML how do you go about breaking it into
> parts? I mean the thought process for deciding the parts. If I have many
> files then I can extract the common things but for a single file I am not
> sure how to go about that.
>
> Partials refers to the sub-templates. Correct?
>
> Custom template tags - I'll put that on my TODO list for later reading.
>
> On Monday, May 26, 2014 7:28:02 PM UTC+5:30, shmengie wrote:
>>
>> Looks like you're getting a handle on django.
>> You're not using Class Based Views, but you import generic.  Since you're
>> getting familiar with django, you *might* want to hold off on delving into
>> CBVs.  They're very powerful and can reduce coding, but can be difficult to
>> wrap your head around.
>>
>> Once you've created your app with functions, then perhaps go back and
>> wrap 'em in CBV's.  CBV's have a lot of power, but while learning the
>> basics, sticking with functions can be a lot less assimilate all at once.
>>
>> In your template, you have CSS at the bottom. CSS is typically linked in
>> the  section.  I suppose most web browsers today are okay
>> either way.  Javascript/jquery is typically near the end of the html, as
>> you have it.
>>
>> I wish w3c/html5 spec'd tags for  and 
>> locations.  Javascript more than css links seem feel sloppy to me, ahh
>> well, it is what it is.
>>
>> Next, I suspect you might want to work on a base.html and working with
>> {{include's}}.  It's a fairly easy concept to grasp and some of the beauty
>> of django's templating.  I wouldn't recommend delving into custom template
>> tags yet, but it's good to know they exist.
>>
>> You're template is not complex, being familiar with partials is an easy
>> way to keep it *simpler.*
>>
>> -Joe
>>
>  --
> You received this message because you are subscribed to the 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/33c0987a-9edb-42dc-b37a-28c6273d2253%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/CAKBiv3zcZRBjCQGy%3D_9FO0pu%2BKDOb_0n%2BRrkGB44byEYx8u_ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone interested in reviewing the code of a small project - BookMarker

2014-05-26 Thread Aseem Bansal
Thanks Shmengie. I was thinking of using class based views as it was 
pointed in tutorial that they are better but I was not sure which ones are 
good here. So I decided to prioritize making it work and then go for 
refactoring. CSS location I will change. 

The tutorials used include's but I didn't get the benefit of using that in 
a small project. I mean in a program I can think of independent units and 
turn them into functions but in HTML how do you go about breaking it into 
parts? I mean the thought process for deciding the parts. If I have many 
files then I can extract the common things but for a single file I am not 
sure how to go about that.

Partials refers to the sub-templates. Correct?

Custom template tags - I'll put that on my TODO list for later reading.

On Monday, May 26, 2014 7:28:02 PM UTC+5:30, shmengie wrote:
>
> Looks like you're getting a handle on django.
> You're not using Class Based Views, but you import generic.  Since you're 
> getting familiar with django, you *might* want to hold off on delving into 
> CBVs.  They're very powerful and can reduce coding, but can be difficult to 
> wrap your head around.  
>
> Once you've created your app with functions, then perhaps go back and wrap 
> 'em in CBV's.  CBV's have a lot of power, but while learning the basics, 
> sticking with functions can be a lot less assimilate all at once.
>
> In your template, you have CSS at the bottom. CSS is typically linked in 
> the  section.  I suppose most web browsers today are okay 
> either way.  Javascript/jquery is typically near the end of the html, as 
> you have it.
>
> I wish w3c/html5 spec'd tags for  and  
> locations.  Javascript more than css links seem feel sloppy to me, ahh 
> well, it is what it is.
>
> Next, I suspect you might want to work on a base.html and working with 
> {{include's}}.  It's a fairly easy concept to grasp and some of the beauty 
> of django's templating.  I wouldn't recommend delving into custom template 
> tags yet, but it's good to know they exist.
>
> You're template is not complex, being familiar with partials is an easy 
> way to keep it *simpler.*
>
> -Joe
>

-- 
You received this message because you are subscribed to the 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/33c0987a-9edb-42dc-b37a-28c6273d2253%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why I change url is showing other user's data?

2014-05-26 Thread Andromeda Yelton
The urlpattern is telling your view (I assume a subclass of UpdateView?)
which instance of your User model to edit, but that's all the urlpattern
gets you - there's nothing built in about permissions. You need to write
permission restrictions yourself.

There's a whole bunch of ways you can do this. Something I've done:

from django.core.exceptions import PermissionDenied

[...]

class UserUpdateView(UpdateView):
[...]

def dispatch(self, request, *args, **kwargs):
if not self.request.user == self.object:
raise PermissionDenied
super(UserUpdateView, self).dispatch(request, *args, **kwargs)

I can think of a couple other things you might try and I don't know what's
most stylish, but that'll work.

Andromeda Yelton
LITA Board of Directors, Director-at-Large, 2013-2016
http://andromedayelton.com
@ThatAndromeda


On Sat, May 24, 2014 at 7:21 PM, Carlos Perche  wrote:

> for exemple, I have following url:
> http://tenant.com:8000/accounts/test1/edit/
>
> when my user right authenticated is test1, but if I change the url to
> http://tenant.com:8000/accounts/admin/edit/, the data of user admin is
> showing in profile form and if I change and save this form the admin's data
> is update.
>
> test1 is a simple user, no superuser nor staff, but have object permission
> for save, delete, change and view profile
>
> how do I protect the other user's data?
>
> sorry my english
>
> --
> You received this message because you are subscribed to the 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/8025d812-6b2f-4a60-8538-6ea060b0fa34%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/CAFE1XCb3TzbjCQYo%2Bt_trECmsknyirxCpyOByKZjmb1svH_RHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone interested in reviewing the code of a small project - BookMarker

2014-05-26 Thread shmengie
Looks like you're getting a handle on django.
You're not using Class Based Views, but you import generic.  Since you're 
getting familiar with django, you *might* want to hold off on delving into 
CBVs.  They're very powerful and can reduce coding, but can be difficult to 
wrap your head around.  

Once you've created your app with functions, then perhaps go back and wrap 
'em in CBV's.  CBV's have a lot of power, but while learning the basics, 
sticking with functions can be a lot less assimilate all at once.

In your template, you have CSS at the bottom. CSS is typically linked in 
the  section.  I suppose most web browsers today are okay 
either way.  Javascript/jquery is typically near the end of the html, as 
you have it.

I wish w3c/html5 spec'd tags for  and  
locations.  Javascript more than css links seem feel sloppy to me, ahh 
well, it is what it is.

Next, I suspect you might want to work on a base.html and working with 
{{include's}}.  It's a fairly easy concept to grasp and some of the beauty 
of django's templating.  I wouldn't recommend delving into custom template 
tags yet, but it's good to know they exist.

You're template is not complex, being familiar with partials is an easy way 
to keep it *simpler.*

-Joe

-- 
You received this message because you are subscribed to the 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/d5999370-00bb-4bd8-8982-59dab7eb3630%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread hito koto
Hi, WongoBongo,

Thanks



2014年5月26日月曜日 18時39分20秒 UTC+9 WongoBongo:
>
> If you want all the user_name's in Staff as UTF-8:
>
> staff = Staff.objects.all()
> staff_list = [s.user_name.encode('utf-8') for s in staff]
>
> I'm not familiar with the encoding you mentioned in your last message. Try 
> it.
>
> K
>
>
> On Monday, May 26, 2014 2:12:14 AM UTC-7, hito koto wrote:
>>
>> Hi,
>>
>> this is output the one name, but i want to output all name, so i can't 
>> logic  
>> >>> name[0].encode("Shift_JIS")
>>
>>
>>

-- 
You received this message because you are subscribed to the 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/4fac97e5-a4c5-4696-861a-46319d977cad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: ASP .NET web service and Django

2014-05-26 Thread Ilya Kazakevich
Hello,

For web services (I believe you speak about SOAP web services) check:
* https://wiki.python.org/moin/WebServices (SOAP section). It has info about 
Python SOAP client and server libraries.
* For .NET (client) : 
http://stackoverflow.com/questions/1302525/how-to-use-a-wsdl

Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"

>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Ariel Calzada
>Sent: Sunday, May 25, 2014 1:48 AM
>To: django-users@googlegroups.com
>Subject: ASP .NET web service and Django
>
>hi
>
>.net -> django you should look tastypie
>
>django -> asp you should use python library named request
>
>regards fron colombia
>
>El sábado, 24 de mayo de 2014, shar100101  > escribió:
>
>
>   Hi,
>
>   How to create and send HTTP request from ASP .NET web service with POST
>data in it, to Django, and get HTTP responce from Django to web service ? Does
>anyone have a simple example of this?
>
>   Regards,
>   Dušan
>
>
>
>
>   --
>   You received this message because you are subscribed to the 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/a1c1aaf2-6dd9-4cf8-9131-b45
>4d8dcf548%40googlegroups.com
>54d8dcf548%40googlegroups.com?utm_medium=email_source=footer> .
>   For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>--
>
>Ariel Calzada
>Homepage: http://www.000paradox000.co
>Blog: http://blog.000paradox000.co
>
>
>La Salvaje Esperanza
>
>Éramos dioses y nos volvieron esclavos.
>Éramos hijos del sol y nos consolaron
>con medallas de lata.
>Éramos poetas y nos pusieron a recitar
>oraciones pordioseras.
>Éramos felices y nos civilizaron.
>Quién refrescará la memoria de la tribu.
>Quién revivirá nuestros dioses.
>Que la salvaje esperanza siempre sea tuya, querida alma inamansable.
>
>-Gonzalo Arango-
>
>
>--
>You received this message because you are subscribed to the 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/CACVFg4vgj1jqLUKdqqjwnA3A
>t8DS-KkEptu2ceZMufjpRhuyXA%40mail.gmail.com
>At8DS-KkEptu2ceZMufjpRhuyXA%40mail.gmail.com?utm_medium=email_
>source=footer> .
>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/00a201cf78d6%2451691790%24f43b46b0%24%40JetBrains.com.
For more options, visit https://groups.google.com/d/optout.


Re: ASP .NET web service and Django

2014-05-26 Thread Jani Tiainen
You might be interested in suds library, it's basically lightweight SOAP stuff, 
it may work or it may not.
All depends quality of WSDL you do have.

And to my knowledge getting Django to run on IronPython requires some
hacks...

On Mon, 26 May 2014 04:09:19 -0700 (PDT)
shar100101  wrote:

> Unfortunately Tastypie is not solution for me, because it uses Rest. I am 
> using IronPython to run website and I still have not found solution to read 
> Soap/Rest requests with IronPython.
> 
> I was hoping that output form .Net service, sent using HTTP, can be used in 
> Django. I tried using WebRequest class but it didn't work.
> 
> -- 
> You received this message because you are subscribed to the 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/091eda56-74a2-4b41-aa15-4f9a0c465daa%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/20140526141936.7140a546%40jns42-l.w2k.keypro.fi.
For more options, visit https://groups.google.com/d/optout.


Re: ASP .NET web service and Django

2014-05-26 Thread shar100101
Unfortunately Tastypie is not solution for me, because it uses Rest. I am 
using IronPython to run website and I still have not found solution to read 
Soap/Rest requests with IronPython.

I was hoping that output form .Net service, sent using HTTP, can be used in 
Django. I tried using WebRequest class but it didn't work.

-- 
You received this message because you are subscribed to the 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/091eda56-74a2-4b41-aa15-4f9a0c465daa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
If you want all the user_name's in Staff as UTF-8:

staff = Staff.objects.all()
staff_list = [s.user_name.encode('utf-8') for s in staff]

I'm not familiar with the encoding you mentioned in your last message. Try 
it.

K


On Monday, May 26, 2014 2:12:14 AM UTC-7, hito koto wrote:
>
> Hi,
>
> this is output the one name, but i want to output all name, so i can't 
> logic  
> >>> name[0].encode("Shift_JIS")
>
>
>

-- 
You received this message because you are subscribed to the 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/fe86810b-f9bf-45ae-bd04-7bedede31a12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
Okay, I re-read your first post. You said that you wanted to get a UTF-8 
string.

name = [name.encode("utf8") for name in Staff.objects.filter(id = 
3).values_list('user_name', flat=True)]

This variable 'name' now contains a UTF-8 encoded string in a list-like 
object.

Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> name = ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>>> print name[0]
哈斯朝魯
>>>

Copy and paste the code. Don't retype it.

K


On Sunday, May 25, 2014 11:34:12 PM UTC-7, hito koto wrote:
>
> Hi,
> I have this:
> >>> x = name
> >>> import locale
> >>> locale.getdefaultlocale()[1]
> 'UTF8'
> >>> print x
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>
> after i try this :
>
> >>> name
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
> >>> type(name)
> 
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'list' object has no attribute 'decode'
>
>
>
>
>
>
>
> 2014年5月26日月曜日 15時26分03秒 UTC+9 WongoBongo:
>>
>> Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
>> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> x = u'\u54c8\u65af\u671d\u9b6f'
>> >>> print(x)
>> 哈斯朝魯
>> >>> import locale
>> >>> locale.getdefaultlocale()[1]
>> 'UTF-8'
>> >>>
>>
>> K
>>
>> On Sunday, May 25, 2014 10:24:36 PM UTC-7, hito koto wrote:
>>>
>>> Hi, 
>>>
>>> I'm try tha's but results:
>>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>>> u'\u54c8\u65af\u671d\u9b6f'
>>>
>>>
>>>
>>>
>>> 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo:

 Python 3.4.0 (default, Mar 20 2014, 12:50:31) 
 [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.

 >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
 '哈斯朝魯'

 K

 On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto wrote:
>
> Hi,
>
> I7m try that's this time not the error but output the  
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>
>
>
>
>
>
> 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo:
>>
>> Try
>>
>> name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>> 3).values_list('user_name', *flat=True*)]
>>
>> The other returns one-tuples in a list
>>
>>
>> https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list
>>
>> K
>>
>> On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>>>
>>> Hi,
>>> I want to encode in utf8 but don't know how can i to ?
>>>
>>> i have the errors is here:
>>>
>>> AttributeError: 'tuple' object has no attribute 'encode'
>>>
>>> My code is here :
>>>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>>> 3).values_list('user_name')]
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the 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/2e276f07-ea2e-42a8-afac-96d1e492709c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread hito koto
Hi,
I have this:
>>> x = name
>>> import locale
>>> locale.getdefaultlocale()[1]
'UTF8'
>>> print x
['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']

after i try this :

>>> name
['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>>> type(name)


Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'list' object has no attribute 'decode'







2014年5月26日月曜日 15時26分03秒 UTC+9 WongoBongo:
>
> Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> x = u'\u54c8\u65af\u671d\u9b6f'
> >>> print(x)
> 哈斯朝魯
> >>> import locale
> >>> locale.getdefaultlocale()[1]
> 'UTF-8'
> >>>
>
> K
>
> On Sunday, May 25, 2014 10:24:36 PM UTC-7, hito koto wrote:
>>
>> Hi, 
>>
>> I'm try tha's but results:
>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>> u'\u54c8\u65af\u671d\u9b6f'
>>
>>
>>
>>
>> 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo:
>>>
>>> Python 3.4.0 (default, Mar 20 2014, 12:50:31) 
>>> [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>>> '哈斯朝魯'
>>>
>>> K
>>>
>>> On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto wrote:

 Hi,

 I7m try that's this time not the error but output the  
 ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']






 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo:
>
> Try
>
> name = [name.encode("utf8") for name in Staff.objects.filter(id = 
> 3).values_list('user_name', *flat=True*)]
>
> The other returns one-tuples in a list
>
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list
>
> K
>
> On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>>
>> Hi,
>> I want to encode in utf8 but don't know how can i to ?
>>
>> i have the errors is here:
>>
>> AttributeError: 'tuple' object has no attribute 'encode'
>>
>> My code is here :
>>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>> 3).values_list('user_name')]
>>
>>
>>

-- 
You received this message because you are subscribed to the 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/ad8c0d7a-d04d-4a5d-a9a2-123549880a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread WongoBongo
Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = u'\u54c8\u65af\u671d\u9b6f'
>>> print(x)
哈斯朝魯
>>> import locale
>>> locale.getdefaultlocale()[1]
'UTF-8'
>>>

K

On Sunday, May 25, 2014 10:24:36 PM UTC-7, hito koto wrote:
>
> Hi, 
>
> I'm try tha's but results:
> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
> u'\u54c8\u65af\u671d\u9b6f'
>
>
>
>
> 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo:
>>
>> Python 3.4.0 (default, Mar 20 2014, 12:50:31) 
>> [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>>
>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>> '哈斯朝魯'
>>
>> K
>>
>> On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto wrote:
>>>
>>> Hi,
>>>
>>> I7m try that's this time not the error but output the  
>>> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo:

 Try

 name = [name.encode("utf8") for name in Staff.objects.filter(id = 
 3).values_list('user_name', *flat=True*)]

 The other returns one-tuples in a list

 https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list

 K

 On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>
> Hi,
> I want to encode in utf8 but don't know how can i to ?
>
> i have the errors is here:
>
> AttributeError: 'tuple' object has no attribute 'encode'
>
> My code is here :
>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
> 3).values_list('user_name')]
>
>
>

-- 
You received this message because you are subscribed to the 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/63d41af1-dc6e-4ee0-8382-bdf0ef07d1d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Column type and index not support by Django ORM - best way to alter/add them

2014-05-26 Thread graeme
I need to do the the following to Postgres tables for Django models:

1) Add a functional index
2) Have a bigserial primary key and a bigint foreign key point to it.

Given that I only want this on a single install, is there any reason not to 
just do it directly? I have found code snippets with "AutoBigInt" fields, 
but only one claims to support South and non mention Django migrations. I 
have not found anything to help with adding the index.

The best I can come up with is to directly alter the column type, and do 
the same to add the index, and write a migration to do that later IF we 
ever need more than one install - otherwise its more work that way.

Given that the primary key and the foreign keys pointing to it are unlikely 
to ever change, can I also guess that this is not likely to cause problems 
with migrations (South and the new Djnago ones in 1.7 when we upgrade) that 
change other fields of the model?

-- 
You received this message because you are subscribed to the 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/e7b6ae59-7c4e-42aa-9aca-f0181991124f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.