Re: Want to change home->blog to Admin home -> blog

2014-11-17 Thread Sachin Tiwari


On Thursday, November 13, 2014 7:49:28 PM UTC+5:30, Sachin Tiwari wrote:
>
>  Hi All,
>
>  I want to change Home link at admin page to Admin Home -> blog -> ...
>
>  I tried by modifying  base.html and base_site.html in my 
> templates/admin/, but it would work
>
>  {% block breadcrumbs %}
> 
> {% trans ' Admin Home' %}
> {% if title %} › {{ title }}{% endif %}
> 
> {% endblock %}
>
>Please help..
>
>
>
>

Hi Collin,

No changes will be reflected, Please suggest 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/4c36-0a35-4009-af20-454ab569eff2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: daterange filter

2014-11-17 Thread Sachin Tiwari


On Saturday, November 15, 2014 4:47:12 PM UTC+5:30, Sachin Tiwari wrote:
>
> Hi All,
>
> I am using  below  daterange filter package but it did not work if 
>  from_date and to_date field are same,
>
>
> https://github.com/DXist/django-daterange-filter/blob/master/daterange_filter/filter.py
>
> Please suggest the solution
>
> I was trying by converting to_date + timedelta(days=1) but it gives below 
> error 
>
>
> time data '' does not 
> match format '%Y-%m-%d'
>
>
> Edited Code of above link
>
> import datetime
>
> to_date = self.form.fields.get('measureddate__lte')
> #toDate = datetime.datetime.strptime('2014-11-15', "%Y-%m-%d").date()
> toDate = datetime.datetime.strptime(to_date.__str__(), "%Y-%m-%d").date() 
> //Error
> toTotom = toDate + datetime.timedelta(days=1)
> self.replace_value_with_definition('measureddate__lte', toTotom.__str__())
>
>
>
>
> def replace_value_with_definition(self,key_to_find, definition):
> for key in self.form.cleaned_data.keys():
> if key == key_to_find:
> self.form.cleaned_data[key] = definition
> return self.form.cleaned_data
>
>
>
>
>

Hi Collin,

Thanks for your kind support,

Sharing more details,

self.form.cleaned_data.get('measureddate__lte')

gives below error,

