Re: Admin: Unknown fields

2015-09-28 Thread Gergely Polonkai
Hello,

I suspect you didn't make/run migrations:

python manage.py makemigrations
python manage.py migrate

The first command creat the so-called migration files that are required to
update the database by adding new tables and fields, while the second one
does the actual upgrade.

Also, allow me some comments.

You may want to omit genus_id from your model, as it gets created
automatically anyway. One field less to manage while you write your code.
Of course, it's up to you.

The second one is your choice field. By convention, Django people do it
this way:

EXAMPLE_CHOICES = (
('short code to store in DB', 'long text to display'),
…
)
field = models.CharField(choices=EXAMPLE_CHOICES)

My main point here other than conventions is that "short code" won't get
displayed for the user, so make your choice list based on this.

Third, eggplant is Solanum if I recall well :)

Best,
Gergely
On 29 Sep 2015 00:56, "Rolston Jeremiah"  wrote:

> Hello,
>
> I am new to Python and Django so please bear with me.
>
> I have  created a model(below) and would now like to access
> from the admin interface. As per instructions  I found on the
> django site (Part 2 tutorial version 1.8.4)
>
>
> model
>
> ///
>
> class Genus(models.Model):
> genus_id = models.AutoField(primary_key=True),
> scientific_genus = models.CharField(max_length=32),
> common_name = models.CharField(max_length=32),
> common_examples = models.TextField(),
> genus_choices = (
> ('Member Banana...','Musa'),
> ('Mango...','Magnifera'),
> ('Avocado...','Persea Americana'),
> ('Soursop, Custard, Sugar Apple...','Annona Reticulata'),
> ('Ginger, Tumeric ...','Zingiber Officinale Roscoe'),
> ('Persimmon','Diospyros'),
> ('Breadfruit...','Artocarpus Altilis'),
> ('Cherry ...','Prunus'),
> ('Grapes ...','Vitis'),
> ('Tomato ...','Lycopersicon'),
> ('EggPlant ...',''),
> ('Onion, Garlic ...','Allium'),
> ('Cashew ...','Anacardium'),
> ('Rice ...','Oryza'),
> ('Pepper ...','Capsicum'),
> ('Orange,Lemon, Lime ','Citrus')
> ),
> image_url = models.CharField(max_length=128),
> genus = models.CharField(max_length=32,choices=genus_choices),
> description = models.TextField()
>
>
> I edit  "admin.py"  so that it now looks like
>
>
> admin.py
>
> //
>
> from django.contrib import admin
> from cfxBase.models import Genus
> # Register your models here.
>
>
> class GenusAdmin(admin.ModelAdmin):
> fields = [
>'genus',
>'scientific_genus',
>'common_name',
>'description',
>'common_examples',
>'image_url'
> ]
>
> admin.site.register(Genus, GenusAdmin)
>
>
>
> 
>
> Now when I attempt the admin page add entry  for Genus I am getting this
> error:
>
>
> FieldError at /admin/cfxBase/genus/add/
>
> Unknown field(s) (scientific_genus, genus, common_name, common_examples,
>
>   description, image_url) specified for Genus.
>
>
> Check fields/fieldsets/exclude attributes of class GenusAdmi
>
>
>
> Your help will be  greatly appreciated
>
>
>
>
>
>
>
>
>
>
> --
> 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/3b131d1a-78b9-4294-adad-1040a5ab7a12%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/CACczBUKQ6ma72xvWmp4vftqdJj%3DNpSAURy%2B2VcY0SJE%2Bwwu7tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Drop constrailts

2015-09-28 Thread Григорий Крамаренко
In migrations I need delete constraints before creating table-partitioning.
But Django generates different constraint names on different servers.
On server 1:
ALTER TABLE "order_autoselect" ADD CONSTRAINT 
"order_autoselec_summary_id_1d623f742c26ae09_fk_order_summary_id" FOREIGN 
KEY ("summary_id") REFERENCES "order_summary" ("id") DEFERRABLE INITIALLY 
DEFERRED;

On server 2:
ALTER TABLE "order_autoselect" ADD CONSTRAINT 
"order_autoselect_summary_id_2c26ae09_fk_order_summary_id" FOREIGN KEY 
("summary_id") REFERENCES "order_summary" ("id") DEFERRABLE INITIALLY 
DEFERRED;


Version 1.8.4 uses on all servers.

The application is written for multiple installations in different 
organizations and on different servers.
Before, in version 1.4, the constraints were created without hashes and 
were really unique. And we could write one SQL script which will be 
executed after the command "syncdb" and will 100% work everywhere. Attempt 
to migrate the app to a new Django version 1.8 turned into such problems.

How make it? Or is it a bug in Django? Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0f20a0ce-22c6-4623-b164-0044dce8f612%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sending mail using smtp server

