Re: Internationalize: Get two things to happen when you select a language: set the language and redirected to a different part of the site

2014-06-19 Thread visionary800

>
> Resolved.  The solution was staring right at me (0^0) the whole time n the 
> template language.  I figured it out upon reading further down on the 
> documents.
>

https://docs.djangoproject.com/en/1.6/topics/i18n/translation/#miscellaneous
 

-- 
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/38a740dc-eaf6-4265-8323-4500ba1fb97e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Chat application

2014-06-19 Thread Anshum Verma
I would suggest you to use Twisted along with Django. Django could serve as
MVC framework and twisted could take control of connection protocol.
On Jun 19, 2014 4:17 AM, "Pedro"  wrote:

> Hello,
>
> i'm working in a mobile app that depends of a Django server (to manage
> user data and stuff).
> This mobile app is about a social network with users interacting. It
> should have a chat system, where two or more users can send and receive
> messages and photos.
>
> I'm thinking in the best way to implement the communication and the model
> on the server. My first idea is to use a simple model with rooms and
> messages (each message belong to a room). To send messages from a client to
> the server, i think i could use http requests, like GETs and POSTs, where i
> would implement syncronization methods and stuff.
>
> Is this the best approach to solve this problem on Django?
>
>
> --
> Pedro Alves
>
> *Mestrando em Ciência da Computação*
> *Universidade Estadual de Campinas*
>
> --
> 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/CACW_pa0Dfom4Eydop5qedMMP5fbuBx-yZAUgDrhDApfewDFWbQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMPe4x1g-WKZhbbq_Eo_p--DBZq5hqHU3i1ETM0Bwx-fFeQ4sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Internationalize: Get two things to happen when you select a language: set the language and redirected to a different part of the site

2014-06-19 Thread visionary800
I am stumped.  I am not sure how to approach this.  I think its best if I 
describe what I would like to happen then I would greatly appreciate some 
recommendations.

*Imagine this...*
You go to www.mysite.com and you are presented solely with two buttons(and 
nothing else): [Enter in English] | [Enter in Spanish].  You can press 
either button and what happens next is you enter the site to a different 
page that says "Welcome" or "hola" (which ever you chose) and language is 
session is set.  I am trying to get two things to happen with one button: 
1. set the language and 2. go to a new page(all in one process).

*Background: *
Internationalization works excellent on my site once you are in the site 
and you change to another language.  I have no problems with my site when 
you are in and you change the language setting - all is good there. 
 Internationalization works but I can't combine it with an other step.

*This is a general idea of what I thought might work - Any suggestions?*
urlpatterns = patterns('',
url(
regex=r'^english/',
view = UserEnterInEnglish.asView(),
name = 'enter_english'
),
url(
regex=r'^spanish/',
view = UserEnterInSpanish.asView(),
name = 'enter_spanish'
),...

class UserEnterInEnglish(TemplateView):
'''User selects english''
'
get(self, request, *args, **kwargs):
#Step 1. Set the language
#Post to language which I do not know how to do
#Post to' name="language" value="es" action="/i18n/setlang/"
   #Step 2 Go Enter the Site
return HttpResponseRedirect('/about')

class UserEnterInSpanish(TemplateView):
'''User selects spanish''
'
get(self, request, *args, **kwargs):
#Step 1. Set the language
#Post to language which I do not know how to do
#Post to' name="language" value="es" action="/i18n/setlang/"
   #Step 2 Go Enter the Site
return HttpResponseRedirect('/about')

-- 
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/6d24dbe5-ea73-4024-9b9d-f63f63b62f7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Dying upon loop

2014-06-19 Thread G Z
my django server dies whenever i login and access the following function:

what is a better way to do what im doing. I need to loop through all of the 
vm_groups by customer id, and then loop through all of the vms and 
associate them with each other.
The code below is what i have but its not working. django just kills its 
self.

def portal(request):

query_results = Customer.objects.all()

for result in query_results:
   customer_id = Customer.objects.values('customer_id')
   
   vm_group = Vm_group.objects.filter(customer=customer_id)
   
   for result in vm_group:
  vm_group_ids = Vm_group.objects.values('vm_group_id')
  
  for result in vm_group_ids:
 vms = Vm.objects.filter(vm_group_id=vm_group_ids)


context = Context({'customer': query_results, 'vm_group': vm_group, 
'vms': vms,
})

return render(request, 'portal.html', context)

-- 
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/84cc69c3-b925-4bfb-b321-5918b5030c6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: In the Django documentation, Where can I found URLS.PY Symbol explanations?

2014-06-19 Thread Mike Dewhirst

On 20/06/2014 8:26 AM, Uzi Lumbroso wrote:

?In the Django documentation, Where can I found URLS.PY Symbol
explanations (for example: (?P[-\w]+)).  What is
... [-\w]+) matches

I couldn’t find it in the Django documentation. Thanks for the help