[u"'None' value has an invalid format. It must be in -MM-DD 
HH:MM[:ss[.uu]][TZ] format."]


Original implementation is available at above link,

This filter does not show the event if both dates are same, for e.g. 
from_date : 2014-11-18 to_date : 2014-11-18, then events of today date will 
not be displayed.

Please suggest the solution,

class DateRangeForm(forms.Form):

def __init__(self, *args, **kwargs):
self.field_name = kwargs.pop('field_name')
super(DateRangeForm, self).__init__(*args, **kwargs)

   
self.fields['%s__gte' % self.field_name] = forms.DateField(
label='', widget=forms.widgets.DateInput(format="%Y-%m-%d",
attrs={'placeholder': _('From date')}), localize=True, 
input_formats="%Y-%m-%d",
required=False)
self.fields['%s__lte' % self.field_name] = forms.DateField(
label='', widget=forms.widgets.DateInput(format="%Y-%m-%d",
attrs={'placeholder': _('To date')}), localize=True, 
input_formats="%Y-%m-%d",
required=False)


class DateRangeFilter2(admin.filters.DateFieldListFilter):
template = 'daterange_filter/filter.html'

def __init__(self, field, request, params, model, model_admin, 
field_path):
super(DateRangeFilter2, self).__init__(
field, request, params, model, model_admin, field_path)

self.form = self.get_form(request)
self.field_generic = '%s__' % field_path
self.date_params = dict([(k, v) for k, v in params.items()
 if k.startswith(self.field_generic)])

 def expected_parameters(self):
return [self.lookup_kwarg_since, self.lookup_kwarg_until]

def get_form(self, request):
return DateRangeForm(data=self.used_parameters,
 field_name=self.field_path)

def replace_value_with_definition(self,key_to_find, definition):
for key in self.form.cleaned_data.keys():
if key == key_to_find:
self.form.cleaned_data[key] = definition
return self.form.cleaned_data

def queryset(self, request, queryset):
if self.form.is_valid():
   

to_date = self.form.cleaned_data.get('measureddate__gte')
#if isinstance(to_date, forms.DateField):
#to_date = now.replace(hour=0, minute=0, second=0)

#from_date = self.form.fields.get('measureddate__lte')
from_date = self.form.cleaned_data.get('measureddate__lte')
#if isinstance(from_date, forms.DateField):
#from_date = now.replace(hour=0, minute=0, second=0)
   
#return 
queryset.filter(measureddate__gte=datetime.date(from_date), 
measureddate__lte=datetime.date(to_date))
return queryset.filter(measureddate__gte=from_date.__str__(), 
measureddate__lte=to_date.__str__())
   else:
return queryset

FieldListFilter.register(
lambda f: isinstance(f, forms.DateField), DateFieldListFilter)


[u"'None' value has an invalid format. It must be in -MM-DD 
HH:MM[:ss[.uu]][TZ] format."]


-- 
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/ae6b4e01-6a2f-454e-9cac-17f37bbe099a%40googlegroups.com.
For more options, visit https://groups.google.com/

Re: Need help with unique_together - on ForeignKey and Boolean field

2014-11-17 Thread ThomasTheDjangoFan
Hi Javier,

oh yes! You seem to be a really creative and experienced programmer!  [image: 
smile.png] 

My solution will be way number 5:
5) Do not set unique_together - forget about it and give the model a 
function "get_default_image", which returns the first "default_image=True" 
in the list.

Thanks a lot for your help! This was really inpiring! [image: smile.png] 

Have a good one

Am Montag, 17. November 2014 15:12:50 UTC+1 schrieb Javier Guerra:
>
> On Mon, Nov 17, 2014 at 6:10 AM, ThomasTheDjangoFan 
> > wrote: 
> > 
> > How would you do this? Can you give me a hint? 
>
>
> 4 different ways: 
>
> - don't do it as a flag, add a 'defaultImage=ForeignKey(ProductImage)' 
> to the Product class. 
>
> - don't use False for non-default, use NULL.  since two NULL values 
> aren't equal, they don't trip unique restriction 
>
> - don't use True/False, use an integer to give images some priority. 
> #1 is default, the others get 2...n 
>
> - use a partial index (supported by PosgreSQL and SQLite), it's not 
> directly supported by the ORM, but you can simply add as an "ALTER 
> TABLE CREATE UNIQUE INDEX ProductdefaultImage ON app_productimage 
> (image)  WHERE is_default_image;"  at creation and forget about it. 
>
>
> -- 
> Javier 
>

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


Re: Uploadfile form and CSS Style

2014-11-17 Thread donarb
On Monday, November 17, 2014 5:00:54 AM UTC-8, Russo wrote:
>
> Hi James,
>
> sorry I'm new on Django, can you give me some code example? I mean, hot to 
> define the CLASS or ID into the html with elements like this {{ 
> form.docfile }} ?
>
> Regards
> Russo
>
>
> El jueves, 13 de noviembre de 2014 15:48:16 UTC-4:30, James Schneider 
> escribió:
>>
>> If you are manually expressing the form, then you can add classes and 
>> ID's to any or all elements in the form. Even if you are using something 
>> like the {{ form.as_p }} method to display the form, you can still style it 
>> using CSS styles at the tag level. Just include a custom CSS file with your 
>> template.
>>
>> -James
>> On Nov 13, 2014 12:13 PM, "Russo"  wrote:
>>
>>>  Hi Kakar,
>>>
>>> but i tried and there is not way to change the bottom style, see the 
>>> html code
>>>
>>> 
>>> >> enctype="multipart/form-data">
>>> {% csrf_token %}
>>>
>>> {{ form.non_field_errors }}
>>> {{ form.docfile.label_tag }} {{ form.docfile.help_text 
>>> }}
>>> 
>>> {{ form.docfile.errors }}
>>> {{ form.docfile }}
>>> 
>>> 
>>> 
>>>
>>> as it is a form there is no way to change style ¿?
>>>
>>> Regards/AR
>>>
>>>
>>> El 13/11/2014 a las 03:37 p.m., Kakar Nyori escribió:
>>>  
>>> Then you need to apply css to the form.
>>>
>>> On Fri, Nov 14, 2014 at 1:16 AM, Russo  
>>> wrote:
>>>
 Hi,

 i just implemented the uploadfile form on Django, and everything goes 
 greate, but i would like to do if it is possible to apply CSS styles to 
 the 
 upload botton on the forms, Anybody knows this?

 Regards
 Russo

 -- 
 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 http://groups.google.com/group/django-users.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/54650A9B.8040004%40musicparticles.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...@googlegroups.com.
>>> To post to this group, send email to django...@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/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@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/5465119E.2030707%40musicparticles.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

I assume you have a form class for your form. In that class file, you can 
define the class or any other attribute that is used by that widget in your 
form, something like this (note, this is sort of off the top of my head, 
but you should be able to get the idea):

class MyForm(forms.Form):
upload = forms.FileField(widget=forms.FileInput(attrs={'class': 
'some_style' }))

-- 
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/87a213ab-3a49-4f6d-b01f-4a1679d122dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.6 admin force db commit

2014-11-17 Thread PRyan
Sorry. I am trying this in model_save().

On Monday, November 17, 2014 4:38:56 PM UTC-7, PRyan wrote:
>
> I'm trying to force a db commit on our users admin page. I call obj.save() 
> then want to call sync_marketing(obj.id). When sync_marketing pulls the 
> User object from the db by the id, it gets the data before the save, not 
> the data afterwards.
>
> sync_marketing is ran via celery (apply_async) and we really don't want to 
> use countdown to delay it. i need to force the db to commit that save after 
> I call save so then when celery pulls from the db, it is the new data. 
>
> I've tried transaction.savepoint and savepoint_commit, no luck. If i 
> set_autocommit to true (get_autocommit shows False) I get a "forbidden in 
> atomic block" error.
>
> I've tried with and without the atomic decorator. I don't know how to make 
> it non-atomic, if that is the right path, etc.
>
> Any suggestions would be appreciated. 
> 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/db11732c-ccc5-44e9-a945-facf996e9386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.6 admin force db commit

2014-11-17 Thread PRyan
I'm trying to force a db commit on our users admin page. I call obj.save() 
then want to call sync_marketing(obj.id). When sync_marketing pulls the 
User object from the db by the id, it gets the data before the save, not 
the data afterwards.

sync_marketing is ran via celery (apply_async) and we really don't want to 
use countdown to delay it. i need to force the db to commit that save after 
I call save so then when celery pulls from the db, it is the new data. 

I've tried transaction.savepoint and savepoint_commit, no luck. If i 
set_autocommit to true (get_autocommit shows False) I get a "forbidden in 
atomic block" error.

I've tried with and without the atomic decorator. I don't know how to make 
it non-atomic, if that is the right path, etc.

Any suggestions would be appreciated. 
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/6989fb66-ef13-423d-a501-75cf1d092f09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best practices question on django-guardian and permissions

2014-11-17 Thread T Kwn
Hi all,
I'm a relative beginner to django. For a test project I'm making an app 
where users can create leaderboards. Owners of the leaderboards can add 
other people as members and delete boards. Members of the leaderboards can 
update entries. Anonymous people can view the leaderboards.

   I used django-registration for login and I'm using django-guardian for 
permissions. What I'm confusing myself about is this whether I should add 
fields in my model to track the owner and members. If I don't, I could 
still use (I think) guardian to restrict permissions. Here are the 
questionable entries:

class LeaderBoard(models.Model):
   owner = models.ManyToManyField(User)   <- do I need this?
   other stuff...


class LeaderBoardMembers(models.Models):  < do I need this 
model at all?
   member = models.ManyToManyFields(User)
   board = models.ManyToManyFields(LeaderBoard)

Then I give the Owner permission for editing Members, deleting board. And I 
give Members, permission to update entries. But if I'm using guardian to 
handle permissions, do I even need to add these fields to the model? They 
don't seem to be required for any functionality. However, if I remove them, 
how would I know who is a member of the board or the owner of a board? 

-- 
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/cf5aede4-d72b-440e-ab1a-e49fc82aacc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Related Names Not Working

2014-11-17 Thread Collin Anderson
Hello,

I don't think you need a GenericRelation unless you're using a 
GenericForeignKey.

Would it work to use plan model.ForeignKey instead of GenericRelation?

Collin

On Monday, November 17, 2014 12:50:09 PM UTC-5, Shaun Livingston wrote:
>
> Hi, 
> I have two different apps that contain classes of the same name, and using 
> a related name in a GenericRelation doesn't seem to be helping. Here are 
> the details:
>
> In both of the apps I have "Source" and "Variable." They're not the same 
> for either app, so I can't just create one. These apps are called "hs_core" 
> and "ref_ts." In both apps I have a class called 
> "Metadata" that has a GenericRelation to both of the 
> Source and Variable classes. So I added a related_name in order to 
> differentiate between the two in the database. It didn't seem to have any 
> effect at all. Here are some snippets of the code (I can add more if you 
> need):
>
> In ref_ts:
> class Source(AbstractMetaDataElement):
> term = 'Source'
> derived_from = models.CharField(max_length=300)
> organization = models.CharField(max_length=200, null=True)
> source_description = models.CharField(max_length=400, null=True)
>
> def __unicode__(self):
> return self.derived_from
>
> @classmethod
> def create(cls, **kwargs):
> if 'derived_from' in kwargs:
> # check the source doesn't already exists - source needs to be 
> unique per resource
> if 'metadata_obj' in kwargs:
> metadata_obj = kwargs['metadata_obj']
> metadata_type = 
> ContentType.objects.get_for_model(metadata_obj)
> src = Source.objects.filter(derived_from= 
> kwargs['derived_from'], object_id=metadata_obj.id, 
> content_type=metadata_type).first()
> if src:
> raise ValidationError('Source:%s already exists for 
> this resource.' % kwargs['derived_from'])
> src = 
> Source.objects.create(derived_from=kwargs['derived_from'], 
> organization=kwargs.get('organization'),source_description=kwargs.get('source_description'),
>  
> content_object=metadata_obj)
> return src
> else:
> raise ValidationError('Metadata instance for which source 
> element to be created is missing.')
> else:
> raise ValidationError("Source data is missing.")
>
> @classmethod
> def update(cls, element_id, **kwargs):
> src = Source.objects.get(id=element_id)
> if src:
> if 'derived_from' in kwargs:
> src.derived_from = kwargs['derived_from']
> if 'organization' in kwargs:
> src.organization = kwargs['organization']
> if 'source_description' in kwargs:
> src.source_description = kwargs['source_description']
> src.save()
> else:
> raise ObjectDoesNotExist("No source element was found for the 
> provided id:%s" % element_id)
>
> @classmethod
> def remove(cls, element_id):
> src = Source.objects.get(id=element_id)
> if src:
> src.delete()
> else:
> raise ObjectDoesNotExist("No source element was found for 
> id:%d." % element_id)
>
> class RefTSMetadata(CoreMetaData):
> ...
> variables = generic.GenericRelation(Ref_TS_Variable, 
> related_name='ref_ts_variables')
> sources = generic.GenericRelation(Ref_TS_Source, 
> related_name='ref_ts_sources')
> ...
>
> @classmethod
> def get_supported_element_names(cls):
> # get the names of all core metadata elements
> elements = super(RefTSMetadata, cls).get_supported_element_names()
> # add the name of any additional element to the list
> elements.append('Method')
> elements.append('QualityControlLevel')
> elements.append('Variable')
> elements.append('Site')
> return elements
>
> @property
> def resource(self):
> return self._refts_resource.all().first()
>
> def get_xml(self):
> ...
>
>

-- 
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/c0222ff8-dacc-4a10-afe2-23e3f9f1adda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Uploadfile form and CSS Style

2014-11-17 Thread Collin Anderson
Hi Russo,

There should be an auto-generated id, in this case probably #id_docfile for 
that field. You could check the generated html source to be sure. (or 
"Inspect Element" in a browser.)

Collin


On Monday, November 17, 2014 8:00:54 AM UTC-5, Russo wrote:
>
> Hi James,
>
> sorry I'm new on Django, can you give me some code example? I mean, hot to 
> define the CLASS or ID into the html with elements like this {{ 
> form.docfile }} ?
>
> Regards
> Russo
>
>
> El jueves, 13 de noviembre de 2014 15:48:16 UTC-4:30, James Schneider 
> escribió:
>>
>> If you are manually expressing the form, then you can add classes and 
>> ID's to any or all elements in the form. Even if you are using something 
>> like the {{ form.as_p }} method to display the form, you can still style it 
>> using CSS styles at the tag level. Just include a custom CSS file with your 
>> template.
>>
>> -James
>> On Nov 13, 2014 12:13 PM, "Russo"  wrote:
>>
>>>  Hi Kakar,
>>>
>>> but i tried and there is not way to change the bottom style, see the 
>>> html code
>>>
>>> 
>>> >> enctype="multipart/form-data">
>>> {% csrf_token %}
>>>
>>> {{ form.non_field_errors }}
>>> {{ form.docfile.label_tag }} {{ form.docfile.help_text 
>>> }}
>>> 
>>> {{ form.docfile.errors }}
>>> {{ form.docfile }}
>>> 
>>> 
>>> 
>>>
>>> as it is a form there is no way to change style ¿?
>>>
>>> Regards/AR
>>>
>>>
>>> El 13/11/2014 a las 03:37 p.m., Kakar Nyori escribió:
>>>  
>>> Then you need to apply css to the form.
>>>
>>> On Fri, Nov 14, 2014 at 1:16 AM, Russo  
>>> wrote:
>>>
 Hi,

 i just implemented the uploadfile form on Django, and everything goes 
 greate, but i would like to do if it is possible to apply CSS styles to 
 the 
 upload botton on the forms, Anybody knows this?

 Regards
 Russo

 -- 
 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 http://groups.google.com/group/django-users.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/54650A9B.8040004%40musicparticles.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...@googlegroups.com.
>>> To post to this group, send email to django...@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/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@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/5465119E.2030707%40musicparticles.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/aeaccaa9-8e93-4266-8aca-94f81ad8d992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get django default model field value to be a parent attribute value

2014-11-17 Thread Collin Anderson
Hello,

The issue is with the "default=moda.asDefault". That won't work in this 
case. If you remove that, does your save method do what you are trying to 
do?

Collin

On Sunday, November 16, 2014 7:22:34 AM UTC-5, Matlau Issu wrote:
>
> I want the default modB localField value to be the modA wantedField value 
> corresponding to the foreign key. This would gives :
>
> class modA(models.Model):
> wantedField = models.CharField(max_length=9)
> [ ... other fields ...]
> def asDefault():
> return wantedField
>
> class modB(models.Model): 
> moda= models.ForeignKey(modA)
> [ ... other fields ...]
> localField  = models.CharField(max_length=9,default=moda.asDefault)
> def save(self, *args, **kwargs):
> if self.pk is None:
> if self.moda and not self.localField:
> self.localField = self.moda.wantedField
> super(modB, self).save(*args, **kwargs)
>
> Also, would the approach be the same with any other field type ?
> Anyway, for the moment it returns:
>
> AttributeError: 'ForeignKey' object has no attribute 'asDefault'
>
> Thanks for your help
>

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


Re: daterange filter

2014-11-17 Thread Collin Anderson
Hello,

to_date = self.form.fields.get('measureddate__lte')

I think you want something more like this:

self.form.cleaned_data.get('measureddate__lte')

Collin

On Saturday, November 15, 2014 6:17:12 AM UTC-5, Sachin Tiwari wrote:
>
> Hi All,
>
> I am using  below  daterange filter package but it did not work if 
>  from_date and to_date field are same,
>
>
> https://github.com/DXist/django-daterange-filter/blob/master/daterange_filter/filter.py
>
> Please suggest the solution
>
> I was trying by converting to_date + timedelta(days=1) but it gives below 
> error 
>
>
> time data '' does not 
> match format '%Y-%m-%d'
>
>
> Edited Code of above link
>
> import datetime
>
> to_date = self.form.fields.get('measureddate__lte')
> #toDate = datetime.datetime.strptime('2014-11-15', "%Y-%m-%d").date()
> toDate = datetime.datetime.strptime(to_date.__str__(), "%Y-%m-%d").date() 
> //Error
> toTotom = toDate + datetime.timedelta(days=1)
> self.replace_value_with_definition('measureddate__lte', toTotom.__str__())
>
>
>
>
> def replace_value_with_definition(self,key_to_find, definition):
> for key in self.form.cleaned_data.keys():
> if key == key_to_find:
> self.form.cleaned_data[key] = definition
> return self.form.cleaned_data
>
>
>
>
>
>

-- 
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/539080d7-c467-4c80-ab30-50b34aca5803%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Want to change home->blog to Admin home -> blog

2014-11-17 Thread Collin Anderson
Hello,

Interesting. What happened when you tried changing the link?

Do any changes to the template have any effect?

Collin

On Thursday, November 13, 2014 9:19:28 AM UTC-5, Sachin Tiwari wrote:
>
>  Hi All,
>
>  I want to change Home link at admin page to Admin Home -> blog -> ...
>
>  I tried by modifying  base.html and base_site.html in my 
> templates/admin/, but it would work
>
>  {% block breadcrumbs %}
> 
> {% trans ' Admin Home' %}
> {% if title %} › {{ title }}{% endif %}
> 
> {% endblock %}
>
>Please help..
>
>
>
>

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


Re: Users can give permissions they don't have.

2014-11-17 Thread Collin Anderson
On Friday, November 14, 2014 9:25:28 PM UTC-5, RLF_UNIQUE wrote:
>
> I want to make a "manager" user, who has a set of permissions (less than 
> what I have as admin). I want "manager" to be able to create users, groups, 
> permissions, etc, but restrict them to ONLY the permissions they have (if I 
> give them permission to add user, they can just give new user all available 
> permissions, even ones they don't have). Is there an easy way to do this?
>

Hello,

I don't think django has anything like this built-in, but it seems to me if 
you write some code for adding permissions, you could just manually check 
that the user has the permission before giving it to the next person.

Though of course, removing permissions from the first user wouldn't 
automatically remove them from the other people. 

Collin

-- 
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/f8c42c30-f061-434e-8002-3767ef49e41f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with runserver

2014-11-17 Thread Andreas Ka
Good News (for me): I got that sorted.

I had the exact same problems today, with a fresh install of
Java8+eclipse4.4+Anaconda(updated)+django1.7,
and it took me hours ...

SYMPTOM:
from Eclipse ... New PyDev project ... Django ...
I could just not persuade the thing
*to execute any django-admin routines, nor start the server.*
the error message always was something like:

*Could not import settings 'mysite.settings' (Is it on sys.path?): No
module named mysite.settings*
And something about a DJANGO_SETTINGS_MODULE environment variable.


Nowhere, e.g. in https://docs.djangoproject.com/en/1.7/howto/windows/ was
anything mentioned.

I am not 100% sure what it was in the end
(perhaps the django-admin.exe instead of django-admin.py ?) ,
but when I forgot about Eclipse&PyDev, and went to the commandline, and
executed these commands:

django-admin.exe startproject dummy
cd dummy
python manage.py migrate
python manage.py runserver 0.0.0.0:8000
Ctrl-C

I could suddenly create proper projects,
and start the server in Eclipse/pyDev

And it continues to work, even after:
rmdir /S dummy


Hope that helps somehow?


On Mon, Nov 17, 2014 at 10:01 PM, Avraham Serour  wrote:

> It is no clear what is your problem, in all that you wrote I don't see a
> question
>
> On Mon, Nov 17, 2014 at 3:24 PM, Det S. Pillner 
> wrote:
>
>> Hi,
>>
>> yes I know this topic exist, bud:
>>
>> I follow this book:
>>
>> http://www.djangobook.com/en
>>
>> and I can do all the nice things up to the database chapter. I use SVN to
>> save my data and to transfer to other computers. I'm wondering: it does not
>> working on the 'new' machine. Every time I got error message: can't find
>> .settings. Ok. I try a new project: All is working fine. I
>> transfer my data to a new machine: same like before: only error messages.
>> In between I read the 'complete internet' to fix this issue and try all
>> 'solutions'...
>>
>> My problem is: is there another place where django stores settings (yes i
>> know the default_settings). I can change something in settings and django
>> ignores this (I believe). My last try: set  PYTHONPATH to
>> . Wow, it works - one time. What is the
>> right way to set path to settings module? I also try sys.path.append in
>> settings/manage/wsgi.
>>
>> To test I install django in Windows (with Python XY): same problem. No
>> way to settings.
>>
>> Cheers
>>
>> --
>> 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/471379d9-a3c0-446d-b414-6e66ec501de4%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/CAFWa6t%2B0K0ZnD8hQ2upa%2BN2pMvQk60Jy_qH7AsJ7o7Xs%2B95mEA%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Replacing usage of form._errors in Django 1.7

2014-11-17 Thread Collin Anderson
Hi Alasdair,
 

> I'm upgrading to Django 1.7, and updating my forms to use the new 
> form.add_errors() method. 
>
> I have one remaining pattern which uses form._errors. 
>
> class MyForm(forms.Form): 
>  ... 
>  def clean(): 
> cleaned_data = super(MyForm, self).clean() 
> if not self._errors: 
> do_something() 
>
> I only want to call do_something() if no errors have been found during 
> the validation so far. I'd rather not use self._errors, since it is now 
> a private API according to the release notes [1]. What's the recommended 
> way to replace self._errors here? 
>
> Is it ok to use self.errors instead? Looking at the source code [2], 
> errors is a property, not an attribute. By the time the clean() method 
> is called, self._errors should have been created, so I think that 
> accessing self.errors should be safe.
>

The doc says it's ok.
"Since the field validation methods have been run by the time clean() is 
called, you also have access to the form’s errors attribute which contains 
all the errors raised by cleaning of individual fields."

https://docs.djangoproject.com/en/dev/ref/forms/validation/#form-subclasses-and-modifying-field-errors

Collin

-- 
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/8666367e-4186-4dce-8c18-341e7d819f31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


tutorial bugs: body-tag & view-tests

2014-11-17 Thread Andreas Ka
I have found errors in the tutorial:


https://docs.djangoproject.com/en/1.7/intro/tutorial06/#adding-a-background-image
didn't work until I put a  tag into  polls/templates/polls/index.html



https://docs.djangoproject.com/en/1.7/intro/tutorial05/#testing-our-new-view
these tests all come up with one or the other assertion error




python -c "import django; print(django.get_version())"
1.7.1

python --version
Python 2.7.3

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


Re: my mysite/templates/admin/base_site.html is ignored (tutorial unclear?)

2014-11-17 Thread Andreas Ka
> Show your view code
The tutorial did not create any view.py for the admin pages



See
https://docs.djangoproject.com/en/1.7/intro/tutorial02/#customize-the-admin-look-and-feel

We copied from the Django source files these two into:
/mysite/templates/admin/base_site.html
and
/mysite/templates/admin/index.html



and in
https://docs.djangoproject.com/en/1.7/intro/tutorial02/#customize-the-admin-change-list
edited:


admin.py

from django.contrib import admin

# Register your models here.

from django.contrib import admin
from polls.models import Choice, Question


class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3


class QuestionAdmin(admin.ModelAdmin):
fieldsets = [
(None,   {'fields': ['question_text']}),
('Date information', {'fields': ['pub_date'], 'classes':
['collapse']}),
]
inlines = [ChoiceInline]
list_display = ('question_text', 'pub_date', 'was_published_recently')
list_filter = ['pub_date']
search_fields = ['question_text']

admin.site.register(Question, QuestionAdmin)


---



On Mon, Nov 17, 2014 at 2:11 PM, Artie  wrote:

> Are you sure about correct path to your templates in views?
>
> Show your view code
>
> понедельник, 17 ноября 2014 г., 5:04:53 UTC+2 пользователь Andreas Ka
> написал:
>>
>> thanks for your answer.
>>
>> yes, I just tried that. Same result.
>>
>

> By now, I have understood much more about the templates.
>>
>

> But still, for the admin pages
>> mysite/templates/admin/base_site.html
>> doesn't work yet.
>>
>>
>> ...
>>
>
On Sun, Nov 16, 2014 at 7:19 PM, RLF_UNIQUE  wrote:

> Obviously you've restarted the server and refreshed the page in such a way
> to ensure it's not a caching issue ?

-- 
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/CAJAOMehiM9F9DM9NcR21-P-ZowjVsd4-U9DbDWsR2%2BnQAZ%3DFQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin Page Error

2014-11-17 Thread Collin Anderson
Hello,

Try completely uninstalling and reinstalling django.

The shortcuts module was changed from django/shortcuts/__init__.py to 
django/shortcuts.py, and I bet this error is related to that.

Collin

On Thursday, November 13, 2014 10:15:21 PM UTC-5, Daniel Pek wrote:
>
> Hi, 
>
> I'm new to Django, and I've been following the tutorial up until the 2nd 
> part where it asks your to runserver, and then access the admin page. 
> However, when i try to access 127.0.0.1:8000/admin/ i get this error:
>
> Here is the traceback:
>
> *Environment:*
>
>
> *Request Method: GET*
> *Request URL: http://127.0.0.1:8000/admin/ *
>
> *Django Version: 1.7.1*
> *Python Version: 2.7.8*
> *Installed Applications:*
> *('django.contrib.admin',*
> * 'django.contrib.auth',*
> * 'django.contrib.contenttypes',*
> * 'django.contrib.sessions',*
> * 'django.contrib.messages',*
> * 'django.contrib.staticfiles',*
> * 'polls')*
> *Installed Middleware:*
> *('django.contrib.sessions.middleware.SessionMiddleware',*
> * 'django.middleware.common.CommonMiddleware',*
> * 'django.middleware.csrf.CsrfViewMiddleware',*
> * 'django.contrib.auth.middleware.AuthenticationMiddleware',*
> * 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',*
> * 'django.contrib.messages.middleware.MessageMiddleware',*
> * 'django.middleware.clickjacking.XFrameOptionsMiddleware')*
>
>
> *Traceback:*
> *File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in 
> get_response*
> *  111. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)*
> *File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in 
> wrapper*
> *  225. return self.admin_view(view, cacheable)(*args, 
> **kwargs)*
> *File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in 
> _wrapped_view*
> *  105. response = view_func(request, *args, **kwargs)*
> *File "/Library/Python/2.7/site-packages/django/views/decorators/cache.py" 
> in _wrapped_view_func*
> *  52. response = view_func(request, *args, **kwargs)*
> *File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in 
> inner*
> *  199. from django.contrib.auth.views import 
> redirect_to_login*
> *File "/Library/Python/2.7/site-packages/django/contrib/auth/views.py" in 
> *
> *  8. from django.shortcuts import resolve_url*
>
> *Exception Type: ImportError at /admin/*
> *Exception Value: cannot import name resolve_url*
>
> and the error on the browser is:
>
> ImportError at /admin/
>
> cannot import name resolve_url
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.7.1Exception Type:ImportErrorException Value:
>
> cannot import name resolve_url
>
> Exception 
> Location:/Library/Python/2.7/site-packages/django/contrib/auth/views.py 
> in , line 8Python Executable:
> /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/PythonPython
>  
> Version:2.7.8Python Path:
>
> ['/Users/___/Documents/projects/speakeasy',
>  '/Library/Python/2.7/site-packages/pip-1.5.1-py2.7.egg',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
>  '/Library/Python/2.7/site-packages',
>  '/Library/Python/2.7/site-packages/PIL']
>
> Server time:Fri, 14 Nov 2014 14:09:33 +1100
>
> I dont know what is wrong? I think it might be a pathing problem with 
> Python but im not entirely sure, any help would be awesome, 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/034baac8-0590-4a0e-9b9a-470e79133edd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with runserver

2014-11-17 Thread Avraham Serour
It is no clear what is your problem, in all that you wrote I don't see a
question

On Mon, Nov 17, 2014 at 3:24 PM, Det S. Pillner 
wrote:

> Hi,
>
> yes I know this topic exist, bud:
>
> I follow this book:
>
> http://www.djangobook.com/en
>
> and I can do all the nice things up to the database chapter. I use SVN to
> save my data and to transfer to other computers. I'm wondering: it does not
> working on the 'new' machine. Every time I got error message: can't find
> .settings. Ok. I try a new project: All is working fine. I
> transfer my data to a new machine: same like before: only error messages.
> In between I read the 'complete internet' to fix this issue and try all
> 'solutions'...
>
> My problem is: is there another place where django stores settings (yes i
> know the default_settings). I can change something in settings and django
> ignores this (I believe). My last try: set  PYTHONPATH to
> . Wow, it works - one time. What is the
> right way to set path to settings module? I also try sys.path.append in
> settings/manage/wsgi.
>
> To test I install django in Windows (with Python XY): same problem. No way
> to settings.
>
> Cheers
>
> --
> 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/471379d9-a3c0-446d-b414-6e66ec501de4%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/CAFWa6t%2B0K0ZnD8hQ2upa%2BN2pMvQk60Jy_qH7AsJ7o7Xs%2B95mEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-17 Thread elcaiaimar
Hello! I've tried to do a makemigrations and a migrate but It returns "No 
changes detected" and "No migrations to apply".
Sorry Vijay Khemlani, I forgot it, you have my code here:

forms.py:

class PozosForm(forms.Form):
codpozo = forms.CharField(max_length=20)
coorx = forms.DecimalField(max_digits=13, decimal_places=5)
coory = forms.DecimalField(max_digits=13, decimal_places=5)
tipo = forms.CharField(max_length=20, required=False)
cotatrapa = forms.DecimalField(max_digits=6, decimal_places=2, 
required=False)
profundidad = forms.DecimalField(max_digits=6, decimal_places=2, 
required=False)
cotafondo = forms.DecimalField(max_digits=6, decimal_places=2, 
required=False)
material = forms.ChoiceField(choices=MATERIAL_POZOS, required=False)
materialpates = forms.ChoiceField(choices=MATERIAL_PATES, 
required=False)
diametro = forms.DecimalField(max_digits=20, decimal_places=2, 
required=False)
largotrapa = forms.DecimalField(max_digits=20, decimal_places=2, 
required=False)
seccionmayor = forms.DecimalField(max_digits=5, decimal_places=0, 
required=False)
seccionmenor = forms.DecimalField(max_digits=5, decimal_places=0, 
required=False)
numacometidas = forms.DecimalField(max_digits=2, decimal_places=0, 
required=False)

models.py:

class Pozo(models.Model):
# gid_pozo = models.IntegerField(primary_key=True)
# gid_colector = models.ForeignKey(Colector)
codpozo = models.CharField(max_length=20)
coorx = models.DecimalField(max_digits=13, decimal_places=5)
coory = models.DecimalField(max_digits=13, decimal_places=5)
tipo = models.CharField(max_length=20)
cotatrapa = models.DecimalField(max_digits=6, decimal_places=2, 
blank=True, null=True)
profundidad = models.DecimalField(max_digits=6, decimal_places=2, 
blank=True, null=True)
cotafondo = models.DecimalField(max_digits=6, decimal_places=2, 
blank=True, null=True)
material = models.CharField(max_length=20)
materialpates = models.CharField(max_length=20)
diametro = models.DecimalField(max_digits=20, decimal_places=2, 
blank=True, null=True)
largotrapa = models.DecimalField(max_digits=20, decimal_places=2, 
blank=True, null=True)
seccionmayor = models.DecimalField(max_digits=5, decimal_places=0, 
blank=True, null=True)
seccionmenor = models.DecimalField(max_digits=5, decimal_places=0, 
blank=True, null=True)
numacometidas = models.DecimalField(max_digits=2, decimal_places=0, 
blank=True, null=True)

I think everything is ok, but if you find errors, please tell me. If not, I 
will try to use south.

Thank you very much!


El domingo, 16 de noviembre de 2014 18:51:43 UTC+1, elcaiaimar escribió:
>
> Hello everybody, I've a problem with DecimalField at Forms. I've a long 
> form in my template and I want to left some fields in blank. I've declared 
> these fields with 
> *required=False*, but when I submit the form I receive this error: '*This 
> value must be a decimal number*'.
>
> I've tried to declare *blank=True, null=True* in respective fields in 
> models.py and make a syncdb but it continues without works
>
> Does somebody know how could I solve this problem?
>
> Thank you very much!
>

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


Re: Chrome Desktop Notification for Django

2014-11-17 Thread Collin Anderson
Hello,

The frontend part is simple:

var myEventSource = new EventSource('/path/to/eventsource/');
myEventSource.onmessage = function(e) {
  console.log(e.data)
}

The backend part is where things get complicated (untested code, as always 
:)
def eventsource(request):
last_id = request.META.get('HTTP_LAST_EVENT_ID')
id, data = get_new_data()  # somehow wait for some new data, and 
timeout after 10-50 seconds.
if not data:
  return HttpResponse('', content_type='text/event-stream')
assert '\n\n' not in data, 'two line breaks in a row signifies an end 
of message'
return HttpResponse('id: %s\ndata: %s' % (id, data), content_type=
'text/event-stream')

Collin

On Thursday, November 13, 2014 8:25:07 PM UTC-5, Max Nathaniel Ho wrote:
>
> HI Collin,
>
> Thanks for pointing that out. Apart from the documentation, do you have 
> any examples of how to implement it?
>
> Thank you.
>
> On Thu, Nov 13, 2014 at 5:55 AM, Collin Anderson  > wrote:
>
>> Hello,
>>
>> From a front-end standpoint, I personally like EventSource for this, 
>> though you could also use websockets or polling (checking every few 
>> minutes/seconds).
>>
>> https://developer.mozilla.org/en-US/docs/Web/API/EventSource
>> http://en.wikipedia.org/wiki/Server-sent_events
>>
>> Collin
>>
>> On Tuesday, November 11, 2014 8:12:43 PM UTC-5, Max Nathaniel Ho wrote:
>>>
>>> I found this excellent example on Chrome Desktop Notification - Chrome 
>>> desktop notification example? 
>>> 
>>>
>>> I am able to create the Desktop Notification by clicking a button. 
>>>
>>> However, that is pretty front-end. 
>>>
>>> I would like to find out how to link an event in the web app. For 
>>> example,  the event could be someone posting a job for a freelance work. 
>>> And user who is logged into the web app but not actively browsing on the 
>>> web page will be notified via the Chrome Desktop Notification. 
>>>
>>> Are there any examples of how I can create a Event Handler to listen to 
>>> data in the backend, and prompt the user via the Desktop Notification?
>>>
>>> Many 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/6b4132fb-0169-4a35-bec9-09b7ac987ba8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: need precise advice before final decision on Django

2014-11-17 Thread Collin Anderson
Hi Krishnaaknt,

On Thursday, November 13, 2014 2:05:08 PM UTC-5, krmane wrote:
>
> On 11/14/2014 12:07 AM, Avraham Serour wrote: 
> >> Now, I wish to know, if I can use the template's capacity of generating 
> > good forms and add good css without having a compulsion of using the 
> model 
> > part of Django? 
> > yes. 
> Any good article, blog or tutorial for this? 
>
You could try this if you haven't.
https://docs.djangoproject.com/en/dev/topics/forms/

Collin
 

-- 
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/527c0032-8a9b-4903-843a-3aad4482b74d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HStoreField can't adapt type 'dict'

2014-11-17 Thread Collin Anderson
Hi Fred,

On Thursday, November 13, 2014 11:29:30 AM UTC-5, Fred Stluka wrote:

>  Any reason you don't include the original question with your 
> reply?  Either by top-posting, or by quoting an excerpt?
>
I like to keep the emails as short as possible :)

Would provide context to your answers, making them more
> useful, especially to those of us reading them as email, not 
> at the Google Groups Web site.
>
I'll start doing that.

Thanks!
Collin

-- 
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/ff9cb463-f4d6-44ea-8a7f-513d8461d7ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django & gunicorn: KeyError with active log-config setting

2014-11-17 Thread Collin Anderson
Hello,

You may want to try asking this on the gunicorn mailing list if you haven't.

Thanks,
Collin


On Thursday, November 13, 2014 7:35:40 AM UTC-5, Florian Auer wrote:
>
> Hi
>
> I wanted to let my gunicorn server to log its config into a dedicated file.
> Therefore I added an extra line:
> exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
> --name $NAME \
> --workers $NUM_WORKERS \
> --user=$USER --group=$GROUP \
> --log-level=debug \
> --bind=unix:$SOCKFILE \
> --log-file=$ERRLOG \
> --access-logfile=$LOGFILE \
> --log-config=$CONFLOG # added this line with the \ before
>
> But when i start the server with supervisorctl i receive a "KeyError" for 
> the formatters.
> Traceback (most recent call last):
>   File "/webapps/sonar3/tekkoSONAR/../bin/gunicorn", line 11, in 
> sys.exit(run())
>   File 
> "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/app/wsgiapp.py", 
> line 74, in run
> WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
>   File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/app/base.py", 
> line 185, in run
> super(Application, self).run()
>   File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/app/base.py", 
> line 71, in run
> Arbiter(self).run()
>   File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/arbiter.py", 
> line 57, in __init__
> self.setup(app)
>   File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/arbiter.py", 
> line 88, in setup
> self.log = self.cfg.logger_class(app.cfg)
>   File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/glogging.py", 
> line 175, in __init__
> self.setup(cfg)
>   File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/glogging.py", 
> line 203, in setup
> disable_existing_loggers=False)
>   File "/usr/local/lib/python3.3/logging/config.py", line 70, in 
> fileConfig
> formatters = _create_formatters(cp)
>   File "/usr/local/lib/python3.3/logging/config.py", line 103, in 
> _create_formatters
> flist = cp["formatters"]["keys"]
>   File "/usr/local/lib/python3.3/configparser.py", line 937, in 
> __getitem__
> raise KeyError(key)
> KeyError: 'formatters'
> - log file exists
> - permissions math
> Keeping the --log-config out of the command, everything start correctly.
>
> Any help / idea welcome
>
>

-- 
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/a8963c3e-9bcd-44bb-bf18-e879c5c1940d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: modify attribute on a model based on the other attributes when it is added: model.clean method?

2014-11-17 Thread Collin Anderson
Hi Mike,

I'd do it in the model save() method.

Collin


On Wednesday, November 12, 2014 9:38:10 AM UTC-5, Michael wrote:
>
> Hi,
>
> I would like to modify an attribute on a model based on the other 
> attributes when it is added from the admin or elsewhere.
>
> For example:
>
> Model A: 
> has FK to Model B
> has FK to Model C
> 
> Model B: 
> has FK to Model C
>
>
> When I create a Model A, I choose a Model B so I'd like the FK to Model C 
> to be set automatically based on the FK to Model C that already exists on 
> Model B.
>
> I found the ``Model.clean`` method (
> https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean)
>  
> but it says that it is not invoked when you call your model’s save() method 
> so when is it invoked? I am a bit confused about the purpose of this method 
> then.
>
> I tried the clean method and I was able to make it work after some issues 
> but I am wondering whether that's the best way to do it?
>
> Thanks
> Mike
>
>

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


Re: How to keep backwards campabilities when upgradeing django to 1.7

2014-11-17 Thread Collin Anderson

>
> 1. The project structure are quite different between 1.5 and 1.7, what are 
> careful points when doing this?
>
I _think_ the main project structure changed between 1.4 and 1.5. In any 
case the main thing is to be sure you do is be consistent about how you 
import things. Either always say projectname.appname.models or always do 
appname.models.

2. We use south, how do I keep backwards compatibilities, in other words, 
> is that possible the south migration files still useful for rolling back 
> after upgrading it to django 1.7? 
>
I don't your south migration files will be helpful after switching to 
native django migrations.
 https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south
 

> 3. Any other things I must consider when upgrade our project?
>
As always, read the release notes. :)
https://docs.djangoproject.com/en/dev/releases/1.7/

I think it's also best to upgrade one django version at a time. 1.5->1.6, 
then 1.6->1.7.

-- 
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/b9849cc3-3c54-4828-ba03-7d6b285bbcbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread Andreas Kuhne
Thanks all for your answers.

I have been looking for alternatives today, and all I have seen have not
been python 3 compatible. What I can see however is that fabric (using a
separate python 2 environment) or ansible both only use ssh and should not
require installing anything on the servers. I suppose it'll have to be ok
to use one of them with python 2, instead of using python 3 completely. I
do think it's a shame that the community hasn't embraced python 3 more.
It's a pity that developers don't make sure that the code is python 3
compatible so that we can easily make the transition.

Oh well

Regards,

Andréas

2014-11-17 20:38 GMT+01:00 Matt Gushee :

> Hi--
>
> On Mon, Nov 17, 2014 at 12:27 PM, René Fleschenberg
>  wrote:
>
> > On Monday 17 November 2014 17:42:22 Brad Pitcher wrote:
> >> I agree Ansible is a good fit for your situation. Since Ansible works
> from
> >> yaml files, you don't have to write any Python 2.x compatible code as
> you
> >> would with Fabric.
>
> That's true.
>
> > I agree that Ansible is a nice tool, but AFAIK, it is not Python 3
> compatible.
>
> That's also true.
>
> In other words, you don't have to write Python 2 (or any Python) code
> to use Ansible, but you do have to have Python 2 installed on your
> target hosts, which I believe was the OP's objection.
>
> The question of transitioning to Python 3 has been discussed in the
> Ansible community; apparently the devs feel that moving to Python 3 at
> this time would not deliver any great benefits, and would risk
> alienating a large enterprise user base that is mostly using Python
> 2.x.
>
> I was also looking at other alternatives, and it doesn't seem like
> there are any good CM/deployment tools that currently support Python
> 3. It did look like Fabric is at least planning for a transition (I
> think I saw something about it in the docs ... or maybe they had a
> Python 3 development branch ... it was a few weeks ago, so I don't
> remember exactly).
>
> --
> Matt Gushee
>
> --
> 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/CABrD0edV8Ar6muh0eVP0UjjpYHf%3DbR%3DPHdE%2BpzSz_%3DRaa0bo6w%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUbm%3DoQJx411-5h6GG6HbuGbZiL%3DcW3%2BFqFF75%2BBo9jrJSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Using Related Names Not Working

2014-11-17 Thread Shaun Livingston
Hi, 
I have two different apps that contain classes of the same name, and using 
a related name in a GenericRelation doesn't seem to be helping. Here are 
the details:

In both of the apps I have "Source" and "Variable." They're not the same 
for either app, so I can't just create one. These apps are called "hs_core" 
and "ref_ts." In both apps I have a class called 
"Metadata" that has a GenericRelation to both of the 
Source and Variable classes. So I added a related_name in order to 
differentiate between the two in the database. It didn't seem to have any 
effect at all. Here are some snippets of the code (I can add more if you 
need):

In ref_ts:
class Source(AbstractMetaDataElement):
term = 'Source'
derived_from = models.CharField(max_length=300)
organization = models.CharField(max_length=200, null=True)
source_description = models.CharField(max_length=400, null=True)

def __unicode__(self):
return self.derived_from

@classmethod
def create(cls, **kwargs):
if 'derived_from' in kwargs:
# check the source doesn't already exists - source needs to be 
unique per resource
if 'metadata_obj' in kwargs:
metadata_obj = kwargs['metadata_obj']
metadata_type = 
ContentType.objects.get_for_model(metadata_obj)
src = Source.objects.filter(derived_from= 
kwargs['derived_from'], object_id=metadata_obj.id, 
content_type=metadata_type).first()
if src:
raise ValidationError('Source:%s already exists for 
this resource.' % kwargs['derived_from'])
src = 
Source.objects.create(derived_from=kwargs['derived_from'], 
organization=kwargs.get('organization'),source_description=kwargs.get('source_description'),
 
content_object=metadata_obj)
return src
else:
raise ValidationError('Metadata instance for which source 
element to be created is missing.')
else:
raise ValidationError("Source data is missing.")

@classmethod
def update(cls, element_id, **kwargs):
src = Source.objects.get(id=element_id)
if src:
if 'derived_from' in kwargs:
src.derived_from = kwargs['derived_from']
if 'organization' in kwargs:
src.organization = kwargs['organization']
if 'source_description' in kwargs:
src.source_description = kwargs['source_description']
src.save()
else:
raise ObjectDoesNotExist("No source element was found for the 
provided id:%s" % element_id)

@classmethod
def remove(cls, element_id):
src = Source.objects.get(id=element_id)
if src:
src.delete()
else:
raise ObjectDoesNotExist("No source element was found for 
id:%d." % element_id)

class RefTSMetadata(CoreMetaData):
...
variables = generic.GenericRelation(Ref_TS_Variable, 
related_name='ref_ts_variables')
sources = generic.GenericRelation(Ref_TS_Source, 
related_name='ref_ts_sources')
...

@classmethod
def get_supported_element_names(cls):
# get the names of all core metadata elements
elements = super(RefTSMetadata, cls).get_supported_element_names()
# add the name of any additional element to the list
elements.append('Method')
elements.append('QualityControlLevel')
elements.append('Variable')
elements.append('Site')
return elements

@property
def resource(self):
return self._refts_resource.all().first()

def get_xml(self):
...

-- 
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/547b2f3f-f5e9-4b57-ab94-3174d89ac1be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


problem with runserver

2014-11-17 Thread Det S. Pillner
Hi,

yes I know this topic exist, bud:

I follow this book:

http://www.djangobook.com/en

and I can do all the nice things up to the database chapter. I use SVN to 
save my data and to transfer to other computers. I'm wondering: it does not 
working on the 'new' machine. Every time I got error message: can't find 
.settings. Ok. I try a new project: All is working fine. I 
transfer my data to a new machine: same like before: only error messages. 
In between I read the 'complete internet' to fix this issue and try all 
'solutions'...

My problem is: is there another place where django stores settings (yes i 
know the default_settings). I can change something in settings and django 
ignores this (I believe). My last try: set  PYTHONPATH to 
. Wow, it works - one time. What is the 
right way to set path to settings module? I also try sys.path.append in 
settings/manage/wsgi. 

To test I install django in Windows (with Python XY): same problem. No way 
to settings.

Cheers

-- 
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/471379d9-a3c0-446d-b414-6e66ec501de4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem in deploying Django 1.7 application using openshift.

2014-11-17 Thread Girish Joshi
Hello all,
I want to deploy Django 1.7 application on openshift.
I've tried the steps given at 
https://stackoverflow.com/questions/26871381/deploying-a-local-django-app-using-openshift
but I'm getting 

503 Service Unavailable No server is available to handle this request. 

Error message.

can anyone please tell me the correct way to deploy the  Django 1.7 
application on openshift.

thank you!
girish.

-- 
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/a9e4656f-259f-4aed-8d0a-9825b5e3d2ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DecimalField returns 'This value must be a decimal number' when blank

2014-11-17 Thread fred . wulei
You'd better have a look at the raw database SQL. I think syncdb won't change 
the null attr of this column if it is not set in the first time. So the 
possible solutions are 1) change the column in db manually 2) use a migration 
tool like south. Hope this can help you.

-- 
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/84b8a495-a148-43b7-af4b-cff84687e56b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DecimalField returns 'This value must be a decimal number' when blank

2014-11-17 Thread fred . wulei
I think you'd better have a look at the raw db sql. I remember that the syncdb 
won't change the null attr. of a column if it's not set when initialized. So 
two possible solutions: 1) set the db manually 2) use a tool like south to do a 
migration. Hope I can help you.

-- 
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/f06e99e5-fa41-4571-92fc-e325af7d981f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Uploadfile form and CSS Style

2014-11-17 Thread Russo
Hi James,

sorry I'm new on Django, can you give me some code example? I mean, hot to 
define the CLASS or ID into the html with elements like this {{ 
form.docfile }} ?

Regards
Russo


El jueves, 13 de noviembre de 2014 15:48:16 UTC-4:30, James Schneider 
escribió:
>
> If you are manually expressing the form, then you can add classes and ID's 
> to any or all elements in the form. Even if you are using something like 
> the {{ form.as_p }} method to display the form, you can still style it 
> using CSS styles at the tag level. Just include a custom CSS file with your 
> template.
>
> -James
> On Nov 13, 2014 12:13 PM, "Russo"  > wrote:
>
>>  Hi Kakar,
>>
>> but i tried and there is not way to change the bottom style, see the html 
>> code
>>
>> 
>> > enctype="multipart/form-data">
>> {% csrf_token %}
>>
>> {{ form.non_field_errors }}
>> {{ form.docfile.label_tag }} {{ form.docfile.help_text 
>> }}
>> 
>> {{ form.docfile.errors }}
>> {{ form.docfile }}
>> 
>> 
>> 
>>
>> as it is a form there is no way to change style ¿?
>>
>> Regards/AR
>>
>>
>> El 13/11/2014 a las 03:37 p.m., Kakar Nyori escribió:
>>  
>> Then you need to apply css to the form.
>>
>> On Fri, Nov 14, 2014 at 1:16 AM, Russo > > wrote:
>>
>>> Hi,
>>>
>>> i just implemented the uploadfile form on Django, and everything goes 
>>> greate, but i would like to do if it is possible to apply CSS styles to the 
>>> upload botton on the forms, Anybody knows this?
>>>
>>> Regards
>>> Russo
>>>
>>> -- 
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/54650A9B.8040004%40musicparticles.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...@googlegroups.com .
>> To post to this group, send email to django...@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/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@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/5465119E.2030707%40musicparticles.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/c14d4df3-2eb8-401b-8e42-17eddbcad59d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread Matt Gushee
Hi--

On Mon, Nov 17, 2014 at 12:27 PM, René Fleschenberg
 wrote:

> On Monday 17 November 2014 17:42:22 Brad Pitcher wrote:
>> I agree Ansible is a good fit for your situation. Since Ansible works from
>> yaml files, you don't have to write any Python 2.x compatible code as you
>> would with Fabric.

That's true.

> I agree that Ansible is a nice tool, but AFAIK, it is not Python 3 compatible.

That's also true.

In other words, you don't have to write Python 2 (or any Python) code
to use Ansible, but you do have to have Python 2 installed on your
target hosts, which I believe was the OP's objection.

The question of transitioning to Python 3 has been discussed in the
Ansible community; apparently the devs feel that moving to Python 3 at
this time would not deliver any great benefits, and would risk
alienating a large enterprise user base that is mostly using Python
2.x.

I was also looking at other alternatives, and it doesn't seem like
there are any good CM/deployment tools that currently support Python
3. It did look like Fabric is at least planning for a transition (I
think I saw something about it in the docs ... or maybe they had a
Python 3 development branch ... it was a few weeks ago, so I don't
remember exactly).

--
Matt Gushee

-- 
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/CABrD0edV8Ar6muh0eVP0UjjpYHf%3DbR%3DPHdE%2BpzSz_%3DRaa0bo6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread Ezequiel Bertti
Ansible +1

On Mon, Nov 17, 2014 at 5:27 PM, René Fleschenberg 
wrote:

> Hi,
>
> On Monday 17 November 2014 17:42:22 Brad Pitcher wrote:
> > I agree Ansible is a good fit for your situation. Since Ansible works
> from
> > yaml files, you don't have to write any Python 2.x compatible code as you
> > would with Fabric.
>
> I agree that Ansible is a nice tool, but AFAIK, it is not Python 3
> compatible.
>
> http://docs.ansible.com/intro_installation.html
>
> Best regards,
> René
>
>
> --
> 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/1770024.nnJIfWbPdB%40rex.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Ezequiel Bertti
E-Mail: eber...@gmail.com
Cel: (21) 99188-4860

-- 
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/CACrQMYrhEeZ%3D%3DQGSEGUd7Q_nU9V2RaSGsfo5BwHtH8-YXZJtUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread René Fleschenberg
Hi,

On Monday 17 November 2014 17:42:22 Brad Pitcher wrote:
> I agree Ansible is a good fit for your situation. Since Ansible works from
> yaml files, you don't have to write any Python 2.x compatible code as you
> would with Fabric.

I agree that Ansible is a nice tool, but AFAIK, it is not Python 3 compatible.

http://docs.ansible.com/intro_installation.html

Best regards,
René


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


Re: moving existing django projects

2014-11-17 Thread Carl Meyer
Hi Malik,

On 11/15/2014 08:52 PM, Malik Rumi wrote:
> << What WSGI server are you using in the
> Heroku deployment? Can you point to the instructions you followed to
> deploy your project on Heroku?>>
> 
> Simple questions with not so simple answers. I started with a Django
> getting started tutorial on Heroku. It had a different look and feel
> than the rest of Heroku, and it included a sample application called
> 'getting started'. However, that page has now been completely rewritten
> to look like all the other Heroku pages, and it no longer includes the
> tutorial or the getting started project:
>  
> https://devcenter.heroku.com/articles/getting-started-with-django#django-settings.
> 
> This project used get_wsgi_application from django.core and Cling.
> 
> I suspect the reason it's gone now is that there is now an 'official'
> Django template for getting started on Heroku. It uses whitenoise
> instead of dj-static and Cling but still has django.core.

django.core.wsgi.get_wsgi_application() gets a WSGI application object,
but you still need a WSGI server to run it. That'll be whatever your
Procfile contains in the "web: " line. Gunicorn is the one shown in
Heroku's docs; is that what you're using?

> Anyway, I adjusted my project to suit these new requirements, then tried
> adding my pre-existing project which works just fine on my home machine
> (Windows 8.1), and when that didn't behave as expected is when I came
> here to post. Since then I have gone ahead and imported my database with
> pgbackup. Now I understood that this would be 'destructive', but I
> assumed that meant it would destroy my database, not wipe my models.py
> too - but that's what it did. 

I am quite sure that importing a database using pgbackup did not
actually wipe your models.py file. (It can't; once you've deployed a
version of an app to Heroku all your code is read-only). If you're not
seeing your models in the admin, that's a symptom of a different
problem. Perhaps the wrong settings are being used?

A good place to start would be your Procfile, and the value of
DJANGO_SETTINGS_MODULE you see when you run "heroku config".

> Now what I don't get is, if it was so
> destructive, why is the 'getting started' project now BACK in my Heroku
> site, (I had deleted it in the first place, and why wasn't it wiped out
> too in the second place?)

It seems like you are confused about the distinction between "code
deployed to a Heroku app" and "contents of a Heroku database." If you're
seeing a generic "getting started" app instead of your app, you have a
problem with the former; the latter is irrelevant (for now).

You might start over with a brand new Heroku app (heroku create
somename) and then "git push" your codebase to it.

and when I run git status or migrate, they
> both say there are no changes to update, even though my pre-existing
> models.py is still sitting there on my local dev. I don't get that at all.  
>
> Your wisdom and insights will be greatly appreciated. 

Carl

-- 
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/546A42DA.3040009%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread Brad Pitcher
I agree Ansible is a good fit for your situation. Since Ansible works from
yaml files, you don't have to write any Python 2.x compatible code as you
would with Fabric.

On Mon Nov 17 2014 at 8:24:24 AM Brian Schott  wrote:

> Ansible is a good choice.
>
> Sent from my iPhone
>
> On Nov 17, 2014, at 11:07 AM, Cal Leeming [iops.io]  wrote:
>
> There isn't really such a thing as a "deployment plugin", there are many
> aspects to deployment workflow that should be considered.
>
> It really depends on how you are intending on deploying your application,
> if you are dockerizing it then your CI system should be building the images
> and pushing to a repository of your choice (docker hub, S3 etc). If you are
> snapshotting on the hosting provider, then you can use packer.io and a
> bunch of shell scripts. Pushing code to a single server via SSH isn't
> really a scalable way to do deployment, and if this is what you are doing
> then you might as well run a tmux/screen session on the server instead.
>
> Sadly other than Amazon Beanstalk and Heroku, both of which are
> horrifically expensive, there isn't much in the way of choices. You can
> look at dokku and deis, both of which are not considered stable for
> production but use the same build pack idea as Heroku.
>
> If you want to go super ghetto, you should use a shell script which SSHs
> into your "single use" box, issue a "docker pull" then restart the running
> container. All of these things require a lot of plumbing work.
>
> Another approach would be to install python 2.6 in a venv (assuming you
> have the relevant system libs) and run Fabric with that instead... In fact
> putting fabric in its own venv is probably better because having fabric
> inside your application space anyway would be considered cross
> contamination (e.g. deployment tooling mixed in with application code).
> This may feel weird at first, but once you get into the concept of
> separating plumbing from application code, it feels more normal. If you do
> this, use virtualenvwrapper to save headaches.
>
> If you're a JS guy, there's also a bunch of SSH tooling for node too, but
> I can't give any personal recommendation on those.
>
> Cal
>
>
>
> On Mon, Nov 17, 2014 at 11:28 AM, Andreas Kuhne <
> andreas.ku...@suitopia.com> wrote:
>
>> Hi all,
>>
>> We are just about ready to release our newly rewritten website. It is
>> based on Django 1.6 and Python 3.
>>
>> We have worked through all of the problems with using python 3 (migrated
>> some plugins ourselves, other plugins were updated during the course of the
>> project). The only problem we have left is a good deployment plugin, so
>> that we easily can deploy new versions of our site.
>>
>> We previously used fabric, but that doesn't work with python 3. So I was
>> wondering if anyone has any python 3 compatible fabric alternative that
>> they are using?
>>
>> Regards,
>>
>> Andréas
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALXYUb%3DTpr7RfejfXs2H5vryg6vGp45_bbE%2Bp8tm%3D8CgQN2hzw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHKQagGz1tNLfdF09%3DcFBJaAWfBWFNbWCP%3DTANonGVkZSbvGfg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4679766C-BFEC-4A96-A1D2-BDBD316053EE%40gmail.com
> 

Re: Alternative to fabric

2014-11-17 Thread Brian Schott
Ansible is a good choice.

Sent from my iPhone

> On Nov 17, 2014, at 11:07 AM, Cal Leeming [iops.io]  wrote:
> 
> There isn't really such a thing as a "deployment plugin", there are many 
> aspects to deployment workflow that should be considered.
> 
> It really depends on how you are intending on deploying your application, if 
> you are dockerizing it then your CI system should be building the images and 
> pushing to a repository of your choice (docker hub, S3 etc). If you are 
> snapshotting on the hosting provider, then you can use packer.io and a bunch 
> of shell scripts. Pushing code to a single server via SSH isn't really a 
> scalable way to do deployment, and if this is what you are doing then you 
> might as well run a tmux/screen session on the server instead.
> 
> Sadly other than Amazon Beanstalk and Heroku, both of which are horrifically 
> expensive, there isn't much in the way of choices. You can look at dokku and 
> deis, both of which are not considered stable for production but use the same 
> build pack idea as Heroku.
> 
> If you want to go super ghetto, you should use a shell script which SSHs into 
> your "single use" box, issue a "docker pull" then restart the running 
> container. All of these things require a lot of plumbing work.
> 
> Another approach would be to install python 2.6 in a venv (assuming you have 
> the relevant system libs) and run Fabric with that instead... In fact putting 
> fabric in its own venv is probably better because having fabric inside your 
> application space anyway would be considered cross contamination (e.g. 
> deployment tooling mixed in with application code). This may feel weird at 
> first, but once you get into the concept of separating plumbing from 
> application code, it feels more normal. If you do this, use virtualenvwrapper 
> to save headaches.
> 
> If you're a JS guy, there's also a bunch of SSH tooling for node too, but I 
> can't give any personal recommendation on those.
> 
> Cal
> 
> 
> 
>> On Mon, Nov 17, 2014 at 11:28 AM, Andreas Kuhne  
>> wrote:
>> Hi all,
>> 
>> We are just about ready to release our newly rewritten website. It is based 
>> on Django 1.6 and Python 3. 
>> 
>> We have worked through all of the problems with using python 3 (migrated 
>> some plugins ourselves, other plugins were updated during the course of the 
>> project). The only problem we have left is a good deployment plugin, so that 
>> we easily can deploy new versions of our site.
>> 
>> We previously used fabric, but that doesn't work with python 3. So I was 
>> wondering if anyone has any python 3 compatible fabric alternative that they 
>> are using?
>> 
>> Regards,
>> 
>> Andréas
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CALXYUb%3DTpr7RfejfXs2H5vryg6vGp45_bbE%2Bp8tm%3D8CgQN2hzw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAHKQagGz1tNLfdF09%3DcFBJaAWfBWFNbWCP%3DTANonGVkZSbvGfg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Runtime warning about a naive datetime when running the test command

2014-11-17 Thread Daniel Grace
On Monday, 17 November 2014 11:33:40 UTC, Bruno Barcarol Guimarães wrote:
>
>
> $ python -W error manage.py test
>
>  
Hi Bruno,
I get another warning / error with that command:
>python -W error manage.py test flow
Traceback (most recent call last):
  File "manage.py", line 8, in 
from django.core.management import execute_from_command_line
  File "C:\landy\lib\site-packages\django\core\management\__init__.py", 
line 8,
in 
from django.apps import apps
  File "C:\landy\lib\site-packages\django\apps\__init__.py", line 1, in 


from .config import AppConfig   # NOQA
  File "C:\landy\lib\site-packages\django\apps\config.py", line 5, in 

from django.utils.module_loading import module_has_submodule
  File "C:\landy\lib\site-packages\django\utils\module_loading.py", line 4, 
in <
module>
import imp
  File "C:\Python34\lib\imp.py", line 32, in 
PendingDeprecationWarning)
PendingDeprecationWarning: the imp module is deprecated in favour of 
importlib;
see the module's documentation for alternative uses

-- 
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/45eef407-09f0-4cc2-bbdd-603d1a0424c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread Cal Leeming [iops.io]
There isn't really such a thing as a "deployment plugin", there are many
aspects to deployment workflow that should be considered.

It really depends on how you are intending on deploying your application,
if you are dockerizing it then your CI system should be building the images
and pushing to a repository of your choice (docker hub, S3 etc). If you are
snapshotting on the hosting provider, then you can use packer.io and a
bunch of shell scripts. Pushing code to a single server via SSH isn't
really a scalable way to do deployment, and if this is what you are doing
then you might as well run a tmux/screen session on the server instead.

Sadly other than Amazon Beanstalk and Heroku, both of which are
horrifically expensive, there isn't much in the way of choices. You can
look at dokku and deis, both of which are not considered stable for
production but use the same build pack idea as Heroku.

If you want to go super ghetto, you should use a shell script which SSHs
into your "single use" box, issue a "docker pull" then restart the running
container. All of these things require a lot of plumbing work.

Another approach would be to install python 2.6 in a venv (assuming you
have the relevant system libs) and run Fabric with that instead... In fact
putting fabric in its own venv is probably better because having fabric
inside your application space anyway would be considered cross
contamination (e.g. deployment tooling mixed in with application code).
This may feel weird at first, but once you get into the concept of
separating plumbing from application code, it feels more normal. If you do
this, use virtualenvwrapper to save headaches.

If you're a JS guy, there's also a bunch of SSH tooling for node too, but I
can't give any personal recommendation on those.

Cal



On Mon, Nov 17, 2014 at 11:28 AM, Andreas Kuhne 
wrote:

> Hi all,
>
> We are just about ready to release our newly rewritten website. It is
> based on Django 1.6 and Python 3.
>
> We have worked through all of the problems with using python 3 (migrated
> some plugins ourselves, other plugins were updated during the course of the
> project). The only problem we have left is a good deployment plugin, so
> that we easily can deploy new versions of our site.
>
> We previously used fabric, but that doesn't work with python 3. So I was
> wondering if anyone has any python 3 compatible fabric alternative that
> they are using?
>
> Regards,
>
> Andréas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALXYUb%3DTpr7RfejfXs2H5vryg6vGp45_bbE%2Bp8tm%3D8CgQN2hzw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Alternative to fabric

2014-11-17 Thread Andreas Kuhne
Hi René,

I saw that kind of solution. The only thing is I really didn't like having
to setup 2 environments, but perhaps that is the way to go. I will however
be looking into ansible, to see if that is an alternative (I know that it
runs python 2 as well, but I liked the format of it).

Regards,

Andréas Kühne
Software Development Manager
Suitopia Scandinavia AB

2014-11-17 16:37 GMT+01:00 René Fleschenberg :

> Hi Andreas,
>
> If you like fabric, why not just use Python 3 for your project and Python 2
> for fabric? You can easily have multiple Python interpreters installed.
> Just
> install Python 2 to a path like ~/local and give fabric its own virtualenv.
>
> Best regards,
> René
>
>
> On Monday 17 November 2014 12:28:27 Andreas Kuhne wrote:
> > Hi all,
> >
> > We are just about ready to release our newly rewritten website. It is
> based
> > on Django 1.6 and Python 3.
> >
> > We have worked through all of the problems with using python 3 (migrated
> > some plugins ourselves, other plugins were updated during the course of
> the
> > project). The only problem we have left is a good deployment plugin, so
> > that we easily can deploy new versions of our site.
> >
> > We previously used fabric, but that doesn't work with python 3. So I was
> > wondering if anyone has any python 3 compatible fabric alternative that
> > they are using?
> >
> > Regards,
> >
> > Andréas
>
> --
> 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/2926866.uvUyIk0gGl%40rex.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUb%3DTg%2ByEbgdjR4-HGYpPx-PMJrkFVTffFQW9xSxoVGL1Xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread René Fleschenberg
Hi Andreas,

If you like fabric, why not just use Python 3 for your project and Python 2 
for fabric? You can easily have multiple Python interpreters installed. Just 
install Python 2 to a path like ~/local and give fabric its own virtualenv.

Best regards,
René


On Monday 17 November 2014 12:28:27 Andreas Kuhne wrote:
> Hi all,
> 
> We are just about ready to release our newly rewritten website. It is based
> on Django 1.6 and Python 3.
> 
> We have worked through all of the problems with using python 3 (migrated
> some plugins ourselves, other plugins were updated during the course of the
> project). The only problem we have left is a good deployment plugin, so
> that we easily can deploy new versions of our site.
> 
> We previously used fabric, but that doesn't work with python 3. So I was
> wondering if anyone has any python 3 compatible fabric alternative that
> they are using?
> 
> Regards,
> 
> Andréas

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


Re: Django (1.5) login exception (Save with update_fields did not affect any rows)

2014-11-17 Thread jeroenp
Hi,

the model.save() arguments `force_update` and `update_fields` cause an 
explicit check if the update statement matched any rows.

Every once in a while one of my applications runs into a race condition 
where one process does an update (with one of the flags) and another just 
removed an object. You then get a very generic DatabaseError with the 
message "Forced update did not affect any rows.", or "Save with 
update_fields did not affect any rows.". This invariably makes me scratch 
my head and wonder what happened. 

As per ticket #21761, I don't understand why that is an error and a regular 
call to save() doesn't throw an error. 

But since I can easily recover from this exception, I think it would be 
nice if these exceptions would be typed in a more specific subclass so that 
I can catch them and do something nice for the end-user. 

As a side note, you might want to check that a single row is updated, and 
not "more than zero"; just in case a primary key is composed from more than 
one column and there's some other error... 

kind regards
Jeroen Pulles



On Sunday, March 30, 2014 12:23:29 AM UTC+1, AK wrote:
>
> In my Django web app (running on Google App Engine), when a new user signs 
> up a User object is created and then that user is authenticated and logged 
> in. Every once in a while, the login function throws an exception 
> (DatabaseError: Save with update_fields did not affect any rows) and I'm 
> not really sure why this is happening (this is my first Django app). 
>

-- 
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/528a99f0-a492-43bd-a962-6e06af88372e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.7 - help with change in "Save as new" behavior when related inlines are marked to be deleted

2014-11-17 Thread Alex Marandon
I've created a ticket for this issue: 
https://code.djangoproject.com/ticket/23857

-- 
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/d10c7c66-d1d2-44d1-808a-37c7f151fb70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with unique_together - on ForeignKey and Boolean field

2014-11-17 Thread Javier Guerra Giraldez
On Mon, Nov 17, 2014 at 6:10 AM, ThomasTheDjangoFan
 wrote:
>
> How would you do this? Can you give me a hint?


4 different ways:

- don't do it as a flag, add a 'defaultImage=ForeignKey(ProductImage)'
to the Product class.

- don't use False for non-default, use NULL.  since two NULL values
aren't equal, they don't trip unique restriction

- don't use True/False, use an integer to give images some priority.
#1 is default, the others get 2...n

- use a partial index (supported by PosgreSQL and SQLite), it's not
directly supported by the ORM, but you can simply add as an "ALTER
TABLE CREATE UNIQUE INDEX ProductdefaultImage ON app_productimage
(image)  WHERE is_default_image;"  at creation and forget about it.


-- 
Javier

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


Re: Making a field Read-Only in Django

2014-11-17 Thread Patrick Beeson
I believe you can set this via a built-in widget's attrs:

somefield = forms.CharField(
widget=forms.TextInput(attrs={'readonly':'readonly'}))


On Monday, November 17, 2014 1:48:44 AM UTC-5, Frankline wrote:
>
> Hi all,
>
> I'm running Django 1.7 and Python 3.4. I'm trying to make the username 
> field of my custom model to be read-only. I think this is usually set in 
> the form. Below is what I currently have in my *forms.py*
>
> class AuthUserChangeForm(UserChangeForm):
> """
> A form for updating users. Includes all the fields on the user, but 
> replaces the password field with admin's password hash display field.
> """
> password = ReadOnlyPasswordHashField(label="password",
>  help_text="""Raw passwords are 
> not stored, so there is no way to see this
>  user's password, but you can 
> change the password using 
>  this form""")
>
> class Meta:
> model = AuthUser
> fields = ('username', 'email', 'password', 'is_active', 
> 'is_staff', 'is_superuser', 'user_permissions')
> widgets = {
> 'username': TextInput( attrs={'readonly':'readonly'} ),
> 'email': TextInput(),
> }
>
> def clean_username(self):
> # Regardless of what the user provides, reset field to initial 
> value
> # Not appropriate to change usernames once set.
> return self.initial["username"]
> 
> def clean_password(self):
> # Regardless of what the user provides, return the initial value.
> # This is done here, rather than on the field, because the field 
> does 
> # not have access to the initial value
> return self.initial["password"]
>
>
> What I'm I missing here?
>

-- 
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/d2520030-bafa-47aa-9ace-fa480e27cf35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Modifying a ModelAdmin instance at runtime

2014-11-17 Thread Collin Anderson
Ohh. Yup. My bad :)

On Wednesday, November 12, 2014 5:01:03 PM UTC-5, Peter Sagerson wrote:
>
> I agree that setting self.exclude will set the instance attribute, thus 
> hiding the class attribute of the same name. However, it appears that a 
> given AdminSite instantiates each registered ModelAdmin once at 
> registration time.[1] The default AdminSite itself is a module global. 
> Thus, any long-running, multi-threaded Django application server (e.g. a 
> threaded uWSGI process) might be relying on a given ModelAdmin instance to 
> serve multiple requests concurrently. Neither AdminSite nor ModelAdmin 
> appear to have any thread-locality, suggesting that modifying self.exclude 
> (or anything else) for an individual request is a race condition waiting to 
> happen. 
>
> I believe this is essentially a subtle documentation bug, although it's 
> worth asking whether there are any deeper assumptions about ModelAdmin or 
> AdminSite having any kind of request isolation. 
>
> Thanks, 
> Peter 
>
>
> [1] 
> https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L104
>  
>
>
> > On Nov 12, 2014, at 1:36 PM, Collin Anderson  > wrote: 
> > 
> > On Tuesday, November 11, 2014 3:24:48 PM UTC-5, Peter Sagerson wrote: 
> > The documentation of ModelAdmin.get_form()[1] demonstrates modifying 
> self.exclude in order to modify the add/change form on a per-request basis. 
> However, looking at django.contrib.admin, it seems clear that ModelAdmin is 
> instantiated when it's installed, not for every request. It also doesn't 
> appear to be a subclass of threading.local. Is there some reason this isn't 
> a terrible idea or is the example just in error? 
> > 
> > Thanks, 
> > Peter 
> > 
> > 
> > [1] 
> https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_form
>  
> > 
> > Hi Peter, 
> > 
> > I've never thought that way about admin classes before, but it should 
> work correctly. 
> > 
> > In Python, setting self.exclude = ['something'] will set a _new_ 
> attribute on on the object, the instance of the admin class, not the admin 
> class itself, even if there's a matching attribute on the class with that 
> name. You'll end up with two different exclude lists. One in 
> self.__class__.__dict__ (aka vars(type(self))) (which is now pretty hidden) 
> and one in self.__dict__ (aka vars(self)). 
> > 
> > Though, if you _mutate_ the original attribute, like 
> self.exclude.append('something'), it will mutate the exclude list on the 
> class. 
> > 
> > Collin 
> > 
> > 
> > -- 
> > 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/AmoUDtEefyA/unsubscribe. 
> > To unsubscribe from this group and all its topics, send an email to 
> django-users...@googlegroups.com . 
> > To post to this group, send email to django...@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/be985862-c203-4358-bc78-8988a295f733%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/cfc0073a-1214-4c09-a145-a9d70e8012b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Runtime warning about a naive datetime when running the test command

2014-11-17 Thread André Castilho Manzano
Daniel,
I remember doing a function to handle naive date, it was something like
that.

def ConvertDateFormat(date):
hour = " 00:00:00"
NaiveDate = str(date) + hour
NewDate = datetime.strptime(NaiveDate , '%d/%m/%Y
%H:%M:%S').replace(tzinfo=utc)
return NewDate


PS: I also noticed that you have "auto_now_add=True", so you probably using
naive date when using filter, or something like that.


I hope it's from any help.


On 17 November 2014 09:33, Bruno Barcarol Guimarães 
wrote:

> Hi Daniel.
>
> The problem is you're probably generating a naive datetime at some point in
> your code. The best way to solve this is to run the tests with
>
> $ python -W error manage.py test
>
> That way an exception will be raised instead of a warning. From there you
> can
> probably figure out where it is coming from.
>
> --
> 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/4f7aeea8-d1c0-4840-9995-d9c441bf70b0%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*André Castilho*
Celular: (11) 99587-3437
andremanz...@gmail.com

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


Re: my mysite/templates/admin/base_site.html is ignored (tutorial unclear?)

2014-11-17 Thread Artie
Are you sure about correct path to your templates in views?

Show your view code

понедельник, 17 ноября 2014 г., 5:04:53 UTC+2 пользователь Andreas Ka 
написал:
>
> thanks for your answer.
>
> yes, I just tried that. Same result.
> By now, I have understood much more about the templates.
> But still, for the admin pages
> mysite/templates/admin/base_site.html   
> doesn't work yet.
>
>
>
> I have actually found more errors in the tutorial:
>
>
>
> https://docs.djangoproject.com/en/1.7/intro/tutorial06/#adding-a-background-image
> didn't work until I put a  tag into  polls/templates/polls/index.html
>
>
>
>
> https://docs.djangoproject.com/en/1.7/intro/tutorial05/#testing-our-new-view
> these tests all come up with one or the other assertion error
>
>
>
>
>
> On Sun, Nov 16, 2014 at 7:19 PM, RLF_UNIQUE  > wrote:
>
>> Obviously you've restarted the server and refreshed the page in such a 
>> way to ensure it's not a caching issue ?
>>
>> --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/2dfc3c89-cf1a-411f-ab0b-c15e7e09d501%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/05933bee-2249-4f21-b6e8-0930b3720363%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Im having trouble with models when it involves more than 1 class.

2014-11-17 Thread Shazwi Suwandi
Thanks Avraham,

I'm actually not getting any error or exception. However, I must have 
confused myself, thinking I should be able to select a staff under the 
locations tab. You're right, this is actually right (my bad). 

Anyways, for the part about __unicode__ instead of __str__, I believe thats 
for python 2 and not python 3? I'm currently using python 3 for my project. 

On Sunday, 16 November 2014 19:27:05 UTC+8, Avraham Serour wrote:
>
> please post the exception or the error page you are getting.
>
> in any case this seems right to me, on the staff page you inline the 
> location, you are complaining that you can only choose the FK of that 
> location to customer and not staff, well, the staff FK is obviously the one 
> you are editing/creating right now, it makes no sense to choose another
>
> on a side note you should accustom yourself to use __unicode__ instead of 
> __str__
>
> On Sat, Nov 15, 2014 at 7:55 AM, Shazwi Suwandi  > wrote:
>
>> Hi group,
>>
>> This is my first time asking, so bear with me if I'm missing anything. I 
>> have an app in my project called *Users*, under *Users* currently I have 
>> classes - *Customer, Location, ContactNumber. *I added foreign keys in 
>> both *Location *and *ContactNumber* to point to *Customer.*
>>
>> Everything is good so far. However, when I try to add another class - *Staff 
>> * and have those two foreign keys point to *Staff*, hell breaks loose. 
>> When I go to the admin page to add a *Staff*, the section where I want 
>> to add *Location *refers to *Customer *instead.
>>
>> *models.py*
>> from django.db import models
>>
>> # Create your models here.
>> class Staff(models.Model):
>> first_name = models.CharField(max_length=30)
>> last_name = models.CharField(max_length=30)
>> status = models.CharField(max_length=30)
>> activation_code = models.CharField(max_length=50)
>> email = models.EmailField(max_length=50)
>> join_date = models.DateField()
>> date_of_birth = models.DateField()
>> def __str__(self):
>> return self.email
>>
>> class Customer(models.Model):
>> first_name = models.CharField(max_length=30)
>> last_name = models.CharField(max_length=30)
>> status = models.CharField(max_length=30)
>> activation_code = models.CharField(max_length=50)
>> email = models.EmailField(max_length=50)
>> monetary_value = models.IntegerField()
>> join_date = models.DateField()
>> date_of_birth = models.DateField()
>> def __str__(self):
>> return self.email
>>
>> class Location(models.Model):
>> customer = models.ForeignKey(Customer)
>> staff = models.ForeignKey(Staff)
>> address = models.CharField(max_length=200)
>> city = models.CharField(max_length=200)
>> country = models.CharField(max_length=200)
>> zipcode = models.CharField(max_length=200)
>>
>> class ContactNumber(models.Model):
>> customer = models.ForeignKey(Customer)
>> staff = models.ForeignKey(Staff)
>> number = models.PositiveIntegerField()
>>
>> *admin.py*
>> from django.contrib import admin
>> from users.models import Customer, Staff, Location, ContactNumber
>>
>> class LocationInLine(admin.StackedInline):
>> model = Location
>> extra = 1
>>
>> class ContactNumberInLine(admin.StackedInline):
>> model = ContactNumber
>> extra = 2
>>
>> class CustomerAdmin(admin.ModelAdmin):
>> inlines = [LocationInLine, ContactNumberInLine]
>>
>> class StaffAdmin(admin.ModelAdmin):
>> inlines = [LocationInLine, ContactNumberInLine]
>>
>> admin.site.register(Customer, CustomerAdmin)
>> admin.site.register(Staff, StaffAdmin)
>>
>> I've attached a screenshot of how it appeared on the admin page.
>> Please help me. I'm not sure if I'm missing anything. Thank you. 
>>
>> -- 
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9e862722-75ae-4ad3-997d-5e38356e24a6%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/a503e42f-db23-4219-8b4c-dad05ad52e6c

Re: Runtime warning about a naive datetime when running the test command

2014-11-17 Thread Bruno Barcarol Guimarães
Hi Daniel.

The problem is you're probably generating a naive datetime at some point in
your code. The best way to solve this is to run the tests with

$ python -W error manage.py test

That way an exception will be raised instead of a warning. From there you 
can
probably figure out where it is coming from.

-- 
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/4f7aeea8-d1c0-4840-9995-d9c441bf70b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Alternative to fabric

2014-11-17 Thread Andreas Kuhne
Hi all,

We are just about ready to release our newly rewritten website. It is based
on Django 1.6 and Python 3.

We have worked through all of the problems with using python 3 (migrated
some plugins ourselves, other plugins were updated during the course of the
project). The only problem we have left is a good deployment plugin, so
that we easily can deploy new versions of our site.

We previously used fabric, but that doesn't work with python 3. So I was
wondering if anyone has any python 3 compatible fabric alternative that
they are using?

Regards,

Andréas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUb%3DTpr7RfejfXs2H5vryg6vGp45_bbE%2Bp8tm%3D8CgQN2hzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with unique_together - on ForeignKey and Boolean field

2014-11-17 Thread ThomasTheDjangoFan
Hi Jani,

thanks for making it clear. [image: smile.png]


Actually I would like to assign a lot of images to a product and only have 
one image as the default image.

How would you do this? Can you give me a hint?


Am Montag, 17. November 2014 11:25:37 UTC+1 schrieb Jani Tiainen:
>
> On Sun, 16 Nov 2014 23:51:16 -0800 (PST) 
> ThomasTheDjangoFan > wrote: 
>
> > Hi guys, 
> > 
> > I'd like to only be able to assign many ProcutImages to a Product, but 
> only 
> > ONE Image as a default image per product 
> > (ProductImage.is_default_image=True). 
> > 
> > I can't get this to work correnctly on Django 1.7 with a db.sqlite3: 
> With 
> > the code below I can only assign ONE Image to a Product. After that I 
> get 
> > the error "Product image with this Product und Is default image already 
> > exists.". 
> > 
> > Am I getting something wrong? 
> > 
> > from django.db import models 
> > 
> > class Product(models.Model): 
> > title = models.CharField(max_length=255) 
> > 
> > is_active = models.BooleanField(default=True) 
> > 
> > 
> > class ProductImage(models.Model): 
> > product = models.ForeignKey(Product) 
> > 
> > image = models.ImageField(upload_to='products/images/') 
> > 
> > is_default_image = 
> models.BooleanField(default=False,null=False,blank= 
> > False) 
> > 
> > class Meta: 
> > # A product can have multiple ProductImages, but only one of 
> them 
> > can be the "default"-image 
> > unique_together = ('product', 'is_default_image') 
> > 
> > I would be really thankful for some tips. 
>
> Well boolean field can have only two values: "true" or "false". 
>
> Now your unique_together defines that for "product" combined with 
> "is_default_image" must be unique. Which means that for each product you 
> can have _two_ images, one where is_default_image is true and one where 
> is_default_image is false. And this is forced on database level as well. 
>
> But apparently that is what you intended to do. There isn't really one 
> single solution for your problem. 
>
> -- 
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64e193a5-a3dd-45fd-aec5-b891657c0e10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with unique_together - on ForeignKey and Boolean field

2014-11-17 Thread Jani Tiainen
On Sun, 16 Nov 2014 23:51:16 -0800 (PST)
ThomasTheDjangoFan  wrote:

> Hi guys,
> 
> I'd like to only be able to assign many ProcutImages to a Product, but only 
> ONE Image as a default image per product 
> (ProductImage.is_default_image=True).
> 
> I can't get this to work correnctly on Django 1.7 with a db.sqlite3: With 
> the code below I can only assign ONE Image to a Product. After that I get 
> the error "Product image with this Product und Is default image already 
> exists.".
> 
> Am I getting something wrong?
> 
> from django.db import models
> 
> class Product(models.Model):
> title = models.CharField(max_length=255)
> 
> is_active = models.BooleanField(default=True)
> 
> 
> class ProductImage(models.Model):
> product = models.ForeignKey(Product)
> 
> image = models.ImageField(upload_to='products/images/')
> 
> is_default_image = models.BooleanField(default=False,null=False,blank=
> False)
> 
> class Meta:
> # A product can have multiple ProductImages, but only one of them 
> can be the "default"-image
> unique_together = ('product', 'is_default_image')
> 
> I would be really thankful for some tips.

Well boolean field can have only two values: "true" or "false".

Now your unique_together defines that for "product" combined with 
"is_default_image" must be unique. Which means that for each product you can 
have _two_ images, one where is_default_image is true and one where 
is_default_image is false. And this is forced on database level as well.

But apparently that is what you intended to do. There isn't really one single 
solution for your problem.

-- 

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20141117122459.5de8b80b%40jns42-l.w2k.keypro.fi.
For more options, visit https://groups.google.com/d/optout.


Need help with unique_together - on ForeignKey and Boolean field

2014-11-17 Thread ThomasTheDjangoFan
Hi guys,

I'd like to only be able to assign many ProcutImages to a Product, but only 
ONE Image as a default image per product 
(ProductImage.is_default_image=True).

I can't get this to work correnctly on Django 1.7 with a db.sqlite3: With 
the code below I can only assign ONE Image to a Product. After that I get 
the error "Product image with this Product und Is default image already 
exists.".

Am I getting something wrong?

from django.db import models

class Product(models.Model):
title = models.CharField(max_length=255)

is_active = models.BooleanField(default=True)


class ProductImage(models.Model):
product = models.ForeignKey(Product)

image = models.ImageField(upload_to='products/images/')

is_default_image = models.BooleanField(default=False,null=False,blank=
False)

class Meta:
# A product can have multiple ProductImages, but only one of them 
can be the "default"-image
unique_together = ('product', 'is_default_image')

I would be really thankful for some tips.

Kind regards
Thomas

-- 
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/e79147d9-b735-43b2-ad4d-0bd964ad2786%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.