2015-09-28 Thread François Schiettecatte
You going to need to set EMAIL_USE_TLS = True, and  EMAIL_PORT = 587.

And you will need to set "Allow less secure apps: ON” on:

https://myaccount.google.com/security?hl=en

because  Google uses OAUTH (I think) and it is beyond the standard SMTP client 
(to the best of my recollection)

François

> On Sep 28, 2015, at 7:26 PM, Mike Dewhirst  wrote:
> 
> Rajat
> 
> In your settings.py file you need to tell Django about your mail server like 
> this ...
> 
> EMAIL_HOST =
> EMAIL_PORT =
> EMAIL_HOST_USER =
> EMAIL_HOST_PASSWORD =
> 
> https://docs.djangoproject.com/en/1.7/topics/email/
> 
> 
> 
> On 29/09/2015 5:07 AM, Rajat Singh wrote:
>> I want to know the how to send mail using google smtp server in django
>> 
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to django-users+unsubscr...@googlegroups.com
>> .
>> To post to this group, send email to django-users@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/162cda54-fe96-4dc5-8c27-a8a17926d1aa%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/5609CC89.9000609%40dewhirst.com.au.
> 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/5AC68360-419E-4553-8B53-6787F6799752%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sending mail using smtp server

2015-09-28 Thread Mike Dewhirst

Rajat

In your settings.py file you need to tell Django about your mail server 
like this ...


EMAIL_HOST =
EMAIL_PORT =
EMAIL_HOST_USER =
EMAIL_HOST_PASSWORD =

https://docs.djangoproject.com/en/1.7/topics/email/



On 29/09/2015 5:07 AM, Rajat Singh wrote:

I want to know the how to send mail using google smtp server in django

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/162cda54-fe96-4dc5-8c27-a8a17926d1aa%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/5609CC89.9000609%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Sending mail using smtp server

2015-09-28 Thread Rajat Singh
I want to know the how to send mail using google smtp server in django

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


Error

2015-09-28 Thread Rajat Singh
I am getting error while using the command in shell python manage,py 
runserver

-- 
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/1a6dfc6a-fdf4-4335-90b5-3377ac54e652%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Admin: Unknown fields

2015-09-28 Thread Rolston Jeremiah
Hello,

I am new to Python and Django so please bear with me.

I have  created a model(below) and would now like to access 
from the admin interface. As per instructions  I found on the 
django site (Part 2 tutorial version 1.8.4) 


model
///

class Genus(models.Model):
genus_id = models.AutoField(primary_key=True),
scientific_genus = models.CharField(max_length=32),
common_name = models.CharField(max_length=32),
common_examples = models.TextField(),
genus_choices = (
('Member Banana...','Musa'),
('Mango...','Magnifera'),
('Avocado...','Persea Americana'),
('Soursop, Custard, Sugar Apple...','Annona Reticulata'),
('Ginger, Tumeric ...','Zingiber Officinale Roscoe'),
('Persimmon','Diospyros'),
('Breadfruit...','Artocarpus Altilis'),
('Cherry ...','Prunus'),
('Grapes ...','Vitis'), 
('Tomato ...','Lycopersicon'), 
('EggPlant ...',''), 
('Onion, Garlic ...','Allium'),
('Cashew ...','Anacardium'),
('Rice ...','Oryza'),
('Pepper ...','Capsicum'),
('Orange,Lemon, Lime ','Citrus')
),
image_url = models.CharField(max_length=128),
genus = models.CharField(max_length=32,choices=genus_choices),
description = models.TextField()


I edit  "admin.py"  so that it now looks like


admin.py
//

from django.contrib import admin
from cfxBase.models import Genus
# Register your models here.


class GenusAdmin(admin.ModelAdmin):
fields = [
   'genus',
   'scientific_genus',
   'common_name',
   'description',
   'common_examples',
   'image_url'
]

admin.site.register(Genus, GenusAdmin)




Now when I attempt the admin page add entry  for Genus I am getting this 
error:


FieldError at /admin/cfxBase/genus/add/ 

Unknown field(s) (scientific_genus, genus, common_name, common_examples, 

  description, image_url) specified for Genus. 


Check fields/fieldsets/exclude attributes of class GenusAdmi



Your help will be  greatly appreciated










-- 
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/3b131d1a-78b9-4294-adad-1040a5ab7a12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting implicit m2m through table to explicit through model with Django 1.7 migrations

2015-09-28 Thread Simon Charette
Hi John,

Until #23034  is fixed you'll 
have to keep using migrations.SeparateDatabaseAndState to achieve the 
implicit to explicit conversion.

>From what I've read of your process everything should be working fine in 
the long term and your approach is safe.

Could you add a mention on the ticket tracking this feature addition about 
the workaround you and your team used to achieve similar results? I think 
this could be valuable to other users until the ticket is fixed.

Cheers,
Simon