It is more or less plain Python rather than Django. Google for "python 
regex" or "python regular expression"


Here's one which is easy to follow ...

http://www.diveintopython.net/regular_expressions/

Good luck

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/5920ca19-42e9-43c0-8b1b-b2b1bb2acea3%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/53A36860.3000100%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


In the Django documentation, Where can I found URLS.PY Symbol explanations?

2014-06-19 Thread Uzi Lumbroso


?In the Django documentation, Where can I found URLS.PY Symbol  
explanations (for example: (?P[-\w]+)).  What is ... [-\w]+) 
matches

I couldn’t find it in the Django documentation. Thanks for the 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/5920ca19-42e9-43c0-8b1b-b2b1bb2acea3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advanced SQL Question

2014-06-19 Thread Javier Guerra Giraldez
On Thu, Jun 19, 2014 at 4:49 PM, G Z  wrote:
> how do I deal with concatenated foreign keys to form a primary key how do i
> even register that in the models.py?


i guess you mean composite keys.  if so, then no; the Django ORM
doesn't support composite primary keys.

-- 
Javier

-- 
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/CAFkDaoQ-xWC7%2B6xBt5ojFFRPMas6GYEB6O_G3WLm9%3DHZ%3D6N_Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Advanced SQL Question

2014-06-19 Thread G Z
I have a multi-level database that uses concatenated foreign keys as 
primary keys for tables. 

For example we have three tables
VMS
VM_LICENSE
LICENSES


VMS has
name 
license_id <- foreign key
vm_id <-primary key


vm_licenses has two concatenated fkeys to for a primary key of:
licenses_id fkey to licenses
vm_id   fkey to vms


licenses has:

license_id pkey
product_code


how do I deal with concatenated foreign keys to form a primary key how do i 
even register that in the models.py? 
The reason I ask is because one i need to register them and the second is 
how do i save forms based on a concatinated pk

-- 
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/2c2754db-4252-4e38-a99f-f518da50d555%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Forms.py issue with Model.py fields

2014-06-19 Thread Daniel Sears
You're using parens instead of brackets.

Change

fields = ('username', 'email', 'password')

to

fields = ['username', 'email', 'password']


On Thu, Jun 19, 2014 at 1:07 PM, G Z  wrote:

> I'm trying to write my forms.py class for editing customers but I'm
> getting some strange issues where it says the field is unknown but im
> typing it exactly how it is in the model.
>
> Forms.Py
>
> from portal.models import UserProfile, Customer
>> from django.contrib.auth.models import User
>> from django import forms
>> class UserForm(forms.ModelForm):
>> password = forms.CharField(widget=forms.PasswordInput())
>> class Meta:
>> model = User
>> fields = ('username', 'email', 'password')
>> class UserProfileForm(forms.ModelForm):
>> class Meta:
>> model = UserProfile
>> fields = ('website', 'picture')
>>
>>
>> class ecForm(forms.ModelForm):
>> class Meta:
>> model = Customer
>> fields = ('customer_id', 'customer_name', 'inactive',)
>
>
>
> Models.Py Customer
>
> class Customer(models.Model):
>>customer_id = models.BigIntegerField(primary_key = True, editable =
>> False, db_column = 'customer_id')
>>customer_name = models.CharField(max_length = 30)
>>inactive = models.CharField(max_length = 1)
>>class Meta:
>>   managed = False
>>   db_table = 'customers'
>>   ordering = ['customer_name']
>
>
>
>>
>> Error
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/portal/37/
>> Django Version: 1.6.5
>> Python Version: 2.7.5
>> Installed Applications:
>> ('django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'portal')
>> Installed Middleware:
>> ('django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>> Traceback:
>> File
>> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in
>> get_response
>>   99. resolver_match = resolver.resolve(request.path_info)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in resolve
>>   339. sub_match = pattern.resolve(new_path)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in resolve
>>   223. return ResolverMatch(self.callback, args, kwargs,
>> self.name)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in callback
>>   230. self._callback = get_callable(self._callback_str)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py"
>> in wrapper
>>   32. result = func(*args)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in get_callable
>>   97. mod = import_module(mod_name)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py"
>> in import_module
>>   40. __import__(name)
>> File "/home/grant/workspace/Django Projects/trunk/holon/portal/views.py"
>> in 
>>   8. from portal.forms import UserForm, UserProfileForm, ecForm
>> File "/home/grant/workspace/Django Projects/trunk/holon/portal/forms.py"
>> in 
>>   18. class ecForm(forms.ModelForm):
>> File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in
>> __new__
>>   292. raise FieldError(message)
>> Exception Type: FieldError at /portal/37/
>> Exception Value: Unknown field(s) (customer_id) specified for Customer
>
> Environment:
>
>>
>
>  --
> 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/67b4c709-bb7f-48d2-b3d0-89c59068ee0f%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/CALLzXtQd0H1v4g7qqWsLNiOv

Django Forms.py issue with Model.py fields

2014-06-19 Thread G Z
I'm trying to write my forms.py class for editing customers but I'm getting 
some strange issues where it says the field is unknown but im typing it 
exactly how it is in the model.

Forms.Py

from portal.models import UserProfile, Customer
> from django.contrib.auth.models import User
> from django import forms
> class UserForm(forms.ModelForm):
> password = forms.CharField(widget=forms.PasswordInput())
> class Meta:
> model = User
> fields = ('username', 'email', 'password')
> class UserProfileForm(forms.ModelForm):
> class Meta:
> model = UserProfile
> fields = ('website', 'picture')
> 
> 
> class ecForm(forms.ModelForm):
> class Meta:
> model = Customer
> fields = ('customer_id', 'customer_name', 'inactive',)



Models.Py Customer

class Customer(models.Model):
>customer_id = models.BigIntegerField(primary_key = True, editable = 
> False, db_column = 'customer_id')
>customer_name = models.CharField(max_length = 30)
>inactive = models.CharField(max_length = 1)
>class Meta:
>   managed = False
>   db_table = 'customers'
>   ordering = ['customer_name']



>
> Error
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/portal/37/
> Django Version: 1.6.5
> Python Version: 2.7.5
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'portal')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
> in get_response
>   99. resolver_match = resolver.resolve(request.path_info)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in resolve
>   339. sub_match = pattern.resolve(new_path)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in resolve
>   223. return ResolverMatch(self.callback, args, kwargs, 
> self.name)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in callback
>   230. self._callback = get_callable(self._callback_str)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" 
> in wrapper
>   32. result = func(*args)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in get_callable
>   97. mod = import_module(mod_name)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in 
> import_module
>   40. __import__(name)
> File "/home/grant/workspace/Django Projects/trunk/holon/portal/views.py" 
> in 
>   8. from portal.forms import UserForm, UserProfileForm, ecForm
> File "/home/grant/workspace/Django Projects/trunk/holon/portal/forms.py" 
> in 
>   18. class ecForm(forms.ModelForm):
> File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in 
> __new__
>   292. raise FieldError(message)
> Exception Type: FieldError at /portal/37/
> Exception Value: Unknown field(s) (customer_id) specified for Customer

Environment:

>  

-- 
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/67b4c709-bb7f-48d2-b3d0-89c59068ee0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django View Questions

2014-06-19 Thread G Z
thansk I solved it..

On Thursday, June 19, 2014 11:02:21 AM UTC-6, G Z wrote:
>
> so I have a problem when ever I go to /manage/ it takes me to index and im 
> not sure why.
>
> Urls.py
> url(r'^', views.IndexView.as_view(), name='index'),
> url(r'^manage/$', views.ManageView.as_view(), name='manage'),
>
>
>
> Views.py
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect
> from django.contrib.auth import authenticate, login
> from django.contrib.auth.decorators import login_required
> from django.contrib.auth import logout
> from django.views import generic
> from portal.models import Customer
> from django.views.generic import TemplateView
>
> class IndexView(generic.ListView):
>   model = Customer
>   template_name = 'index.html'
>   context_object_name = 'Customer'
>
> class ManageView(TemplateView):
>   
>   template_name = 'manage.html'
>   context_object_name = 'form'
>   
>  @login_required(login_url='/manage/')
>   def my_view(request):
>  username = request.POST['username']
>  password = request.POST['password']
>  user = authenticate(username=username, password=password)
>
>  if user is not None:
> if user.is_active:
>
>login(request, user)
>return redirect('index.html' % request.path) 
> 
> else:
>   return HttpResponse("Your, Account is Disabled.")
>  
>   def logout_view(request):
>  logout(request)
>
>
> manage.html
>
> {% block content %}
>
> {% if form.errors %}
> Your username and password didn't match. Please try again.
> {% endif %}
>
> 
> {% csrf_token %}
> 
> 
> {{ form.username.label_tag }}
> {{ form.username }}
> 
> 
> {{ form.password.label_tag }}
> {{ form.password }}
> 
> 
>
> 
> 
> 
>
> {% endblock %}
>
>
>
> index.html
> {% load staticfiles %}
> 
> {% if Customer %}
> 
> {% for Customer in Customer %}
>   
>{{ Customer.customer_name }}
> {% endfor %}
> 
> {% else %}
> No customers are available.
> {% endif %}
>

-- 
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/5125b656-1bc6-4510-9dc4-7c089d748aaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django View Questions

2014-06-19 Thread C. Kirby
According to the error, you didn't try to access /manage, just the root url

On Thursday, June 19, 2014 12:08:05 PM UTC-5, G Z wrote:
>
> if i comment out the urls for #url(r'^$', views.IndexView.as_view(), 
> name='index'), it will give me an error that it cant find /manage
>
>
> Page not found (404)Request Method:GETRequest URL:http://127.0.0.1:8000/
>
> Using the URLconf defined in holon.urls, Django tried these URL patterns, 
> in this order:
>
>1. ^$ ^manage/$ [name='manage']
>2. ^portal/
>3. ^manage/$
>4. ^admin/
>
> The current URL, , didn't match any of these.
>

