Re: 3 table many to many relationship

2014-04-23 Thread Simon Charette
Django allows you to explicitly specify an intermediary model for 
many-to-many relationships with the 
`through`
 
option. 

class A(models.Model):
b_set = models.ManyToMany('B', related_name='a_set', through='R')
c_set = models.ManyToMany('C', related_name='a_set', through='R')

class B(models.Model):
pass

class C(models.Model):
pass

class R(models.Model):
a = models.ForeignKey('A')
b = models.ForeignKey('B')
c = models.ForeignKey('C')

However you'll loose the ability of directly adding objects to 
relationships (A().b_set.create() won't work).
You'll need to explicitly create `R` instances instead: 
R.objects.create(a=a, b=b, c=c).

Simon

Le mercredi 23 avril 2014 23:24:04 UTC-4, Malik Rumi a écrit :
>
> I was designing the models I will need for this project. I designed an 
> intermediate table for two models, A and B, and then started to sketch out 
> an intermediate table for two other models, A and C, when I realized that 
> these two intermediate tables both use A, and further, the information in 
> the second intermediate table will be a lot more valuable it if also shows 
> the relationship C has to B. 
>
> I looked at the Many to Many documentation on the official Django site, 
> but I don’t see a discussion of this three table option. I have seen it 
> elsewhere, so I assume it can be done. What I don’t assume is the impact 
> this has on performance and other issues I might not even anticipate. So, 
> my questions:
>
>Can this three sided many to many intermediate table be created in 
> Django?
>
> If it can, is it advisable, or are there better / more efficient ways 
> of doing this, like with two intermediate tables as I was originally 
> thinking?
>
> thx.
>
>

-- 
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/2e128d84-3e70-4bab-8b70-696eaaa369c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


3 table many to many relationship

2014-04-23 Thread Malik Rumi


I was designing the models I will need for this project. I designed an 
intermediate table for two models, A and B, and then started to sketch out 
an intermediate table for two other models, A and C, when I realized that 
these two intermediate tables both use A, and further, the information in 
the second intermediate table will be a lot more valuable it if also shows 
the relationship C has to B. 

I looked at the Many to Many documentation on the official Django site, but 
I don’t see a discussion of this three table option. I have seen it 
elsewhere, so I assume it can be done. What I don’t assume is the impact 
this has on performance and other issues I might not even anticipate. So, 
my questions:

   Can this three sided many to many intermediate table be created in 
Django?

If it can, is it advisable, or are there better / more efficient ways 
of doing this, like with two intermediate tables as I was originally 
thinking?

thx.

-- 
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/0dc423af-04ef-4e43-b177-720f9021d6d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-cache-machine with Redis

2014-04-23 Thread Mike Megally
Did you figure this out? I'm currently in the same situation.

On Thursday, March 28, 2013 9:56:13 PM UTC-7, Alan Johnson wrote:
>
> How does one configure this?  The documentation only explains how to use 
> locmem or memcached, and yet the commit logs reference Redis multiple 
> times, so it must be doable. Does anybody have any advice or experience 
> with this?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/e147c975-33e9-466d-81f0-8b3949330b18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ユーザー登録について

2014-04-23 Thread hito koto
Ok, Thank you very much!



曜日 7時08分05秒 UTC+9 Lachlan Musicman:
>
>
> On 23 April 2014 17:59, hito koto >wrote:
>
>> Thank you!
>> i can do create!
>>
>> Sorry! i'm don't understand create staff site,
>> i want to create  staff site , staff site should have when rogin using 
>> ID/PW and have staff profile
>> i'm realy don't know!
>>
>> pleae help me
>>
>
>
>
> So you need to create an URL that looks something like:
>
> https://URL/staff/staff_id
>
> And you want to redirect to that after login. This question has one 
> example of how to solve that problem:
>
>
> http://stackoverflow.com/questions/4870619/django-after-login-redirect-user-to-his-custom-page-mysite-com-username
>  
>
> cheers
> L.
>
>
>  
>
>>
>>
>> 2014年4月23日水曜日 16時18分44秒 UTC+9 Lachlan Musicman:
>>>
>>>
>>> On 23 April 2014 14:11, hito koto  wrote:
>>>
 Thank you very much good idea!
 i'm was try but i'm have error when create new staff !

 >>Request Method: POST  >>Request URL: http://articles/create/  >>Django 
 Version: 1.6.2  >>Exception Type: IntegrityError  >>Exception Value: 

 (1048, "Column 'user_id' cannot be null")

  >>Exception Location: /usr/lib64/python2.6/site-
 packages/MySQLdb/connections.py in defaulterrorhandler, line 36  >>Python 
 Executable: /usr/bin/python
  >>/var/www/html/article/views.py in create 

  >>   form.save()

 this is my views.py:

 def create(request):
 if request.POST:
 form = ArticleForm(request.POST)
 if form.is_valid():
 form.save()

 return HttpResponseRedirect('/articles/all')

 else:
 form = ArticleForm()
 args = {}
 args.update(csrf(request))
 args['form'] = form
 return render_to_response('create.html', args)




>>>
>>> I'm actually racing out the door, but quickly: the id field is 
>>> automatic. Your form refers to a user_id field that doesn't exist on your 
>>> model except as implied. In that case, you don't need to ask for user_id in 
>>> the form. If you want staff to have an ID_number, you should separate it 
>>> from the id (also known as the pk or primary key) field in the model class, 
>>> then query it in the form. 
>>>
>>> But as it stands, you can remove it from your form, and that should work.
>>>
>>> cheers
>>> L.
>>>
>>>
>>>
>>>  
>>>
  this is my forms.py:
 from django import forms
 from models import User,Staff, Address
 from django.contrib.auth.models import User

 class ArticleForm(forms.ModelForm):

 class Meta:
 model = User
 fields = ('user_name','first_kana', 'last_kana', 
 'employee_number','birthday')
 user_id = forms.CharField(label="id", error_messages={'required': 
 ''}, help_text='必須')
 user_name = forms.CharField(label="氏名", error_messages={'required': 
 ''}, help_text='必須')
 first_kana = 
 forms.CharField(label="ふりがな(性)",error_messages={'required': 
 ''}, help_text='必須')
 last_kana = 
 forms.CharField(label="ふりがな(名)",error_messages={'required': 
 ''}, help_text='必須')
 employee_number = forms.CharField(label="社員番号", required=False)
 birthday = forms.CharField(label="生年月日", required=False)

 class Meta:
 model = Address
 fields = ('user_name','postalcode', 'address', 
 'residence','number')
 user_name = forms.CharField(label="氏名", error_messages={'required': 
 ''}, help_text='必須')
 postalcode = forms.CharField(label="郵便番号", required=False)
 address = forms.CharField(label="住所", required=False)
 residence = forms.CharField(label="住所開始日", required=False)
 number = forms.CharField(label="電話番号", required=False)













 2014年4月23日水曜日 7時03分10秒 UTC+9 Lachlan Musicman:

> On 23 April 2014 01:52, hito koto  wrote: 
> > thank you very much 
> Each Staff can login. 
> Each staff should only see their own page or dataset. 
> > This is correct 
> > 
> > I want to create administrator page and each staff , 
> > 1, i want , Staff can see the staff page with ID and PW that an 
> > administrator has issued 
> > 2, administrator can see all the staff page and all staff's 
> information 
> > 3, each staff should only see their own page or dataset. 
> > So, i don't know how to create staff page,only see their own page, 
> > 
> > please help me 
> > 
>
>
> Ok, well first things first. You can do this through the django admin, 
> but it would be easier if you didn't. 
>
> Create a class based DetailView like such: 
>
> https://docs.djangoproject.com/en/1.7/topics/class-based-views/ 
>
> using your Staff model as the base, set up a url schema to deal with 
> it and then ad

How can I set up Debian x86_64 so a Django project sees django.contrib.staticfiles?

2014-04-23 Thread Christos Jonathan Seth Hayward
I have a new Debian VPS, and a Django project that I am trying to deploy is
not seeing django.contrib.staticfiles.*. Doing a "pip install
django-staticfiles" has not observably changed things.

What is the best way to have things running well enough that such Django
projects will run?

Thanks,


-- 
[image: Christos Jonathan Seth Hayward] 
Christos Jonathan Seth Hayward, an Orthodox Christian author.

Amazon / Kindle  • *Author
* • Author Bio 
 • *Email * •
Facebook
 • Fan Page  • Google
Plus
 • LinkedIn  • *Professional
* • Twitter
 • *Web * • What's
New?
If you read just *one* of my books, you'll want *The Best of Jonathan's
Corner *.

-- 
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/CAE6_B5SMaj3tbjbz5-JKMkhZJ%3DGLYE1-RpkxAENKVRmx_fVwZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django and Zinnia + DjangoCMS

2014-04-23 Thread Silvio Siefke
Hello, 

im not sure is allowed to ask here. I want run Django CMS, Django is 
sympa but im not a programmer so i think django cms make it easier to
run a Website. At moment i try local tests to convert my pages in this
system.

I has 2 problems with the this system. 

1.) Must i activate in settings.py the zinnia.urls or goes this automatich?
The problem is i become msg in admin interface, 

