Re: Complex content type

2016-05-02 Thread ludovic coues
I have some trouble trying to understand what you means by "content type".
That terms refer to the content of a file. For exemple, text/plain for
plain text file or image/png for an image encoded as png.
What you show look like a standard form. If you need basic pointer on how
to use a form, saving it's data along with current logged-in user, you
might want to have a look at the django girls tutorial. Specifically,
http://tutorial.djangogirls.org/en/django_forms/ is about django forms.

2016-05-02 8:23 GMT+02:00 Said Akhmedbayev :

> Avraham, I understand that the content type is not any special or complex
> for you. Probably, I should wrote "complex content type for me". Anyways,
> can you provide any instructions for how can make this kind of content type?
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTYNEh6ycOtzcfK_VkmA1Nm2JPKsa-34_x%3Dve5j3vP2AUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex content type

2016-05-02 Thread Said Akhmedbayev
Thank you ludovic and sorry for not being able to clearly explain what I 
want to do :-(. You are right, I want to show a user a simple django form, 
but I cannot figure out how to save an individual answer alone with its 
correspondence question's id and user's id

So my table for "Answer" model will look like:

*user_id   question_id answer*
 0101 text of an answer
 0102 text of an answer
 0201 text of an answer
 0202 text of an answer
 0301 text of an answer
 0302 text of an answer




On Monday, May 2, 2016 at 3:25:06 PM UTC+6, ludovic coues wrote:
>
> I have some trouble trying to understand what you means by "content type". 
> That terms refer to the content of a file. For exemple, text/plain for 
> plain text file or image/png for an image encoded as png.
> What you show look like a standard form. If you need basic pointer on how 
> to use a form, saving it's data along with current logged-in user, you 
> might want to have a look at the django girls tutorial. Specifically, 
> http://tutorial.djangogirls.org/en/django_forms/ is about django forms.
>
> 2016-05-02 8:23 GMT+02:00 Said Akhmedbayev  >:
>
>> Avraham, I understand that the content type is not any special or complex 
>> for you. Probably, I should wrote "complex content type for me". Anyways, 
>> can you provide any instructions for how can make this kind of content type?
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fdbc2c01-2059-406d-93fe-762d9fdc4a73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex content type

2016-05-02 Thread ludovic coues
You might want to add a foreign key in the answer model pointing to
the question.
Then in the view to show the form, create an answer object with it's
question FK assigned to the question and create a form from that
answer. In the view processing the form, you should get that object
back, with the question and the text filled. Complete it with the
user, as shown in the django girls tutorial and save your answer.



2016-05-02 11:57 GMT+02:00 Said Akhmedbayev :
> Thank you ludovic and sorry for not being able to clearly explain what I
> want to do :-(. You are right, I want to show a user a simple django form,
> but I cannot figure out how to save an individual answer alone with its
> correspondence question's id and user's id
>
> So my table for "Answer" model will look like:
>
> user_id   question_id answer
>  0101 text of an answer
>  0102 text of an answer
>  0201 text of an answer
>  0202 text of an answer
>  0301 text of an answer
>  0302 text of an answer
>
>
>
>
> On Monday, May 2, 2016 at 3:25:06 PM UTC+6, ludovic coues wrote:
>>
>> I have some trouble trying to understand what you means by "content type".
>> That terms refer to the content of a file. For exemple, text/plain for plain
>> text file or image/png for an image encoded as png.
>> What you show look like a standard form. If you need basic pointer on how
>> to use a form, saving it's data along with current logged-in user, you might
>> want to have a look at the django girls tutorial. Specifically,
>> http://tutorial.djangogirls.org/en/django_forms/ is about django forms.
>>
>> 2016-05-02 8:23 GMT+02:00 Said Akhmedbayev :
>>>
>>> Avraham, I understand that the content type is not any special or complex
>>> for you. Probably, I should wrote "complex content type for me". Anyways,
>>> can you provide any instructions for how can make this kind of content type?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fdbc2c01-2059-406d-93fe-762d9fdc4a73%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTbCd7%3D1BGMKxVNCT1nRONPasYB%3DbMHDM6aG7OU7miD5vA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


manipulate n insert field values

2016-05-02 Thread Shameema Mohsin
i have 2 fields latitude n longitude, and need to calculate z order value 
of lat n long n insert to a field

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/324d1aa7-a475-4c16-8226-503bd294468e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: manipulate n insert field values

2016-05-02 Thread Shameema Mohsin
Could anybody help me out as I am new to Django.
*In my model:*

from django.db import models

class Employees(models.Model):
empId = models.AutoField(primary_key=True)
empName = models.CharField(max_length=200)
empEmail = models.EmailField()
empMob = models.CharField(max_length=200)
empAddr = models.TextField()
empLat = models.DecimalField(max_digits=9,decimal_places=6)
empLong = models.DecimalField(max_digits=9,decimal_places=6)
empDOB = models.DateField()
zval = models.IntegerField(default=0)

def __str__(self):
return self.empName


In the z value field i need to insert the z curve value calculated from 
latitude and longitude. where should I write the code? In models.py or 
somewhere else?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/60d32bc0-59c0-4467-93df-1c0072c7e5c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex content type

2016-05-02 Thread Said Akhmedbayev
Ludovic, would you be so kind to help me and put together some example code 
of what I should  place in the forms.py and the views.py? I would greatly 
appreciate.

On Monday, May 2, 2016 at 4:25:13 PM UTC+6, ludovic coues wrote:
>
> You might want to add a foreign key in the answer model pointing to 
> the question. 
> Then in the view to show the form, create an answer object with it's 
> question FK assigned to the question and create a form from that 
> answer. In the view processing the form, you should get that object 
> back, with the question and the text filled. Complete it with the 
> user, as shown in the django girls tutorial and save your answer. 
>
>
>
> 2016-05-02 11:57 GMT+02:00 Said Akhmedbayev  >: 
> > Thank you ludovic and sorry for not being able to clearly explain what I 
> > want to do :-(. You are right, I want to show a user a simple django 
> form, 
> > but I cannot figure out how to save an individual answer alone with its 
> > correspondence question's id and user's id 
> > 
> > So my table for "Answer" model will look like: 
> > 
> > user_id   question_id answer 
> >  0101 text of an answer 
> >  0102 text of an answer 
> >  0201 text of an answer 
> >  0202 text of an answer 
> >  0301 text of an answer 
> >  0302 text of an answer 
> > 
> > 
> > 
> > 
> > On Monday, May 2, 2016 at 3:25:06 PM UTC+6, ludovic coues wrote: 
> >> 
> >> I have some trouble trying to understand what you means by "content 
> type". 
> >> That terms refer to the content of a file. For exemple, text/plain for 
> plain 
> >> text file or image/png for an image encoded as png. 
> >> What you show look like a standard form. If you need basic pointer on 
> how 
> >> to use a form, saving it's data along with current logged-in user, you 
> might 
> >> want to have a look at the django girls tutorial. Specifically, 
> >> http://tutorial.djangogirls.org/en/django_forms/ is about django 
> forms. 
> >> 
> >> 2016-05-02 8:23 GMT+02:00 Said Akhmedbayev : 
> >>> 
> >>> Avraham, I understand that the content type is not any special or 
> complex 
> >>> for you. Probably, I should wrote "complex content type for me". 
> Anyways, 
> >>> can you provide any instructions for how can make this kind of content 
> type? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/fdbc2c01-2059-406d-93fe-762d9fdc4a73%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c96cece4-7a3b-45fc-bb6f-5dfdd1e1b242%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-02 Thread Bruce Whealton
As an update to this...  I decided to simplify things a bit.  For my 
contacts application, 
I decided to start with just one table.  I got that working in a 
Ubuntu Vbox 
environment, inside a virtualenv. 

I'm not sure if it is ok to use python manage.py makemigrations on the 
production server or if one should just do that locally and then import it.
Thanks for any advice,
This should be part of a larger posting on workflows moving from 
development to
production.
Thanks,
Bruce

On Saturday, April 23, 2016 at 10:30:45 AM UTC-4, Bruce Whealton wrote:
>
> Hello all,
>   So, I setup django in a virtualenv on my Ubuntu environment.  I 
> was reading the docs and thought I had things right 
> for creating the 3 models I wanted with this application. I am using 
> Postgresql.  I have the Postgresql driver for Python/Django installed
> in the virtualenv.  It is a "Contacts" app.  
> First question: Do django model fields default to required unless you use 
> blank=True, null=True?
> Many of my fields, I want to have optional.
>
> I have a class called Contact, a class called Organization and a class 
> called Connection.  
> I wanted to use the Organization as a foreign key on the Contact model.  I 
> could have more than one contact from
> an Organization.  The Connection model is inspired by the Google Plus idea 
> of "Circles" - e.g. friends,
> family, following, etc.   So, this would be a many-to-many relationship.  
>
> My problems are (1) I cannot create connections without specifying a 
> contact.  
> (2) If I was adding a contact using the admin interface, how do I allow no 
> value for that foreign field
> or allow for some kind of ajax type of text completion?  If a person is 
> family or friend, I may not need
> to list an Organization for them.
> (3) I would like to support multiple connection types - e.g. following, 
> employer, etc.
>
> So, here is my apps models.py file:
> 
>
> from django.db import models
>
>
> class Contact(models.Model):
> name = models.CharField(max_length=40)
> Organization = models.CharField(max_length=50)
> street_line1 = models.CharField("Street Line 1", max_length=50)
> street_line2 = models.CharField("Street Line 2", max_length=50)
> city = models.CharField(max_length=40)
> state = models.CharField(max_length=40)
> zipcode = models.CharField(max_length=20, blank=True, null=True)
> phone1 = models.CharField(max_length=20)
> phone2 = models.CharField(max_length=20)
> email = models.EmailField(max_length=60)
>
>
> class Organization(models.Model):
> name = models.CharField(max_length=60)
> street_line1 = models.CharField("Street Line 1", max_length=50)
> street_line2 = models.CharField("Street Line 2", max_length=50)
> city = models.CharField(max_length=40)
> state = models.CharField(max_length=40)
> zipcode = models.CharField(max_length=20, blank=True, null=True,)
> phone = models.CharField(max_length=20)
> email = models.EmailField(max_length=60)
> website = models.URLField(max_length=90)
> contact_name = models.ForeignKey(Contact, on_delete=models.CASCADE)
>
>
> class Connection(models.Model):
> type = models.CharField(max_length=60)
> contact_name = models.ManyToManyField(Contact)   
>
> >>>
> Thanks in advance for any suggestions,
> Bruce 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c7ad7e0-485b-4da1-81c0-8a63f0b108be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: manipulate n insert field values

2016-05-02 Thread Erik Cederstrand

> Den 2. maj 2016 kl. 15.38 skrev Shameema Mohsin :
> 
> Could anybody help me out as I am new to Django.
> In my model:
> 
> from django.db import models
> 
> class Employees(models.Model):
>empId = models.AutoField(primary_key=True)
>empName = models.CharField(max_length=200)
>empEmail = models.EmailField()
>empMob = models.CharField(max_length=200)
>empAddr = models.TextField()
>empLat = models.DecimalField(max_digits=9,decimal_places=6)
>empLong = models.DecimalField(max_digits=9,decimal_places=6)
>empDOB = models.DateField()
>zval = models.IntegerField(default=0)
> 
>def __str__(self):
>return self.empName
> 
> In the z value field i need to insert the z curve value calculated from 
> latitude and longitude. where should I write the code? In models.py or 
> somewhere else?

There are two strategies here. If zval is always generated from empLat and 
empLong, then you could change zval from a field to a property on the Employees 
class. Otherwise, you risk zval falling out of sync if you are not careful to 
always re-calculate zval when empLat/empLong changes:

  class Employees(models.Model):
 [...]
 @property
 def zval(self):
return # your calculation here


The other strategy would be to place the calculation in the save() method:

  class Employees(models.Model):
 [...]
 def save(self, *args, **kwargs):
self.zval = # your calculation here
super().save(*args, **kwargs)

Beware that save() is not always called. For example, bulk_create() doesn't 
call save(). You need to handle these situations yourself.

Erik

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97FEF314-509F-48AF-8A41-860CDBC6F514%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-02 Thread Michal Petrucha
On Mon, May 02, 2016 at 08:37:43AM -0700, Bruce Whealton wrote:
> I'm not sure if it is ok to use python manage.py makemigrations on the 
> production server or if one should just do that locally and then import it.

Hi Bruce,

Migrations are a part of your application's code base, and they should
be treated as such. In other words, you create all migrations during
development, and make sure to include them in your code repository,
and then as part of your deployment strategy, you only apply them in
the production environment.

Cheers,

Michal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160502154744.GP435%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Trying to make a POST call to a Django view

2016-05-02 Thread carloratm
hello everyone,
I am a frontend developer studying Django, so please forgive my noobish 
question...
I am trying to make a simple ajax call working.

I have a form in a template. I would like to use that form to save an 
object into the database (asynchronously).
On form submit event:
* I prevent regular action
* I serialize form data in a JSON
* I pass that object to a view using a jquery POST
* The view receive the JSON data
* The view use the request.POST data to save an object into the database.
* The view returns a message.

Is that flow straightforward, or am I completely missing the goal?

Now some code and the error I got.

The relevant part of template:

http://dpaste.com/3Z7TRPM


And this is the error I got:

http://dpaste.com/3FYMGYG

I noticed that in the view the request.POST is *empty*!
That is wrong, I suppose.

I am surely missing something.
Any help is really appreciated.

Thank you in advance,
carlo

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/44f6da2a-c677-4485-99f2-eec20f8dfe0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to make a POST call to a Django view

2016-05-02 Thread ludovic coues
I would use the browser developer tools to look at what JQuery is
sending to django in the submit event.

2016-05-02 18:01 GMT+02:00 carloratm :
> hello everyone,
> I am a frontend developer studying Django, so please forgive my noobish
> question...
> I am trying to make a simple ajax call working.
>
> I have a form in a template. I would like to use that form to save an object
> into the database (asynchronously).
> On form submit event:
> * I prevent regular action
> * I serialize form data in a JSON
> * I pass that object to a view using a jquery POST
> * The view receive the JSON data
> * The view use the request.POST data to save an object into the database.
> * The view returns a message.
>
> Is that flow straightforward, or am I completely missing the goal?
>
> Now some code and the error I got.
>
> The relevant part of template:
>
> http://dpaste.com/3Z7TRPM
>
>
> And this is the error I got:
>
> http://dpaste.com/3FYMGYG
>
> I noticed that in the view the request.POST is *empty*!
> That is wrong, I suppose.
>
> I am surely missing something.
> Any help is really appreciated.
>
> Thank you in advance,
> carlo
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/44f6da2a-c677-4485-99f2-eec20f8dfe0f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTb4q_-OwNX%2BMWbp2DQrRB0-gdSv5-rD-h31GYrSWHXwew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex content type

2016-05-02 Thread ludovic coues
There is such example in the django girls tutorial I linked earlier.

2016-05-02 15:48 GMT+02:00 Said Akhmedbayev :
> Ludovic, would you be so kind to help me and put together some example code
> of what I should  place in the forms.py and the views.py? I would greatly
> appreciate.
>
> On Monday, May 2, 2016 at 4:25:13 PM UTC+6, ludovic coues wrote:
>>
>> You might want to add a foreign key in the answer model pointing to
>> the question.
>> Then in the view to show the form, create an answer object with it's
>> question FK assigned to the question and create a form from that
>> answer. In the view processing the form, you should get that object
>> back, with the question and the text filled. Complete it with the
>> user, as shown in the django girls tutorial and save your answer.
>>
>>
>>
>> 2016-05-02 11:57 GMT+02:00 Said Akhmedbayev :
>> > Thank you ludovic and sorry for not being able to clearly explain what I
>> > want to do :-(. You are right, I want to show a user a simple django
>> > form,
>> > but I cannot figure out how to save an individual answer alone with its
>> > correspondence question's id and user's id
>> >
>> > So my table for "Answer" model will look like:
>> >
>> > user_id   question_id answer
>> >  0101 text of an answer
>> >  0102 text of an answer
>> >  0201 text of an answer
>> >  0202 text of an answer
>> >  0301 text of an answer
>> >  0302 text of an answer
>> >
>> >
>> >
>> >
>> > On Monday, May 2, 2016 at 3:25:06 PM UTC+6, ludovic coues wrote:
>> >>
>> >> I have some trouble trying to understand what you means by "content
>> >> type".
>> >> That terms refer to the content of a file. For exemple, text/plain for
>> >> plain
>> >> text file or image/png for an image encoded as png.
>> >> What you show look like a standard form. If you need basic pointer on
>> >> how
>> >> to use a form, saving it's data along with current logged-in user, you
>> >> might
>> >> want to have a look at the django girls tutorial. Specifically,
>> >> http://tutorial.djangogirls.org/en/django_forms/ is about django forms.
>> >>
>> >> 2016-05-02 8:23 GMT+02:00 Said Akhmedbayev :
>> >>>
>> >>> Avraham, I understand that the content type is not any special or
>> >>> complex
>> >>> for you. Probably, I should wrote "complex content type for me".
>> >>> Anyways,
>> >>> can you provide any instructions for how can make this kind of content
>> >>> type?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to django-users...@googlegroups.com.
>> > To post to this group, send email to django...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/django-users/fdbc2c01-2059-406d-93fe-762d9fdc4a73%40googlegroups.com.
>> >
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>>
>> Cordialement, Coues Ludovic
>> +336 148 743 42
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c96cece4-7a3b-45fc-bb6f-5dfdd1e1b242%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTZ0nZMxtBroPkriKuE2e0YBH%2BKPQ5uEkPR1f5CMX0bO4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Python3 + makemessages = "invalid multibyte sequence"

2016-05-02 Thread Torsten Bronger
Hallöchen!

With Django 1.9.5 and Python 3, I get warnings like

./jb_common/templates/404.html.py:35: invalid multibyte sequence

when I run "manage.py makemessages".  The problem occurs only in
HTML files with (validly) UTF-8-encoded characters in them.  In the
.po file, these characters are skipped.  How can I fix this?

The problem does not occur with Python 2.

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87zis81iwk.fsf%40physik.rwth-aachen.de.
For more options, visit https://groups.google.com/d/optout.


Re: Complex content type

2016-05-02 Thread Aaron Cannon
To your Answer class, you could just add a field like:

question = models.ForeignKey(Question, on_delete=models.CASCADE)

It may be as simple as that.

Does that help?

Aaron

On 5/2/16, ludovic coues  wrote:
> There is such example in the django girls tutorial I linked earlier.
>
> 2016-05-02 15:48 GMT+02:00 Said Akhmedbayev :
>> Ludovic, would you be so kind to help me and put together some example
>> code
>> of what I should  place in the forms.py and the views.py? I would greatly
>> appreciate.
>>
>> On Monday, May 2, 2016 at 4:25:13 PM UTC+6, ludovic coues wrote:
>>>
>>> You might want to add a foreign key in the answer model pointing to
>>> the question.
>>> Then in the view to show the form, create an answer object with it's
>>> question FK assigned to the question and create a form from that
>>> answer. In the view processing the form, you should get that object
>>> back, with the question and the text filled. Complete it with the
>>> user, as shown in the django girls tutorial and save your answer.
>>>
>>>
>>>
>>> 2016-05-02 11:57 GMT+02:00 Said Akhmedbayev :
>>> > Thank you ludovic and sorry for not being able to clearly explain what
>>> > I
>>> > want to do :-(. You are right, I want to show a user a simple django
>>> > form,
>>> > but I cannot figure out how to save an individual answer alone with
>>> > its
>>> > correspondence question's id and user's id
>>> >
>>> > So my table for "Answer" model will look like:
>>> >
>>> > user_id   question_id answer
>>> >  0101 text of an answer
>>> >  0102 text of an answer
>>> >  0201 text of an answer
>>> >  0202 text of an answer
>>> >  0301 text of an answer
>>> >  0302 text of an answer
>>> >
>>> >
>>> >
>>> >
>>> > On Monday, May 2, 2016 at 3:25:06 PM UTC+6, ludovic coues wrote:
>>> >>
>>> >> I have some trouble trying to understand what you means by "content
>>> >> type".
>>> >> That terms refer to the content of a file. For exemple, text/plain
>>> >> for
>>> >> plain
>>> >> text file or image/png for an image encoded as png.
>>> >> What you show look like a standard form. If you need basic pointer on
>>> >> how
>>> >> to use a form, saving it's data along with current logged-in user,
>>> >> you
>>> >> might
>>> >> want to have a look at the django girls tutorial. Specifically,
>>> >> http://tutorial.djangogirls.org/en/django_forms/ is about django
>>> >> forms.
>>> >>
>>> >> 2016-05-02 8:23 GMT+02:00 Said Akhmedbayev :
>>> >>>
>>> >>> Avraham, I understand that the content type is not any special or
>>> >>> complex
>>> >>> for you. Probably, I should wrote "complex content type for me".
>>> >>> Anyways,
>>> >>> can you provide any instructions for how can make this kind of
>>> >>> content
>>> >>> type?
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "Django users" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to django-users...@googlegroups.com.
>>> > To post to this group, send email to django...@googlegroups.com.
>>> > Visit this group at https://groups.google.com/group/django-users.
>>> > To view this discussion on the web visit
>>> >
>>> > https://groups.google.com/d/msgid/django-users/fdbc2c01-2059-406d-93fe-762d9fdc4a73%40googlegroups.com.
>>> >
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>>
>>> Cordialement, Coues Ludovic
>>> +336 148 743 42
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/c96cece4-7a3b-45fc-bb6f-5dfdd1e1b242%40googlegroups.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEuG%2BTZ0nZMxtBroPkriKuE2e0YBH%2BKPQ5uEkPR1f5CMX0bO4g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are 

makemigrations throws table does not exist error

2016-05-02 Thread Lucian Willoughby
I am trying to recreate a django project from a git repository that I have. 
I don't have the original database. I have emptyied all of the migration 
folders but when I run "python manage.py makemigrartions" I get the 
following error ("Table 'age-sdb.login_esm_systems_experience_choice' 
doesn't exist"). That is a

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/be76c531-09ae-4047-a521-b0f09b64d725%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


makemigrations throws table does not exist error

2016-05-02 Thread Lucian Willoughby
I am trying to re-create an older project from a git repository. I do not 
have the original MySql database. I emptied the migration folders and tried 
to run "python manage.py makemigrations" which resulted in the following 
error : "Table 'age-sdb.login_esm_systems_experience_choice' doesn't 
exist". 'age-sdb.login_esm_systems_experience_choice' is a table from the 
project. I have tried "python manage.py makemigrations --empty" with the 
same results. All migrartion folders are empty

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce208619-4e72-4df0-8a35-0d67a4a07837%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-02 Thread Bruce Whealton
Michal,
   I had to read your response a few times but I finally got it.  I was 
reading
that all migrations are created in development only and then applied during 
production.  
So, during development you use makemigrations and then when deployed
you migrate.  

Thus, if you add a new feature, you make the migration on the 
development system then push it to producation, where you can
issue the command python manage.py migrate.  

I just thought of something that is related to migrations.  Suppose,
with my contacts app, I want to change the name field to be
first_name + last_name.  If there is data in the database, how will
this be handled?

I'll give it a try and see what happens.  It is just the development machine
that has the data.
Thanks,
Bruce

On Monday, May 2, 2016 at 11:48:52 AM UTC-4, Michal Petrucha wrote:
>
> On Mon, May 02, 2016 at 08:37:43AM -0700, Bruce Whealton wrote: 
> > I'm not sure if it is ok to use python manage.py makemigrations on the 
> > production server or if one should just do that locally and then import 
> it. 
>
> Hi Bruce, 
>
> Migrations are a part of your application's code base, and they should 
> be treated as such. In other words, you create all migrations during 
> development, and make sure to include them in your code repository, 
> and then as part of your deployment strategy, you only apply them in 
> the production environment. 
>
> Cheers, 
>
> Michal 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd085f78-6126-4583-8570-1a3ee66778cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Help with moving a development project to production

2016-05-02 Thread Bruce Whealton
Hello all,
 I have been developing a django project and app on a Ubuntu 
system.  My production system is Centos 6 based ( I think, not Centos 7).  
First off, what should I commit to the repo?  I setup a virtualenv using 
virtualenvwrapper.  This included a bin directory, include directory and 
lib directory - 
do I need these in the repo?  Or should they be created on the production 
server using virtualenv?
 
What if the production environment didn't have a virtualenv?  I guess that 
is somewhat of a hypothetical question.  

If during development, I created various migrations and even added data to 
the database.  I am using Postgresql for both
development and production.  If I exported the database, with statements to 
create all the tables and then populate them with
data and then I import this to the database server used for production, 
does this create a problem?  I was told to commit
the migrations and then run/make them on the production server.  Is that 
only necessary if I did not export
everything and then import it all?  Or should I avoid importing the 
database with structure and data,
instead just running the migrations?

If I were moving from one server to another (both production servers ) I 
wouldn't want to lose my data.  It seems
like I would lose it all if I ran all the migrations.

Lastly, I heard that django likes to be in the top level folder for a 
domain - this was in a shared python hosting 
environment that had a one click installer from the control panel.  I also 
have access to a vps server with root shell access.  
It is Centos based with support for python and php.  How do I setup 
wsgi with apache?  Do I need to create a
vhost file?  In that case, I'd use a subdomain for one of my domains.
Thanks in advance for any help,
Bruce 


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dba70b37-2ac3-42d9-8946-41754e1ce4e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with moving a development project to production

2016-05-02 Thread Ryan Nowakowski
On Mon, May 02, 2016 at 03:07:57PM -0700, Bruce Whealton wrote:
>  I have been developing a django project and app on a Ubuntu 
> system.  My production system is Centos 6 based ( I think, not Centos 7).  
> First off, what should I commit to the repo?  I setup a virtualenv using 
> virtualenvwrapper.  This included a bin directory, include directory and 
> lib directory - 
> do I need these in the repo?  Or should they be created on the production 
> server using virtualenv?

No, typically virtualenv stuff(bin/lib) are unique per OS variant(Ubuntu
12.04, CentOS 6, etc).  You won't check that stuff into the repo.
However you do want a list of all your python dependencies and their
versions.  You can do that in your development repo by running:

pip freeze -l > requirements.txt

> What if the production environment didn't have a virtualenv?  I guess that 
> is somewhat of a hypothetical question.  

virtualenv is just a python package so you should be able to install it.

> If during development, I created various migrations and even added data to 
> the database.  I am using Postgresql for both
> development and production.  If I exported the database, with statements to 
> create all the tables and then populate them with
> data and then I import this to the database server used for production, 
> does this create a problem?  I was told to commit
> the migrations and then run/make them on the production server.  Is that 
> only necessary if I did not export
> everything and then import it all?  Or should I avoid importing the 
> database with structure and data,
> instead just running the migrations?
>
> If I were moving from one server to another (both production servers ) I 
> wouldn't want to lose my data.  It seems
> like I would lose it all if I ran all the migrations.

The migrations that get applied are recorded in a table in your database
so if you are exporting the database in dev and importing in production,
all the migrations will already be there along with the record of them
being applied.

> Lastly, I heard that django likes to be in the top level folder for a 
> domain - this was in a shared python hosting 
> environment that had a one click installer from the control panel.  I also 
> have access to a vps server with root shell access.  

Nah, you can serve Django from just about anywhere.  The code can live
anywhere in your filesystem and it can be served from any URL root
path(not just '/').  It's just a matter of configuring things in
settings.py.

> It is Centos based with support for python and php.  How do I setup 
> wsgi with apache?  Do I need to create a
> vhost file?  In that case, I'd use a subdomain for one of my domains.
> Thanks in advance for any help,

Here's the Django documentation for Apache/wsgi.  It's pretty good.

https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160502225515.GB32217%40fattuba.com.
For more options, visit https://groups.google.com/d/optout.


[ANNOUNCE] Django bugfix releases issued: 1.9.6 and 1.8.13

2016-05-02 Thread Tim Graham
Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2016/may/02/bugfix-releases/


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01722d4b-b75d-424e-b744-242ba854395b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: manipulate n insert field values

2016-05-02 Thread Shameema Mohsin
Thank you Erik. I will try the property method.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/efbc38d6-bd0e-485a-81f5-7dc3d59bb8af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: manipulate n insert field values

2016-05-02 Thread Shameema Mohsin

Stil stuck with the z order calculation and usage of the property field. 
Kindly help. I am new to Django, only knows php well.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7702ae6d-3972-44cd-bf8a-089a483068e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Chinese humanize number conversion

2016-05-02 Thread Malte
Hi,

The Chinese humanization of numbers is not correct for large and very large 
numbers.
1.400.000 converts into 1.4 百万 but should be 140万
166,200,000,000 converts into 166.2十亿 but should be 1662亿
I just looked through the Django core code but couldn't find where that 
conversion takes place.

Where does all of that go down?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c1a2574-76e7-4e39-8f59-896fcbdbfe5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to make a POST call to a Django view

2016-05-02 Thread Carlo Ascani
2016-05-02 18:11 GMT+02:00 ludovic coues :
> I would use the browser developer tools to look at what JQuery is
> sending to django in the submit event.

http://dpaste.com/2MQTNZP

I do not see anything wrong there...

Any ideas?
Thank you

>
> 2016-05-02 18:01 GMT+02:00 carloratm :
>> hello everyone,
>> I am a frontend developer studying Django, so please forgive my noobish
>> question...
>> I am trying to make a simple ajax call working.
>>
>> I have a form in a template. I would like to use that form to save an object
>> into the database (asynchronously).
>> On form submit event:
>> * I prevent regular action
>> * I serialize form data in a JSON
>> * I pass that object to a view using a jquery POST
>> * The view receive the JSON data
>> * The view use the request.POST data to save an object into the database.
>> * The view returns a message.
>>
>> Is that flow straightforward, or am I completely missing the goal?
>>
>> Now some code and the error I got.
>>
>> The relevant part of template:
>>
>> http://dpaste.com/3Z7TRPM
>>
>>
>> And this is the error I got:
>>
>> http://dpaste.com/3FYMGYG
>>
>> I noticed that in the view the request.POST is *empty*!
>> That is wrong, I suppose.
>>
>> I am surely missing something.
>> Any help is really appreciated.
>>
>> Thank you in advance,
>> carlo
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/44f6da2a-c677-4485-99f2-eec20f8dfe0f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> You received this message because you are subscribed to a topic in the Google 
> Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/pRkBho_TZrQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAEuG%2BTb4q_-OwNX%2BMWbp2DQrRB0-gdSv5-rD-h31GYrSWHXwew%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Carlo Ascani | www.carlorat.me
carloratm@freenode

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABVJJr-1NsiFcCU%2B-jsT9rVzDoZcesG18yt3Usz0LDXT3zj0YQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to make a POST call to a Django view

2016-05-02 Thread Jani Tiainen



On 02.05.2016 19:01, carloratm wrote:

hello everyone,
I am a frontend developer studying Django, so please forgive my 
noobish question...

I am trying to make a simple ajax call working.

I have a form in a template. I would like to use that form to save an 
object into the database (asynchronously).

On form submit event:
* I prevent regular action
* I serialize form data in a JSON
* I pass that object to a view using a jquery POST
* The view receive the JSON data
* The view use the request.POST data to save an object into the database.
* The view returns a message.

Is that flow straightforward, or am I completely missing the goal?

Now some code and the error I got.

The relevant part of template:

http://dpaste.com/3Z7TRPM


And this is the error I got:

http://dpaste.com/3FYMGYG

I noticed that in the view the request.POST is *empty*!
That is wrong, I suppose.



No that isn't. If jquery sets content-type, to application/json Django 
doesn't put that data in .POST, but it's in .body


Django only puts in .POST form-data (either urlencoded or multipart)


I am surely missing something.
Any help is really appreciated.



If you want to send JSON data with ajax, using something like django-nap 
or django-rest-framework is a great help.


--

Jani Tiainen

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57283A8B.2090502%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Multiple User Profiles Best Practices

2016-05-02 Thread Peter of the Norse
> On Apr 6, 2016, at 9:41 PM, Sudhanshu Shekhar  wrote:
> 
> Hi,
> 
> I am creating a tutor-student forum using Django. For which I need to have 
> two different user profiles, one for students and one for teachers. However, 
> I am unsure about the best way to do this. I am currently following the below 
> approach:
> 
> class UserProfile:
>  user = models.OneToOneField(User, reverse_name="profile")
>  #other common Attributes
>  class Meta(object):
>abstract = true
> 
> class TutorProfile():
>  #tutor fields
>  class Meta(object):
>abstract = true
> 
> class StudentProfile():
>   #student fields
>   class Meta(object):
>abstract = true
> 
> class Profile(TutorProfile, StudentProfile, UserProfile):
>   pass
> 
> 
> The idea is taken from the Django best practices book. However, I am curious 
> if there is any other way with lesser space usage. Any thoughts?
> 
> PS: I also asked the same question on stackoverflow : 
> http://stackoverflow.com/questions/36404889/django-multiple-user-profiles-with-class-based-views-best-practices
>  but didn't get any responses.


First of all, I don’t like multiple inheritance.  You are in control of all of 
the parent classes, so it might not blow up in your face, but there still night 
be problems down the line.  Second, I think this might be the same as just 
creating a single class with all of the fields, so there’s no reason to create 
three abstract classes for it to inherit from.

How old is the Django best practices book you are using?  Because starting with 
1.5, you should be using a custom User model 

 instead of a constant profile.

What I would do, and I’d love to hear some debate about it, is put most (or 
all, depending on requirements) of the fields from the UserProfile in the new 
custom user model, and have two not-abstract profiles with one-to-one fields to 
the user.  If the things in UserProfile don’t make sense for all users, then 
make three profiles which all point to the custom user model.

Peter of the Norse
rahmc...@radio1190.org



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/D4629C3B-5B67-439B-B6B7-0EA2CC7CDFF5%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


Integer field choice list keeps triggering migration

2016-05-02 Thread jorrit787
I have the following model and choice list:

BTW_TARIEF_CHOICES = {
(1, '6%'),
(2, '21%'),
(3, '0%'),
}


class FactuurItem(models.Model):
naam = models.CharField(max_length=100)
factuur_naam = models.CharField(max_length=100)
eenheid = models.CharField(max_length=10)
prijs = models.DecimalField(max_digits=6, decimal_places=2)
btw_tarief = models.IntegerField(choices=BTW_TARIEF_CHOICES, default=2)

class Meta:
ordering = ['naam']

def __str__(self):
return self.naam


Makemigrations creates a migration for the btw_tarief field every time I 
run it, even though the field hasn't changed. It shows up in every 
migration file that has been created since I added the field to the model. 
The only thing that seems different in every migration file is that the 
order of BTW_TARIEF_CHOICES is randomized:

class Migration(migrations.Migration):

dependencies = [
('common', '0021_auto_20160503_0849'),
]

operations = [
migrations.AlterField(
model_name='factuuritem',
name='btw_tarief',
field=models.IntegerField(choices=[(1, '6%'), (3, '0%'), (2, 
'21%')], default=2),
),
]


class Migration(migrations.Migration):

dependencies = [
('common', '0020_auto_20160502_1656'),
]

operations = [
migrations.AlterField(
model_name='factuuritem',
name='btw_tarief',
field=models.IntegerField(choices=[(2, '21%'), (3, '0%'), (1, 
'6%')], default=2),
),
]


class Migration(migrations.Migration):

dependencies = [
('common', '0019_auto_20160502_1604'),
]

operations = [
migrations.AlterField(
model_name='factuuritem',
name='btw_tarief',
field=models.IntegerField(choices=[(1, '6%'), (3, '0%'), (2, 
'21%')], default=2),
),
]


And so on... This happens on Django 1.9.5 and 1.9.6 .

Any ideas why this might be happening?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/88e66c3f-6ebe-4a14-93fe-1b865b712e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.