-- 
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/d708e5de-fb8b-423a-a201-aac51d84f6ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django View Questions

2014-06-19 Thread C. Kirby
Do you have APPEND_SLASH 
 set in 
settings? If you don't and are trying to hit register instead of register/ 
it will fail

Kirby

-- 
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/c2974ed4-eb5e-49c5-be05-d8c55b5ebb24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting initial value of a autoincrement field in the database

2014-06-19 Thread C. Kirby
You can't do it in Django directly. If you need to do it you have to go to 
your DB and use whatever functionality it supports to set an auto id start 
point.


On Thursday, June 19, 2014 12:14:17 PM UTC-5, Anurag Baidyanath wrote:
>
> I have a field in my models.py file as follows
>
> ticket_id = models.AutoField(primary_key=True)
>
> The value for the ticket_id column starts at 1. say i wanted it to start 
> from some value (say 989) . how do i accomplish this using django?
>

-- 
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/85c60deb-3332-4d91-af2d-3c098c7ea2d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django View Questions

2014-06-19 Thread G Z
I chagned it further and it is still not working 



from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from django.views import generic
from portal.models import Customer
from portal.forms import UserForm, UserProfileForm

def register(request):
# Like before, get the request's context.
context = RequestContext(request)

# A boolean value for telling the template whether the registration was 
successful.
# Set to False initially. Code changes value to True when registration 
succeeds.
registered = False

# If it's a HTTP POST, we're interested in processing form data.
if request.method == 'POST':
# Attempt to grab information from the raw form information.
# Note that we make use of both UserForm and UserProfileForm.
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)

# If the two forms are valid...
if user_form.is_valid() and profile_form.is_valid():
# Save the user's form data to the database.
user = user_form.save()

# Now we hash the password with the set_password method.
# Once hashed, we can update the user object.
user.set_password(user.password)
user.save()

# Now sort out the UserProfile instance.
# Since we need to set the user attribute ourselves, we set 
commit=False.
# This delays saving the model until we're ready to avoid 
integrity problems.
profile = profile_form.save(commit=False)
profile.user = user

# Did the user provide a profile picture?
# If so, we need to get it from the input form and put it in 
the UserProfile model.
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']

# Now we save the UserProfile model instance.
profile.save()

# Update our variable to tell the template registration was 
successful.
registered = True

# Invalid form or forms - mistakes or something else?
# Print problems to the terminal.
# They'll also be shown to the user.
else:
print user_form.errors, profile_form.errors

# Not a HTTP POST, so we render our form using two ModelForm instances.
# These forms will be blank, ready for user input.
else:
user_form = UserForm()
profile_form = UserProfileForm()

# Render the template depending on the context.
return render_to_response(
'register.html',
{'user_form': user_form, 'profile_form': profile_form, 
'registered': registered},
context)


def user_login(request):
# Like before, obtain the context for the user's request.
context = RequestContext(request)

# If the request is a HTTP POST, try to pull out the relevant 
information.
if request.method == 'POST':
# Gather the username and password provided by the user.
# This information is obtained from the login form.
username = request.POST['username']
password = request.POST['password']

# Use Django's machinery to attempt to see if the username/password
# combination is valid - a User object is returned if it is.
user = authenticate(username=username, password=password)

# If we have a User object, the details are correct.
# If None (Python's way of representing the absence of a value), no 
user
# with matching credentials was found.
if user:
# Is the account active? It could have been disabled.
if user.is_active:
# If the account is valid and active, we can log the user 
in.
# We'll send the user back to the homepage.
login(request, user)
return HttpResponseRedirect('portal.html')
else:
# An inactive account was used - no logging in!
return HttpResponse("Your Rango account is disabled.")
else:
# Bad login details were provided. So we can't log the user in.
print "Invalid login details: {0}, {1}".format(username, 
password)
return HttpResponse("Invalid login details supplied.")

# The request is not a HTTP POST, so display the login form.
# This scenario would most likely be a HTTP GET.
else:
# No context variables to pass to the template system, hence the
# blank dictionary object...
return render_to_response('login.html', {}, context)
 
def index(request):
welcome = 'Welcome to Enki-Corp!'
return render(request, 'index.html', {'welcome': welcome})




app urls.py

from django.conf.urls import patterns, url
fro

Re: Django View Questions

2014-06-19 Thread G Z
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^register/$', views.register, name='register'), # ADD NEW PATTERN!

is my new urls



from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from django.views import generic
from portal.models import Customer
from django.views.generic import TemplateView
from portal.forms import UserForm, UserProfileForm

