Re: "django.db.models.query.QuerySet" vs "django.db.models.QuerySet"

2015-09-29 Thread Tim Graham
Either way is okay; the original location isn't deprecated. I'd use the 
"convenience" import in django.db.models if it were me.

On Tuesday, September 29, 2015 at 2:00:00 PM UTC-4, Ilya Kazakevich wrote:
>
> In Django 1.6 it QuerySet was in package 
> "django.db.models.query.QuerySet". But since 1.7 it also may be imported 
> with "django.db.models.QuerySet".
>
> Is "django.db.models.query.QuerySet" deprecated since 1.7? What is the 
> "official" way to import QuerySet? I can't find any documentation regard 
> this subject.
>
>

-- 
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/a2be7d1f-3eaa-4e00-bff4-20c42c4c4e49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


upload zip or rar files

2015-09-29 Thread dk
I set up a form to upload files,  and every thing works fine,   the only 
problem is when I am in the webpage and I click the button to choose the 
file I want to upload doesn't show or zips, or rars.  I try playing with 
the input tag accept, from all the type of zips,  to leave it open to 
upload what ever file.

I try it in Firefox, chrome and IE,   I am missing something?

-- 
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/f3ee0eb3-c1c7-424b-87c2-4c63d10ec83d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


"django.db.models.query.QuerySet" vs "django.db.models.QuerySet"

2015-09-29 Thread Ilya Kazakevich
In Django 1.6 it QuerySet was in package "django.db.models.query.QuerySet". 
But since 1.7 it also may be imported with "django.db.models.QuerySet".

Is "django.db.models.query.QuerySet" deprecated since 1.7? What is the 
"official" way to import QuerySet? I can't find any documentation regard 
this subject.

-- 
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/6ebbd9ab-b0e8-486f-aa33-88005a6aa256%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin: Unknown fields

2015-09-29 Thread Florian Schweikert
On 29/09/15 18:47, Rolston Jeremiah wrote:
> 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(),

It's probably because of the ',' at each line end.
I think genus_id became a tuple of fields, remove them and try again :)

--
Florian

-- 
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/560ACDDF.7010201%40ist-total.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Admin: Unknown fields

2015-09-29 Thread Rolston Jeremiah


On Monday, September 28, 2015 at 6:56:42 PM UTC-4, 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
>
>
>
>
> Hello Polonkai,
>

Much thanks for responding to my cry for help!  I will make the 
suggested changes and correctionns. Thanks much.


Actually, I did adhere  to Django's typical  workflow as you hinted to:

python manage.py  makemigrations 
python manage.py migrate

But when I examined the 0001_initial.py file in the migrations folder:



from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='ActiveContracts',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='AddressBook',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='Agents',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='ArchivedContracts',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='Genus',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='ManagementUnits',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='ProductionUnits',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='Products',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, auto_created=True)),
],
),
migrations.CreateModel(
name='SoilProfiles',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', 
primary_key=True, 

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

2015-09-29 Thread Carsten Fuchs

Hi John,

Am 28.09.2015 um 15:54 schrieb John Lucas:

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


I've recently had a similar / the same question. See this thread, which also contains 
the solution that worked very well for me:

http://thread.gmane.org/gmane.comp.python.django.user/172038

Best regards,
Carsten

--
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/560AB725.30509%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: Platform.sh alternative for Django?

2015-09-29 Thread Aaron C. de Bruyn
Heroku is another paid alternative.

For myself, I purchase a $5/mo digital ocean server and install
'dokku' (https://github.com/progrium/dokku) so I can 'git push'.

For automated builds I use Drone CI (https://github.com/drone/drone)
which can also be installed on the same (or a separate) server.

If you need more and more resources as things grow (Redis, Postgres,
MySQL, etc...) you can either spin up additional cheap servers, or
'grow' your existing servers.

-A



On Tue, Sep 29, 2015 at 8:38 AM, Radek Svarz  wrote:
> Hi,
>
> there is the https://platform.sh/ for PHP world for Continuous Deployment.
>
> Do you know of something similar for Django apps?
>
> Thanks, Radek
>
> --
> 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/3c25216f-66e8-4c6d-9f95-15dce6dd1975%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/CAEE%2BrGpbVKWps8vLVfg%2B6wE2VA9PTE2QrBvdn0EpjYXdcPgdSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Platform.sh alternative for Django?

2015-09-29 Thread Radek Svarz
Hi,

there is the https://platform.sh/ for PHP world for Continuous Deployment.

Do you know of something similar for Django apps?

Thanks, Radek

-- 
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/3c25216f-66e8-4c6d-9f95-15dce6dd1975%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django inlineform not adding cinema field info on save

2015-09-29 Thread drifter


I have a inline form which looks like the snapshot above but when I save 
the "Cinema, Movie type and Price" doesn't get added to the additional 
fields (each starts time is another instance of the field). For example the 
second line with 2015-10-02 Cinema2 will only be saved on the instance of 
Show 11:00so it only saves on the first instance.

This is the model Show:

class Show(models.Model):

MOVIE_TYPES = (
('2', '2D'),
('3', '3D'),
)

CINEMAS = (
('C1', 'Cinema 1'),
('C2', 'Cinema 2'),
('C3', 'Cinema 3'),
('C4', 'Cinema 4'),
)

movie = models.ForeignKey('Movie', related_name='shows')
venue = models.ForeignKey(Venue)
old_details = models.TextField(blank=True, editable=False,)
starts = models.DateField(db_index=True,)
starts_time = models.TimeField(db_index=True,)
couple_price = models.IntegerField(blank=True, null=True)
vip = models.IntegerField(blank=True, null=True)
cinema = models.CharField(
max_length=10,
choices=CINEMAS,
blank=True,
null=True
)
comment = models.TextField(blank=True, )
booking_url = models.URLField(blank=True, )
created = models.DateTimeField(editable=False, db_index=True,)
modified = models.DateTimeField(editable=False, db_index=True,)
price = models.IntegerField(blank=True, null=True)
new_price = models.IntegerField(blank=True, null=True)
movie_type = models.CharField(
max_length=1,
choices=MOVIE_TYPES,
blank=True,
null=True
)

class Meta:
ordering = ['starts', 'starts_time',]
verbose_name = 'movie show'

def __unicode__(self):
return u'%s - %s - %s %s' % (self.movie.name, self.venue.name, 
self.starts, self.starts_time)

def save(self):
if not self.id:
self.created = datetime.datetime.now()
self.modified = datetime.datetime.now()
super(Show, self).save()

def movie_type_str(self):
if not self.movie_type:
return '-'
else:
return self.movie_type + 'D'

and the form...

class ShowInlineForm(forms.ModelForm):

def __init__(self, *args, **kwargs):
super(ShowInlineForm, self).__init__(*args, **kwargs)
theatres = Category.objects.get(slug='movie-theatres')
self.fields['venue'].queryset = 
Venue.objects.filter(categories=theatres, visible=True,).order_by('name')

class Meta:
fields = [
'venue',
'price',
'movie_type',
'starts',
'cinema',
'starts_time',
]

in the admin.py

class MovieShowInline(admin.TabularInline):

formfield_overrides = {
models.TimeField: {'widget': AdminTimeWidget(format='%H:%M')},
models.TextField: {'widget': TextInput()},
}
model = Show
extra = 1
template = 'admin/movies/show/inline_edit/tabular.html'
form = ShowInlineForm
exclude = ('comment', 'booking_url',)

def queryset(self, request):
"""Do not show shows older than today """

qs = super(MovieShowInline, self).queryset(request)
return 
qs.filter(starts__gte=datetime.date.today()).order_by('venue__name', 'starts', 
'starts_time')
class MovieShowAdmin(CommonAdmin):
fields = ('name',)
readonly_fields = ('name',)
list_display = [
'name',
'modified_by',
'created_by',
'modified',
'created',
'visible',
]
inlines = [MovieShowInline,]
list_filter = ['modified', 'created', 'visible', 'showing']

and the form admin/movies/show/inline_edit/tabular.html

{% load i18n admin_static admin_modify %}.vTimeField { width:40px 
!important; }
  {{ inline_admin_formset.formset.management_form }}
   {{ inline_admin_formset.opts.verbose_name_plural|capfirst }}
   {{ inline_admin_formset.formset.non_form_errors }}
   
 
 {% for field in inline_admin_formset.fields %}
   {% if not field.widget.is_hidden %}
 {{ field.label|capfirst }}
 {% if field.help_text %}{% endif %}
 
   {% endif %}
 {% endfor %}
 
 {% trans "Copy?" %}
 {% comment %}
 {% if inline_admin_formset.formset.can_delete %}{% trans "Delete?" 
%}{% endif %}
 {% endcomment %}
 

 
 {% for inline_admin_form in inline_admin_formset %}
{% if inline_admin_form.form.non_field_errors %}
{{ 
inline_admin_form.form.non_field_errors }}
{% endif %}


  {% if inline_admin_form.has_auto_field %}{{ 
inline_admin_form.pk_field.field }}{% endif %}
  {{ inline_admin_form.fk_field.field }}
  {% spaceless %}
  {% for fieldset in inline_admin_form %}
{% for line in fieldset %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 

Re: Admin: Unknown fields

2015-09-29 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.