"Menu CategoryMenu cannot be loaded. Please, make sure all its urls exist 
and can be resolved. Menu TagMenu cannot be loaded. Please, make sure all 
its urls exist and can be resolved. Menu AuthorMenu cannot be loaded. 
Please, make sure all its urls exist and can be resolved."

"/var/www/dcms/python/lib/python2.7/site-packages/cms/context_processors.py:20: 
DeprecationWarning: cms.context_processors.media has been deprecated 
in favor of cms.context_processors.cms_settings. Please update your 
configuration 'configuration', DeprecationWarning)

No handlers could be found for logger "menus""

2.) When i go in user settings i become 

"TransactionManagementError at /en/admin/cms/usersettings/
Your database backend doesn't behave properly when autocommit is off. 
Turn it on before using 'atomic'." I has googled but when i fix it
with 'ATOMIC_REQUESTS': True i become 

TransactionManagementError at /en/admin/cms/usersettings/
This is forbidden when an 'atomic' block is active. 


Has someone an advice?

Django V. 1.6.3
Django CMS 3

Thank you for help & Nice Day
Silvio

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


Re: Django ユーザー登録について

2014-04-23 Thread Lachlan Musicman
On 23 April 2014 17:59, hito koto  wrote:

> Thank you!
> i can do create!
>
> Sorry! i'm don't understand create staff site,
> i want to create  staff site , staff site should have when rogin using
> ID/PW and have staff profile
> i'm realy don't know!
>
> pleae help me
>