class IndexView(generic.ListView):
  model = Customer
  template_name = 'index.html'
  context_object_name = 'Customer'
  
def register(request):
# Like before, get the request's context.
context = RequestContext(request)

# A boolean value for telling the template whether the registration was 
successful.
# Set to False initially. Code changes value to True when registration 
succeeds.
registered = False

# If it's a HTTP POST, we're interested in processing form data.
if request.method == 'POST':
# Attempt to grab information from the raw form information.
# Note that we make use of both UserForm and UserProfileForm.
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)

# If the two forms are valid...
if user_form.is_valid() and profile_form.is_valid():
# Save the user's form data to the database.
user = user_form.save()

# Now we hash the password with the set_password method.
# Once hashed, we can update the user object.
user.set_password(user.password)
user.save()

# Now sort out the UserProfile instance.
# Since we need to set the user attribute ourselves, we set 
commit=False.
# This delays saving the model until we're ready to avoid 
integrity problems.
profile = profile_form.save(commit=False)
profile.user = user

# Did the user provide a profile picture?
# If so, we need to get it from the input form and put it in 
the UserProfile model.
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']

# Now we save the UserProfile model instance.
profile.save()

# Update our variable to tell the template registration was 
successful.
registered = True

# Invalid form or forms - mistakes or something else?
# Print problems to the terminal.
# They'll also be shown to the user.
else:
print user_form.errors, profile_form.errors

# Not a HTTP POST, so we render our form using two ModelForm instances.
# These forms will be blank, ready for user input.
else:
user_form = UserForm()
profile_form = UserProfileForm()

# Render the template depending on the context.
return render_to_response(
'register.html',
{'user_form': user_form, 'profile_form': profile_form, 
'registered': registered},
context)


is my new views

it still can't find the register page if i comment out the index page, if i 
dont comment out he index page it defaults to it because it cant find the 
register page.

-- 
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/d619a398-4d0d-41b3-8364-39e5360171cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Setting initial value of a autoincrement field in the database

2014-06-19 Thread Anurag Baidyanath
I have a field in my models.py file as follows

ticket_id = models.AutoField(primary_key=True)

The value for the ticket_id column starts at 1. say i wanted it to start 
from some value (say 989) . how do i accomplish this using django?

-- 
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/5fb06f8d-f8e9-4e16-a4bf-4732487d1119%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django View Questions

2014-06-19 Thread C. Kirby
You actually have a urls error. 

Your first one: url(r'^', views.IndexView.as_view(), name='index'),
Should be: url(r'^$', views.IndexView.as_view(), name='index'),  (Note the 
$)

$ tells the url resolver to stop trying to match a url at the $. Since you 
don't have it, calls to manage/ match on the first url and never go through 
to match the second.

Kirby

On Thursday, June 19, 2014 12:02:21 PM UTC-5, G Z wrote:
>
> so I have a problem when ever I go to /manage/ it takes me to index and im 
> not sure why.
>
> Urls.py
> url(r'^', views.IndexView.as_view(), name='index'),
> url(r'^manage/$', views.ManageView.as_view(), name='manage'),
>
>
>
> Views.py
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect
> from django.contrib.auth import authenticate, login
> from django.contrib.auth.decorators import login_required
> from django.contrib.auth import logout
> from django.views import generic
> from portal.models import Customer
> from django.views.generic import TemplateView
>
> class IndexView(generic.ListView):
>   model = Customer
>   template_name = 'index.html'
>   context_object_name = 'Customer'
>
> class ManageView(TemplateView):
>   
>   template_name = 'manage.html'
>   context_object_name = 'form'
>   
>  @login_required(login_url='/manage/')
>   def my_view(request):
>  username = request.POST['username']
>  password = request.POST['password']
>  user = authenticate(username=username, password=password)
>
>  if user is not None:
> if user.is_active:
>
>login(request, user)
>return redirect('index.html' % request.path) 
> 
> else:
>   return HttpResponse("Your, Account is Disabled.")
>  
>   def logout_view(request):
>  logout(request)
>
>
> manage.html
>
> {% block content %}
>
> {% if form.errors %}
> Your username and password didn't match. Please try again.
> {% endif %}
>
> 
> {% csrf_token %}
> 
> 
> {{ form.username.label_tag }}
> {{ form.username }}
> 
> 
> {{ form.password.label_tag }}
> {{ form.password }}
> 
> 
>
> 
> 
> 
>
> {% endblock %}
>
>
>
> index.html
> {% load staticfiles %}
> 
> {% if Customer %}
> 
> {% for Customer in Customer %}
>   
>{{ Customer.customer_name }}
> {% endfor %}
> 
> {% else %}
> No customers are available.
> {% endif %}
>

-- 
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/6f1d2638-7465-4569-97d5-8e97780d4951%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django View Questions

2014-06-19 Thread G Z
if i comment out the urls for #url(r'^$', views.IndexView.as_view(), 
name='index'), it will give me an error that it cant find /manage


