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

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

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

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

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

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

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

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

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

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

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

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

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

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

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,

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

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

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

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 >

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

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

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

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

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

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

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

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

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

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

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

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

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: >

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: >

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,

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 > >

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 =

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 =

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

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

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

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

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() >

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

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

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

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

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

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

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

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.

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

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

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

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.

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 > >

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 %} >