So you need to create an URL that looks something like:

https://URL/staff/staff_id

And you want to redirect to that after login. This question has one example
of how to solve that problem:

http://stackoverflow.com/questions/4870619/django-after-login-redirect-user-to-his-custom-page-mysite-com-username

cheers
L.




>
>
> 2014年4月23日水曜日 16時18分44秒 UTC+9 Lachlan Musicman:
>>
>>
>> On 23 April 2014 14:11, hito koto  wrote:
>>
>>> Thank you very much good idea!
>>> i'm was try but i'm have error when create new staff !
>>>
>>> >>Request Method: POST  >>Request URL: http://articles/create/  >>Django
>>> Version: 1.6.2  >>Exception Type: IntegrityError  >>Exception Value:
>>>
>>> (1048, "Column 'user_id' cannot be null")
>>>
>>>  >>Exception Location: /usr/lib64/python2.6/site-
>>> packages/MySQLdb/connections.py in defaulterrorhandler, line 36  >>Python
>>> Executable: /usr/bin/python
>>>  >>/var/www/html/article/views.py in create
>>>
>>>  >>   form.save()
>>>
>>> this is my views.py:
>>>
>>> def create(request):
>>> if request.POST:
>>> form = ArticleForm(request.POST)
>>> if form.is_valid():
>>> form.save()
>>> return HttpResponseRedirect('/articles/all')
>>>
>>> else:
>>> form = ArticleForm()
>>> args = {}
>>> args.update(csrf(request))
>>> args['form'] = form
>>> return render_to_response('create.html', args)
>>>
>>>
>>>
>>>
>>
>> I'm actually racing out the door, but quickly: the id field is automatic.
>> Your form refers to a user_id field that doesn't exist on your model except
>> as implied. In that case, you don't need to ask for user_id in the form. If
>> you want staff to have an ID_number, you should separate it from the id
>> (also known as the pk or primary key) field in the model class, then query
>> it in the form.
>>
>> But as it stands, you can remove it from your form, and that should work.
>>
>> cheers
>> L.
>>
>>
>>
>>
>>
>>> this is my forms.py:
>>> from django import forms
>>> from models import User,Staff, Address
>>> from django.contrib.auth.models import User
>>>
>>> class ArticleForm(forms.ModelForm):
>>>
>>> class Meta:
>>> model = User
>>> fields = ('user_name','first_kana', 'last_kana',
>>> 'employee_number','birthday')
>>> user_id = forms.CharField(label="id", error_messages={'required':
>>> ''}, help_text='必須')
>>> user_name = forms.CharField(label="氏名", error_messages={'required':
>>> ''}, help_text='必須')
>>> first_kana = forms.CharField(label="ふりがな(性)",error_messages={'required':
>>> ''}, help_text='必須')
>>> last_kana = forms.CharField(label="ふりがな(名)",error_messages={'required':
>>> ''}, help_text='必須')
>>> employee_number = forms.CharField(label="社員番号", required=False)
>>> birthday = forms.CharField(label="生年月日", required=False)
>>>
>>> class Meta:
>>> model = Address
>>> fields = ('user_name','postalcode', 'address',
>>> 'residence','number')
>>> user_name = forms.CharField(label="氏名", error_messages={'required':
>>> ''}, help_text='必須')
>>> postalcode = forms.CharField(label="郵便番号", required=False)
>>> address = forms.CharField(label="住所", required=False)
>>> residence = forms.CharField(label="住所開始日", required=False)
>>> number = forms.CharField(label="電話番号", required=False)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2014年4月23日水曜日 7時03分10秒 UTC+9 Lachlan Musicman:
>>>
 On 23 April 2014 01:52, hito koto  wrote:
 > thank you very much
 Each Staff can login.
 Each staff should only see their own page or dataset.
 > This is correct
 >
 > I want to create administrator page and each staff ,
 > 1, i want , Staff can see the staff page with ID and PW that an
 > administrator has issued
 > 2, administrator can see all the staff page and all staff's
 information
 > 3, each staff should only see their own page or dataset.
 > So, i don't know how to create staff page,only see their own page,
 >
 > please help me
 >


 Ok, well first things first. You can do this through the django admin,
 but it would be easier if you didn't.

 Create a class based DetailView like such:

 https://docs.djangoproject.com/en/1.7/topics/class-based-views/

 using your Staff model as the base, set up a url schema to deal with
 it and then add a mixin as explained in the Stack Overflow post I
 linked to.

 The administrator/Manager can always see all data through their admin
 view, the staff need to login, and they get the restricted view of
 their own page.

 cheers
 L.





 --
 From t