Page not found (404)Request Method:GETRequest URL:http://127.0.0.1:8000/

Using the URLconf defined in holon.urls, Django tried these URL patterns, 
in this order:

   1. ^$ ^manage/$ [name='manage']
   2. ^portal/
   3. ^manage/$
   4. ^admin/

The current URL, , didn't match any of these.

-- 
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/bfa75c62-9c19-4098-83bd-2f2af93f12c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django View Questions

2014-06-19 Thread G Z
so I have a problem when ever I go to /manage/ it takes me to index and im 
not sure why.

Urls.py
url(r'^', views.IndexView.as_view(), name='index'),
url(r'^manage/$', views.ManageView.as_view(), name='manage'),



Views.py

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from django.views import generic
from portal.models import Customer
from django.views.generic import TemplateView

class IndexView(generic.ListView):
  model = Customer
  template_name = 'index.html'
  context_object_name = 'Customer'

class ManageView(TemplateView):
  
  template_name = 'manage.html'
  context_object_name = 'form'
  
 @login_required(login_url='/manage/')
  def my_view(request):
 username = request.POST['username']
 password = request.POST['password']
 user = authenticate(username=username, password=password)
   
 if user is not None:
if user.is_active:
   
   login(request, user)
   return redirect('index.html' % request.path) 

else:
  return HttpResponse("Your, Account is Disabled.")
 
  def logout_view(request):
 logout(request)


manage.html

{% block content %}

{% if form.errors %}
Your username and password didn't match. Please try again.
{% endif %}


{% csrf_token %}


{{ form.username.label_tag }}
{{ form.username }}


{{ form.password.label_tag }}
{{ form.password }}







{% endblock %}



index.html
{% load staticfiles %}

{% if Customer %}

{% for Customer in Customer %}
  
   {{ Customer.customer_name }}
{% endfor %}

{% else %}
No customers are available.
{% endif %}

-- 
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/3ac31dd2-af6b-4559-8148-a33bb0911182%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-19 Thread Stodge
My problem seems to be this:

 * run custom management command
 * activate language from settings, which is "en-gb"
 * dynamically import module for a Django app and invoke custom bootstrap 
function
 * calling get_language() in bootstrap function returns "en-gb"
 * bootstrap function calls loaddata management command (using 
management.call_command)
 * data created in DB, which triggers a post_save signal
 * get_language() in post_save signal always returns "en-us"




On Wednesday, 18 June 2014 12:48:47 UTC-4, Stodge wrote:
>
> My settings for languages are:
>
> LANGUAGE_CODE = 'en'
>
> USE_I18N = True
> LANGUAGE_COOKIE_NAME='django_language'
> ugettext = lambda s: s
> LANGUAGES = (
> ('en', ugettext('English')),
> ('de', ugettext('German')),
> ('fr', ugettext('French'))
> )
>
>
> I have a post-save signal that creates instances of a model and gets the 
> current Django language. The language returned is for some reason "en-us", 
> but I have no idea where this is coming from. My default as shown above is 
> "en". get_language() is called from within a signal so the language isn't 
> being taken from a cookie or request header. Any ideas why Django thinks 
> the current (default) language is "en-us"? Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/516c568d-f964-4b90-b244-296e112e1a24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-19 Thread Stodge
No that's the code from the Django documentation.

https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales

On Thursday, 19 June 2014 09:39:34 UTC-4, Tom Evans wrote:
>
> On Thu, Jun 19, 2014 at 1:41 PM, Stodge > 
> wrote: 
> > Yes I'm aware of this thanks. However, the documentation also states 
> that I 
> > can activate a different language in my custom command: 
> > 
> > If, for some reason, your custom management command needs to use a fixed 
> > locale different from ‘en-us’, you should manually activate and 
> deactivate 
> > it in your handle() or handle_noargs() method using the functions 
> provided 
> > by the I18N support code: 
> > 
> > 
> > Using the code: 
> > 
> > # Activate a fixed locale, e.g. Russian 
> > translation.activate('ru') 
> > 
> > 
> > However, this doesn't appear to change anything. 
> > 
>
> From an earlier email, 'ru' is not an enabled language in your settings. 
>
> 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/297585e5-9e71-4d39-90d6-868dfc289bd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


gunicorn myproject.wsgi:application invalid now.

2014-06-19 Thread Jacky
I use gunicorn to deploy my project all the time, but today, in my new 
project, it raise a error.

I check here and there, google around, but it doesn't work.

Maybe there was wrong with me.

So I create a new project to test, here is all my process:

$ virtualen env
$ source env/bin/active
$ pip install django
$ pip install gunicorn
$ django-admin.py startproject test_project
$ cd test_project
$ django-admin startapp myapp
$ cd ..
$ gunicorn test_project.wsgi:application


load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()

raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: 

I'm crazy about this error... oh fk.

Any one can help me ? You r my god.

Thank you very much!