Le lundi 28 septembre 2015 09:56:58 UTC-4, John Lucas a écrit :
>
> Hi all,
>
> I'm attempting to convert an implicit m2m through table to an explicit 
> through model and want to make sure I'm not shooting myself in the foot. 
> Any input would be greatly appreciated.
>
> My team was on Django 1.6 until a few months ago and was still living in 
> the South world. We had a need to take an implicit through table for a m2m 
> field and convert it to an explicit through model so we could add some 
> extra data to it. 
>
> To do so we:
> 1) Created the new model and set db_table on the model's Meta to the 
> existing implicit through table and setup the model's fields accordingly.
> 2) Created the south migration. There were no database changes since 
> everything lined up.
> 3) Added the additional fields to the new through model.
> 4) Created another south migration.
> 5) Ran the migrations.
>
> This worked well - we were able to convert the implicit through to an 
> explicit through and add extra fields while retaining our data.
>
> I'm now trying to do the same thing in the world of Django 1.7 
> migrations. The same process works, but when I run the migration created in 
> step 2 it fails because the table already exists. To get around this, I'm 
> experimenting with using migrations.SeparateDatabaseAndState. Since these 
> are purely state changes, it seemed reasonable to move all of the 
> operations created by the migration in step 2 to a list of 
> state_operations. This works! Nothing blows up and I'm able to add the 
> fields as needed.
>
> However, I'm concerned this might have repercussions down the line. I've 
> also experimented with keeping the model creation portion of the migration 
> as state operations, but moving the field alterations on the m2ms to the 
> top level operations list. This blows up with the following error: "you 
> cannot alter to or from M2M fields, or add or remove through= on M2M 
> fields." My understanding is that M2M field changes are disallowed because 
> it's difficult for the migrations to know what to do. Accordingly, I'm 
> worried I could be hacking myself into a corner.
>
> So - is my approach safe? Or will there be complications down the line?
>
> Thank you,
> John
>

-- 
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/07df7a5b-9bfa-4f48-8e8a-02d0b438b77e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Converting implicit m2m through table to explicit through model with Django 1.7 migrations

2015-09-28 Thread John Lucas
Hi all,

I'm attempting to convert an implicit m2m through table to an explicit 
through model and want to make sure I'm not shooting myself in the foot. 
Any input would be greatly appreciated.

My team was on Django 1.6 until a few months ago and was still living in 
the South world. We had a need to take an implicit through table for a m2m 
field and convert it to an explicit through model so we could add some 
extra data to it. 

To do so we:
1) Created the new model and set db_table on the model's Meta to the 
existing implicit through table and setup the model's fields accordingly.
2) Created the south migration. There were no database changes since 
everything lined up.
3) Added the additional fields to the new through model.
4) Created another south migration.
5) Ran the migrations.

This worked well - we were able to convert the implicit through to an 
explicit through and add extra fields while retaining our data.

I'm now trying to do the same thing in the world of Django 1.7 migrations. 
The same process works, but when I run the migration created in step 2 it 
fails because the table already exists. To get around this, I'm 
experimenting with using migrations.SeparateDatabaseAndState. Since these 
are purely state changes, it seemed reasonable to move all of the 
operations created by the migration in step 2 to a list of 
state_operations. This works! Nothing blows up and I'm able to add the 
fields as needed.

However, I'm concerned this might have repercussions down the line. I've 
also experimented with keeping the model creation portion of the migration 
as state operations, but moving the field alterations on the m2ms to the 
top level operations list. This blows up with the following error: "you 
cannot alter to or from M2M fields, or add or remove through= on M2M 
fields." My understanding is that M2M field changes are disallowed because 
it's difficult for the migrations to know what to do. Accordingly, I'm 
worried I could be hacking myself into a corner.

So - is my approach safe? Or will there be complications down the line?

Thank you,
John

-- 
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/7eec0efc-ea4e-47a7-8f8c-7461cd97063c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin suitable for external users?

2015-09-28 Thread Derek
I'd say for non-technical users, you may want something custom; 
particularly if they are only working with a smaller sub-set of the data.

We have users that are fairy technical (working in the science domain) that 
are used to large grid-like data displays (typically in spreadsheets).  So, 
for them, the admin interface makes sense; and be aware that there is a 
*ton* of customisation you can add to the interface (e.g. actions; 
third-party "skins") to make it more "user friendly".  

You can, of course, start with the admin and then expand it / add-on custom 
functionality as needed over time - its not an "either/or" situation.

(PS You can send a private email if you need details on how our project 
works.)

On Wednesday, 23 September 2015 23:39:58 UTC+2, Joshua Pokotilow wrote:
>
> How technical are your users?
>
> Not very technical, necessarily. They're normal end-users.
>
>
>>

-- 
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/36d75f66-752f-4ff8-b84e-b2d3d5b30e3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.