Re: why does django user require create database privlages for testing

2014-04-23 Thread Alex Mandel
If you don't want to setup a test db with permissions for a test app,
use sqlite. I can't see why you'd ever want to give your web app carte
blanc permissions to run all over your db server.

Seems to me "you create a test database as super user" is the same as
changing to a db admin user, creating a db and auth for access to that db.

Thanks,
Alex

On 04/23/2014 01:51 PM, Bill Freeman wrote:
> Because virtually all of us don't want our production database used for
> testing.
> 
> 
> On Wed, Apr 23, 2014 at 4:18 PM, dacresni  wrote:
> 
>> Rails doesn't require this, you create a test database as super user and
>> it uses it for testing. Why doesn't django allow this?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/79bc208a-8e2e-4b8c-a442-19e0f489ecf2%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/535829E6.1090109%40wildintellect.com.
For more options, visit https://groups.google.com/d/optout.


Re: why does django user require create database privlages for testing

2014-04-23 Thread Bill Freeman
Because virtually all of us don't want our production database used for
testing.


On Wed, Apr 23, 2014 at 4:18 PM, dacresni  wrote:

> Rails doesn't require this, you create a test database as super user and
> it uses it for testing. Why doesn't django allow this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/79bc208a-8e2e-4b8c-a442-19e0f489ecf2%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/CAB%2BAj0s3x7shESgF3aMe2qzF-E_Kt5edNrHtL_tHYgKtdsa4YA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


why does django user require create database privlages for testing

2014-04-23 Thread dacresni
Rails doesn't require this, you create a test database as super user and it 
uses it for testing. Why doesn't django allow this?  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/79bc208a-8e2e-4b8c-a442-19e0f489ecf2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Model Design, Nesting by Year

2014-04-23 Thread Christopher Grande
I'm in the process of designing an internal system and I'm having trouble 
designing the model so that it will function as I need it.

The basic idea is that everything is "Season" based, where a season is a 
year (2014, 2015, etc)

>From the there we have Events and the the Seasons they are functioning in, 
(Event 1 (2014, 2015, etc) , Event 2 (2014, 2015, etc))

Then there are people who may be active any given year for a specific Event:

Bob Smith, 2014, Event 1 & Event 2
  2015, Event 2
  2016, Event 1

I have created a Season & Event Models:

class EventSeason(models.Model):
season = models.IntegerField(max_length=4, primary_key=True)

class Event(models.Model):
attraction = models.CharField(max_length=30, null=True, blank=False)
seasons = models.ManyToManyField(EventSeason)