-- 
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/0995f5ec-9a24-484f--48eed234ceb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-19 Thread Tom Evans
On Thu, Jun 19, 2014 at 1:41 PM, Stodge  wrote:
> Yes I'm aware of this thanks. However, the documentation also states that I
> can activate a different language in my custom command:
>
> If, for some reason, your custom management command needs to use a fixed
> locale different from ‘en-us’, you should manually activate and deactivate
> it in your handle() or handle_noargs() method using the functions provided
> by the I18N support code:
>
>
> Using the code:
>
> # Activate a fixed locale, e.g. Russian
> translation.activate('ru')
>
>
> However, this doesn't appear to change anything.
>

>From an earlier email, 'ru' is not an enabled language in your settings.

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/CAFHbX1KwCLavc2VYxX-7T%3DPuanz5Ty3Cye0_pQLe0q6_V10nNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-19 Thread Stodge
Sorry, this is using Django 1.6.2.

On Wednesday, 18 June 2014 12:48:47 UTC-4, Stodge wrote:
>
> My settings for languages are:
>
> LANGUAGE_CODE = 'en'
>
> USE_I18N = True
> LANGUAGE_COOKIE_NAME='django_language'
> ugettext = lambda s: s
> LANGUAGES = (
> ('en', ugettext('English')),
> ('de', ugettext('German')),
> ('fr', ugettext('French'))
> )
>
>
> I have a post-save signal that creates instances of a model and gets the 
> current Django language. The language returned is for some reason "en-us", 
> but I have no idea where this is coming from. My default as shown above is 
> "en". get_language() is called from within a signal so the language isn't 
> being taken from a cookie or request header. Any ideas why Django thinks 
> the current (default) language is "en-us"? Thanks
>
>

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


Re: Database problem in Django

2014-06-19 Thread Stodge
Read the documentation:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by

On Wednesday, 18 June 2014 08:06:18 UTC-4, Ashu Singh wrote:
>
> Hello everyone. My doubt is how to fetch the recent two database entries 
> in django. User may enter into database anytime but the query should always 
> fetch last two entries. 
>

-- 
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/47930d12-fa79-4180-9139-d2601af88586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-19 Thread Stodge
Yes I'm aware of this thanks. However, the documentation also states that I 
can activate a different language in my custom command:

*If, for some reason, your custom management command needs to use a fixed 
locale different from ‘en-us’, you should manually activate and deactivate 
it in your handle() 

 or handle_noargs() 

 method 
using the functions provided by the I18N support code:*


Using the code:

# Activate a fixed locale, e.g. Russian
translation.activate('ru')


However, this doesn't appear to change anything.

On Thursday, 19 June 2014 08:38:31 UTC-4, Tom Evans wrote:
>
> On Wed, Jun 18, 2014 at 7:10 PM, Stodge > 
> wrote: 
> > By override I mean I add this at the start of my handle() function in my 
> > custom management command: 
> > 
> > from django.utils import translation 
> > translation.activate(settings.LANGUAGE_CODE) 
> > 
> > Where settings.LANGUAGE_CODE = "en-gb". 
> > 
> > Calling get_language in my custom management command still returns 
> "en-us". 
> > 
>
> In a management command, django will always set the language to "en-us": 
>
>
> https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales
>  
>
> 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/921eb300-98ca-43d8-b9a8-b23302449f11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-19 Thread Tom Evans
On Wed, Jun 18, 2014 at 7:10 PM, Stodge  wrote:
> By override I mean I add this at the start of my handle() function in my
> custom management command:
>
> from django.utils import translation
> translation.activate(settings.LANGUAGE_CODE)
>
> Where settings.LANGUAGE_CODE = "en-gb".
>
> Calling get_language in my custom management command still returns "en-us".
>

In a management command, django will always set the language to "en-us":

https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales

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/CAFHbX1KpHbTVdGCfG6UWzK6kpOk2dn%2Bm0F697gFz2N5spOjdFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Chat application

2014-06-19 Thread Cal Leeming [Simplicity Media Ltd]
+1.

You may even be able to do this using uWSGI plugins and Redis which would
be even faster.

Django is certainly not the right tool for the job for this use case though.

Cal


On Thu, Jun 19, 2014 at 2:24 AM, carlos  wrote:

> Hi, maybe not all with django, maybe you need learn gevent
> http://www.gevent.org/
> socket.io
> http://socket.io/
>  and here is example for a chat with redis and django + gevent + socketio
> etc.
> https://github.com/rlr/django-gevent-socketio-redis-chat-example
>
> Cheers
>
>
> On Wed, Jun 18, 2014 at 4:46 PM, Pedro  wrote:
>
>> Hello,
>>
>> i'm working in a mobile app that depends of a Django server (to manage
>> user data and stuff).
>> This mobile app is about a social network with users interacting. It
>> should have a chat system, where two or more users can send and receive
>> messages and photos.
>>
>> I'm thinking in the best way to implement the communication and the model
>> on the server. My first idea is to use a simple model with rooms and
>> messages (each message belong to a room). To send messages from a client to
>> the server, i think i could use http requests, like GETs and POSTs, where i
>> would implement syncronization methods and stuff.
>>
>> Is this the best approach to solve this problem on Django?
>>
>>
>> --
>> Pedro Alves
>>
>> *Mestrando em Ciência da Computação*
>> *Universidade Estadual de Campinas*
>>
>> --
>> 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/CACW_pa0Dfom4Eydop5qedMMP5fbuBx-yZAUgDrhDApfewDFWbQ%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAM-7rO0052uKjqh%3D5UEt-%2BGo1-muj3k-Yu7%2BFKjVFLCOTLi2AA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHKQagEfYnwj4ZEWL36rpPYBxjV47wkbkDD0YWvyQYzf_GKJ%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Chat application

2014-06-19 Thread Ilya Kazakevich
Hello,

You may use websockets on client and asyncio on serves as it is done here: 
https://github.com/throwable-one/chat-async/
But websockets require modern client and asyncio require python 3.4 (but 
asyncio is standard and worth using, anyway)

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 carlos
>Sent: Thursday, June 19, 2014 5:25 AM
>To: django-users@googlegroups.com
>Subject: Re: Chat application
>
>Hi, maybe not all with django, maybe you need learn gevent
>http://www.gevent.org/
>
>socket.io
>http://socket.io/
>
> and here is example for a chat with redis and django + gevent + socketio etc.
>https://github.com/rlr/django-gevent-socketio-redis-chat-example
>
>
>Cheers
>
>
>On Wed, Jun 18, 2014 at 4:46 PM, Pedro  wrote:
>
>
>   Hello,
>
>   i'm working in a mobile app that depends of a Django server (to manage
>user data and stuff).
>   This mobile app is about a social network with users interacting. It 
> should
>have a chat system, where two or more users can send and receive messages
>and photos.
>
>   I'm thinking in the best way to implement the communication and the
>model on the server. My first idea is to use a simple model with rooms and
>messages (each message belong to a room). To send messages from a client to
>the server, i think i could use http requests, like GETs and POSTs, where i 
>would
>implement syncronization methods and stuff.
>
>   Is this the best approach to solve this problem on Django?
>
>
>   --
>   Pedro Alves
>
>   Mestrando em Ciência da Computação
>   Universidade Estadual de Campinas
>
>
>
>   --
>   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/CACW_pa0Dfom4Eydop5qed
>MMP5fbuBx-yZAUgDrhDApfewDFWbQ%40mail.gmail.com
>MMP5fbuBx-yZAUgDrhDApfewDFWbQ%40mail.gmail.com?utm_medium=email
>&utm_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/CAM-7rO0052uKjqh%3D5UEt-
>%2BGo1-muj3k-Yu7%2BFKjVFLCOTLi2AA%40mail.gmail.com
>-%2BGo1-muj3k-Yu7%2BFKjVFLCOTLi2AA%40mail.gmail.com?utm_medium=ema
>il&utm_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/020301cf8b9f%2467203a60%243560af20%24%40JetBrains.com.
For more options, visit https://groups.google.com/d/optout.


Re: Change help_text of a field in a derived model

2014-06-19 Thread Vladimir Chukharev
Answering my own question. No, there is no ready way to change help_text in 
model.
The proposed solution is almost correct, just the get_form_class() function 
should
be defined both in CreateViiew- and UpdateView-derived classes and be like 
the 
following.

def get_form_class(self):
'Make a form from a class'

model = class_by_name(self.kwargs['fmname'])
form = model_forms.modelform_factory(model)

# change help_text for fields in derived class, i.e in ReSt class 
and
# derived from it
class_list = [model]
class_list.extend(model._meta.get_parent_list())
for mod in class_list:
opts = mod._meta
if hasattr(opts, 'help_texts'):
for key, value in opts.help_texts.iteritems():
form.base_fields[key].help_text = value
return form

return form

The stuff added for Meta help_texts to work is between empty lines.

-- 
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/b33a134f-b519-4fad-80a2-da4e8185794f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: PostgreSQL, queries, speed

2014-06-19 Thread Vladimir Chukharev
On Tuesday, June 17, 2014 3:42:56 AM UTC+3, Lachlan Musicman wrote:
>
> The db is hosted on the same server, it's not underpowered, and it is 
> less poorly tuned so much as untuned. 
>
>
Untuned is the same as poorly tuned when it comes to PostgreSQL. Or worse. 
Pg has defaults from last millennium... See e.g. 
http://www.revsys.com/writings/postgresql-performance.html
for simple memory limits to increase 10...100 times or more. And make sure 
that autovacuum works.

Vladimir

-- 
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/bb153c26-b212-4e0c-a04b-e308aeaa7799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.