I have created the base person model and all the other fields for them 
(Address, etc) but I'm not sire how I to tie them to the seasons and events 
so that each season and event pair is maintained going forward. So for 
example I could historically lookup people from Event 1, 2014, for example. 

Hope this makes sense, thank you for any help,
Chris

-- 
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/cb81298e-b056-47fe-9b3a-4f4e2e3cfe18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bilingual Content Creation

2014-04-23 Thread Andreas Kuhne
That really depends on what you want to do with it.

We are using both dbgettext with Rosetta and transmeta in our application.

Transmeta creates extra database fields with _en and _es (or other
language-codes). You then edit the fields in django admin, like regular
fields. It is an easy way to create a multi-lingual application. However
the problem with it is when you want external translators to edit the
fields, the django admin interface is not good. You wouldn't want them to
login and edit there.

The best thing about using dbgettext and Rosetta is that you can send the
PO files to translators and they can use there regular software to do the
translations. Then you can just import the po file in the project. You can
then use rosetta to handle updates thereafter.

So in summary, either is good as long as you are doing the translations
yourself or you are doing it as you go along, however if you have alot of
translations that need to be translated at once, Rosetta and dbgettext is
probably a better solution.

Regards,

Andréas


2014-04-23 18:48 GMT+02:00 Nate :

> I'm making a Django site that will have Spanish and English content.
>
> I know I will be using 
> i18n.
> I want users to be able to create and translate content easily from the
> django admin.
>
> I am wondering how I should implement this.
>
> I've looked at these apps:
>
>- Rosetta 
>- transdb 
>- multi-lingual 
>
> And I've also read that one option would be to create duplicate model
> fields renamed with _en and _es suffixes accordingly.
>
> What's the slickest route to go?
>
> --
> 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/1422c693-2dc2-4f3a-b358-be8886d6718b%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/CALXYUb%3DBRg2jB7tuptcj_n4o8qVYJzYB-ykZ1gKGDDV4sU%2Bh%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Bilingual Content Creation

2014-04-23 Thread Nate
I'm making a Django site that will have Spanish and English content.

I know I will be using 
i18n. 
I want users to be able to create and translate content easily from the 
django admin. 

I am wondering how I should implement this.

I've looked at these apps:

   - Rosetta 
   - transdb 
   - multi-lingual 

And I've also read that one option would be to create duplicate model 
fields renamed with _en and _es suffixes accordingly.

What's the slickest route to go?

-- 
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/1422c693-2dc2-4f3a-b358-be8886d6718b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Interesting Django project folder structure.

2014-04-23 Thread Amirouche Boubekki
2014-04-21 16:00 GMT+02:00 Tianyi Wang :

> Today I was reading through
> http://www.deploydjango.com/django_project_structure (great resource)
>
> The suggested folder structure for a Django project from this site is like
> below:
> (I'm only interested in layout for Django apps, not requirements files or
> settings files)
>
>
> myproject
> |-- manage.py
>
> |-- requriements.txt
> |-- *myproject*
> |-- __init__.py
>
> |-- settings.py
> |-- urls.py
> |-- wsgi.py
>
> |
> `-- *apps*
>
> |-- __init__.py
>
> |-- *app_one*
>
> |   |-- __init__.py
> |   |-- models.py
> |   |-- views.py
> |   `-- urls.py
> `-- *app_two*
> |-- __init__.py
> |-- models.py
> |-- views.py
> `-- urls.py
>
>
I don't see the point of this structure really. Maybe, it's kind of helpful
to figure quickly where are the "app" directories, which can not be
immediate matter if you have other directories in myproject/ like
template_tags/ or urls/, why would you do that anyway?

I prefer your setup:


> My current setup is like below:
>
> myproject
> |-- manage.py
>
> |-- requirements.txt
> |-- *myproject*
> |   |-- __init__.py
> |   |-- settings.py
> |   |-- urls.py
> |   `-- wsgi.py
> `-- *app_one*
> |   |-- __init__.py
> |   |-- models.py
> |   |-- views.py
> |   `-- urls.py
> `-- *app_two*
> |-- __init__.py
> |-- models.py
> |-- views.py
> `-- urls.py
>
>
> The reason for the first layout is to categorise the apps,
>
> so one can have a "apps" folder contains all the custom apps;
>
>
> "libs" folder contains all the lib/helper apps and such.
>
>
Or something more sophisticated like:

myproject/
 myproject/ # created by startproject command, holds settings and stuff
 generic/  # holds generic apps
 integration/  # holds integration only apps of generic apps (apps that
only link to generic apps)
 custom/  # holds specific apps they can make use of any other kind of apps
 helpers/  # non app libraries

requirements.txt is usually not in a python package but in the root source
directory.

Do you guys think it's a good idea?
>
> Yes, as soon as you don't loose too much time fiddling with such matter,
it's helpful :)


>
> Cheers
>
>
> Tianyi
>
>  --
> 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/37ecd6cb-6dcc-431e-ae39-3814dbf647de%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/CAL7_Mo9f6%3D6Z1%2BPYoO3_4D_unQtvHz_oadpggZm_1dW1%2BE%3DbDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form wizard get_template_names()

2014-04-23 Thread Juan Miguel Taboada


On Wednesday, July 13, 2011 4:31:58 AM UTC+2, Dario Vergara wrote:
>
> Here is the solution: 
>
> def get_template_names(self): 
> next_step = int(self.steps.current) 
> return 'step_%s.html' % next_step 
>
>
> Simple solution. What is confusing is that the documentation says that 
> get_template_names() should return a list. 
>

I would like to point that your example doesn't return a list.

-- 
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/df58c7eb-1ec2-498f-9cd9-57752e58eee2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django

2014-04-23 Thread Srinivasulu Reddy
Hi Daniel , 


  you asked me copy and paste the error i got. In dealing of poll app 
part 4 help me to find a way to solve the problem in dealing with 
results.html and results view .

   Before changing results view it's working good. After changing result 
view and after creating in results.html . I am getting this problem after 
clicking "Vote" buttion on my browser.


  python manage.py runserver

Validating models...

0 errors found
April 23, 2014 - 09:20:10
Django version 1.6.2, using settings 'dj_tutorial.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[23/Apr/2014 09:20:15] "GET /poll/ HTTP/1.1" 200 408
[23/Apr/2014 09:20:18] "GET /poll/specifics/7/ HTTP/1.1" 200 599
[23/Apr/2014 09:20:23] "POST /poll/7/votes/ HTTP/1.1" 302 0
Internal Server Error: /poll/7/results/
Traceback (most recent call last):
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/core/handlers/base.py",
 
line 114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/seenu/work/Django_proj/d_tutorial/dj_tutorial/poll/views.py", 
line 24, in results
poll = get_object_or_404(Poll, poll_id)
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/shortcuts/__init__.py",
 
line 113, in get_object_or_404
return queryset.get(*args, **kwargs)
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 298, in get
clone = self.filter(*args, **kwargs)
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 590, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 608, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1192, in add_q
if not self.need_having(q_object):
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1155, in need_having
return any(self.need_having(c) for c in obj.children)
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1155, in 
return any(self.need_having(c) for c in obj.children)
  File 
"/root/.virtualenvs/djan/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1153, in need_having
or (hasattr(obj[1], 'contains_aggregate')
IndexError: string index out of range
[23/Apr/2014 09:20:24] "GET /poll/7/results/ HTTP/1.1" 500 91775

















On Wednesday, April 23, 2014 12:58:54 PM UTC+5:30, Daniel Roseman wrote:
>
> Why have you posted screenshots of text to a text-based newsgroup? Please 
> copy and paste the relevant text into a message (the Django error page even 
> has a special link to go to a copy and paste view).
> -- 
> DR.

-- 
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/6439dd90-79d5-4c1a-aeda-3ecc3434f0d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ユーザー登録について

2014-04-23 Thread hito koto
Thank you!
i can do create!

Sorry! i'm don't understand create staff site,
i want to create  staff site , staff site should have when rogin using 
ID/PW and have staff profile
i'm realy don't know!

pleae help me



2014年4月23日水曜日 16時18分44秒 UTC+9 Lachlan Musicman:
>
>
> On 23 April 2014 14:11, hito koto >wrote:
>
>> Thank you very much good idea!
>> i'm was try but i'm have error when create new staff !
>>
>> >>Request Method: POST  >>Request URL: http://articles/create/  >>Django 
>> Version: 1.6.2  >>Exception Type: IntegrityError  >>Exception Value: 
>>
>> (1048, "Column 'user_id' cannot be null")
>>
>>  >>Exception Location: 
>> /usr/lib64/python2.6/site-packages/MySQLdb/connections.py 
>> in defaulterrorhandler, line 36  >>Python Executable: /usr/bin/python
>>  >>/var/www/html/article/views.py in create 
>>
>>  >>   form.save()
>>
>> this is my views.py:
>>
>> def create(request):
>> if request.POST:
>> form = ArticleForm(request.POST)
>> if form.is_valid():
>> form.save()
>> return HttpResponseRedirect('/articles/all')
>>
>> else:
>> form = ArticleForm()
>> args = {}
>> args.update(csrf(request))
>> args['form'] = form
>> return render_to_response('create.html', args)
>>
>>
>>
>>
>
> I'm actually racing out the door, but quickly: the id field is automatic. 
> Your form refers to a user_id field that doesn't exist on your model except 
> as implied. In that case, you don't need to ask for user_id in the form. If 
> you want staff to have an ID_number, you should separate it from the id 
> (also known as the pk or primary key) field in the model class, then query 
> it in the form. 
>
> But as it stands, you can remove it from your form, and that should work.
>
> cheers
> L.
>
>
>
>  
>
>> this is my forms.py:
>> from django import forms
>> from models import User,Staff, Address
>> from django.contrib.auth.models import User
>>
>> class ArticleForm(forms.ModelForm):
>>
>> class Meta:
>> model = User
>> fields = ('user_name','first_kana', 'last_kana', 
>> 'employee_number','birthday')
>> user_id = forms.CharField(label="id", error_messages={'required': 
>> ''}, help_text='必須')
>> user_name = forms.CharField(label="氏名", error_messages={'required': 
>> ''}, help_text='必須')
>> first_kana = 
>> forms.CharField(label="ふりがな(性)",error_messages={'required': ''}, 
>> help_text='必須')
>> last_kana = 
>> forms.CharField(label="ふりがな(名)",error_messages={'required': ''}, 
>> help_text='必須')
>> employee_number = forms.CharField(label="社員番号", required=False)
>> birthday = forms.CharField(label="生年月日", required=False)
>>
>> class Meta:
>> model = Address
>> fields = ('user_name','postalcode', 'address', 
>> 'residence','number')
>> user_name = forms.CharField(label="氏名", error_messages={'required': 
>> ''}, help_text='必須')
>> postalcode = forms.CharField(label="郵便番号", required=False)
>> address = forms.CharField(label="住所", required=False)
>> residence = forms.CharField(label="住所開始日", required=False)
>> number = forms.CharField(label="電話番号", required=False)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2014年4月23日水曜日 7時03分10秒 UTC+9 Lachlan Musicman:
>>
>>> On 23 April 2014 01:52, hito koto  wrote: 
>>> > thank you very much 
>>> Each Staff can login. 
>>> Each staff should only see their own page or dataset. 
>>> > This is correct 
>>> > 
>>> > I want to create administrator page and each staff , 
>>> > 1, i want , Staff can see the staff page with ID and PW that an 
>>> > administrator has issued 
>>> > 2, administrator can see all the staff page and all staff's 
>>> information 
>>> > 3, each staff should only see their own page or dataset. 
>>> > So, i don't know how to create staff page,only see their own page, 
>>> > 
>>> > please help me 
>>> > 
>>>
>>>
>>> Ok, well first things first. You can do this through the django admin, 
>>> but it would be easier if you didn't. 
>>>
>>> Create a class based DetailView like such: 
>>>
>>> https://docs.djangoproject.com/en/1.7/topics/class-based-views/ 
>>>
>>> using your Staff model as the base, set up a url schema to deal with 
>>> it and then add a mixin as explained in the Stack Overflow post I 
>>> linked to. 
>>>
>>> The administrator/Manager can always see all data through their admin 
>>> view, the staff need to login, and they get the restricted view of 
>>> their own page. 
>>>
>>> cheers 
>>> L. 
>>>
>>>
>>>
>>>
>>>
>>> -- 
>>> From this perspective it is natural that anarchism be marked by 
>>> spontaneity, differentiation, and experimentation that it be marked by 
>>> an expressed affinity with chaos, if chaos is understood to be what 
>>> lies outside or beyond the dominant game or system. Because of the 
>>> resistance to definition and categorisation, the anarchist principle 
>>> has been variously interpreted as, rather than an articulated 
>>> position, “a moral attitude, an emotional clima

Re: Django

2014-04-23 Thread Daniel Roseman
Why have you posted screenshots of text to a text-based newsgroup? Please copy 
and paste the relevant text into a message (the Django error page even has a 
special link to go to a copy and paste view).
-- 
DR.

-- 
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/5e3a3622-b8bc-4863-a189-640b0d66111d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ユーザー登録について

2014-04-23 Thread Lachlan Musicman
On 23 April 2014 14:11, hito koto  wrote:

> Thank you very much good idea!
> i'm was try but i'm have error when create new staff !
>
> >>Request Method: POST  >>Request URL: http://articles/create/  >>Django
> Version: 1.6.2  >>Exception Type: IntegrityError  >>Exception Value:
>
> (1048, "Column 'user_id' cannot be null")
>
>  >>Exception Location: 
> /usr/lib64/python2.6/site-packages/MySQLdb/connections.py
> in defaulterrorhandler, line 36  >>Python Executable: /usr/bin/python
>  >>/var/www/html/article/views.py in create
>
>  >>   form.save()
>
> this is my views.py:
>
> def create(request):
> if request.POST:
> form = ArticleForm(request.POST)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect('/articles/all')
>
> else:
> form = ArticleForm()
> args = {}
> args.update(csrf(request))
> args['form'] = form
> return render_to_response('create.html', args)
>
>
>
>

I'm actually racing out the door, but quickly: the id field is automatic.
Your form refers to a user_id field that doesn't exist on your model except
as implied. In that case, you don't need to ask for user_id in the form. If
you want staff to have an ID_number, you should separate it from the id
(also known as the pk or primary key) field in the model class, then query
it in the form.

But as it stands, you can remove it from your form, and that should work.

cheers
L.





> this is my forms.py:
> from django import forms
> from models import User,Staff, Address
> from django.contrib.auth.models import User
>
> class ArticleForm(forms.ModelForm):
>
> class Meta:
> model = User
> fields = ('user_name','first_kana', 'last_kana',
> 'employee_number','birthday')
> user_id = forms.CharField(label="id", error_messages={'required': ''},
> help_text='必須')
> user_name = forms.CharField(label="氏名", error_messages={'required':
> ''}, help_text='必須')
> first_kana =
> forms.CharField(label="ふりがな(性)",error_messages={'required': ''},
> help_text='必須')
> last_kana =
> forms.CharField(label="ふりがな(名)",error_messages={'required': ''},
> help_text='必須')
> employee_number = forms.CharField(label="社員番号", required=False)
> birthday = forms.CharField(label="生年月日", required=False)
>
> class Meta:
> model = Address
> fields = ('user_name','postalcode', 'address',
> 'residence','number')
> user_name = forms.CharField(label="氏名", error_messages={'required':
> ''}, help_text='必須')
> postalcode = forms.CharField(label="郵便番号", required=False)
> address = forms.CharField(label="住所", required=False)
> residence = forms.CharField(label="住所開始日", required=False)
> number = forms.CharField(label="電話番号", required=False)
>
>
>
>
>
>
>
>
>
>
>
>
>
> 2014年4月23日水曜日 7時03分10秒 UTC+9 Lachlan Musicman:
>
>> On 23 April 2014 01:52, hito koto  wrote:
>> > thank you very much
>> Each Staff can login.
>> Each staff should only see their own page or dataset.
>> > This is correct
>> >
>> > I want to create administrator page and each staff ,
>> > 1, i want , Staff can see the staff page with ID and PW that an
>> > administrator has issued
>> > 2, administrator can see all the staff page and all staff's information
>> > 3, each staff should only see their own page or dataset.
>> > So, i don't know how to create staff page,only see their own page,
>> >
>> > please help me
>> >
>>
>>
>> Ok, well first things first. You can do this through the django admin,
>> but it would be easier if you didn't.
>>
>> Create a class based DetailView like such:
>>
>> https://docs.djangoproject.com/en/1.7/topics/class-based-views/
>>
>> using your Staff model as the base, set up a url schema to deal with
>> it and then add a mixin as explained in the Stack Overflow post I
>> linked to.
>>
>> The administrator/Manager can always see all data through their admin
>> view, the staff need to login, and they get the restricted view of
>> their own page.
>>
>> cheers
>> L.
>>
>>
>>
>>
>>
>> --
>> From this perspective it is natural that anarchism be marked by
>> spontaneity, differentiation, and experimentation that it be marked by
>> an expressed affinity with chaos, if chaos is understood to be what
>> lies outside or beyond the dominant game or system. Because of the
>> resistance to definition and categorisation, the anarchist principle
>> has been variously interpreted as, rather than an articulated
>> position, “a moral attitude, an emotional climate, or even a mood”.
>> This mood hangs in dramatic tension between utopian hope or dystopian
>> nihilism...
>> -
>> http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos
>>
>  --
> 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@googleg