Re: Custom QuerySet and __date field lookup

2015-11-05 Thread aprzywecki
You were right. Wrong virtualenv...*facepalm* -- 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,

Re: django admin - You don't have permission to edit anything

2015-11-05 Thread Andreas Kuhne
Hi, You don't have permissions to edit anything, because you haven't created a superuser. The superuser in django has a property that is called "is_superuser" and should be set to True. If you don't have that property (and your createsuperuser sets some other property), you will have the same

Re: Best practices for writing functional tests to exercise forms?

2015-11-05 Thread Carl Meyer
Hi Tim, On 11/04/2015 05:36 PM, Tim Chase wrote: > Beginning a new project, I'd like to include functional testing in > addition to my unit tests. What are recommended best practices for > exercising form-classes? I was hoping to do something like > > c = django.test.Client() > results =

django admin - You don't have permission to edit anything

2015-11-05 Thread Benjamin Smith
I followed the django doc on creating a custom user model while extending the model itself with my own fields. So it became like this: class MyUser(AbstractBaseUser, PermissionsMixin): email =

Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-05 Thread Simon Charette
Bonsoir Michele, I'll try to explain what happens here with a simplified model definition assuming you are using Django 1.8. I used a GenericRelation like your provided example but this issue can be triggered for about any M2M relationship. Given the following models: from django.db import

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-05 Thread Jani Tiainen
Well your workflow would be following steps roughly: 1) End user requests URL from your Django site 2) Django router URL to a view 3) View code opens remote connection to RESTful service somewhere on the web 4) View code receive response from service 5) Data is processed 6) Data is rendered to

Re: Locking / serializing access to one element in database

2015-11-05 Thread Carsten Fuchs
Hi Collin, Am 05.11.2015 um 16:36 schrieb Collin Anderson: If you're just updating one field, this _might_ work for you: Why just one? | try: TestMonthModel.objects.create(jahr=Jahr,monat=Monat)# create() uses force_insert. exceptIntegrityError: pass # It already exists. No

Re: How do I relate two tables using field name instead of id?

2015-11-05 Thread Jani Tiainen
You need to set few additional attributes in your foreign key. First you have to use db_column='', and to_field='' db_column value would be column name in your table that holds foreign key. I guess this would be 'name2' in your model that reflects table2 to_field would be reference in field in

Re: update_or_create() always creates (or recreates)

2015-11-05 Thread Carsten Fuchs
Hi Yunti, Am 05.11.2015 um 18:19 schrieb Yunti: I have tried to use the update_or_create() method assuming that it would either, create a new entry in the db if it found none or update an existing one if it found one and had differences to the defaults passed in - or wouldn't update if there

Re: Form to login

2015-11-05 Thread Dariusz Mysior
Thank's I have it! W dniu środa, 4 listopada 2015 06:51:02 UTC+1 użytkownik Dariusz Mysior napisał: > > I try do login view and I find it on > > https://docs.djangoproject.com/en/1.8/topics/auth/default/ > > from django.contrib.auth import authenticate, login > > def my_view(request): >

Re: Why my aggregate is not working?

2015-11-05 Thread Dheerendra Rathor
Are you sure you want to use aggregate? Aggregate will return you a dictionary like {'total': 10}. Probably you want to use annotate which will return you a queryset. On Thu, 5 Nov 2015 at 22:09 Fellipe Henrique wrote: > Hi, I have these model: > > class

update_or_create() always creates (or recreates)

2015-11-05 Thread Yunti
I have tried to use the update_or_create() method assuming that it would either, create a new entry in the db if it found none or update an existing one if it found one and had differences to the defaults passed in - or wouldn't update if there was no difference. However it just seemed to

Why my aggregate is not working?

2015-11-05 Thread Fellipe Henrique
Hi, I have these model: class ProductClicks(models.Model): product = models.ForeignKey(Product) dthr = models.DateTimeField(_('Date/Time Click'), auto_now_add=True) ip = models.CharField(_('IP'), max_length=20, blank=True, null=True) And this view: current_month =

Re: return values from static files to django admin

2015-11-05 Thread Collin Anderson
Hi, You may need to also calculate the possible options in python. Some hacky code that might help: class AdminRoutingInlineForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(AdminRoutingInlineForm, self).__init__(*args, **kwargs) field1 =

Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-05 Thread Michele Ciccozzi
Hello Simon, I'm going to paste a trimmed-down version of the involved classes: class CeleryTask(models.Model): celery_task_id = models.CharField(max_length=50, primary_key=True) task_type = models.ForeignKey(ContentType) task_id = models.PositiveIntegerField() task =

Re: How do I relate two tables using field name instead of id?

2015-11-05 Thread frocco
Thank you On Wednesday, November 4, 2015 at 11:19:40 AM UTC-5, frocco wrote: > > Hello, > > I have two existing tables > table1 has name1 > > table2 has name2 > > when I edit table2 in admin, I want a dropdownbox that shows values from > table1 using name1 > both fields are character > > I

Re: How do I relate two tables using field name instead of id?

2015-11-05 Thread Gergely Polonkai
If you go with the current solution, you will have to add the to_field keyword argument to ForeignKey: clinician = models.ForeignKey(Clinician, to_field='name') Best, Gergely 2015-11-05 15:47 GMT+01:00 frocco : > Thanks, I will look into adding id > > If I just do this,

Re: jquery and django template

2015-11-05 Thread Collin Anderson
Hi, Are you trying to show the user what filters are being applied to the data, or are you trying to filter the data based on a user selection? Collin On Monday, November 2, 2015 at 2:51:36 AM UTC+1, varun naganathan wrote: > > I basically have the database entries in the namespace of my

Re: Django bootstrap3_datetime widget in admin site doesn't pass form data

2015-11-05 Thread Collin Anderson
Hi Ilia, The default admin widget looks for id_0 and id_1, but if you use a custom widget, that is responsible for looking for its own value (like publish_time_1). You could check out DateTimePicker's source code to see what it's actually doing. Thanks, Collin On Sunday, November 1, 2015 at

Re: mssql databASE CONNECTION to Django

2015-11-05 Thread Collin Anderson
Hello, I'd recommend using django 1.7 until mssql gets compatible with django 1.8. Thanks, Collin On Friday, October 30, 2015 at 3:31:35 PM UTC+1, Sid wrote: > > sorry tim I know I am asking a dumb question...can you please tell me what > is the best way to make it work please if

Re: Locking / serializing access to one element in database

2015-11-05 Thread Collin Anderson
Hi Carsten, If you're just updating one field, this _might_ work for you: try: TestMonthModel.objects.create(jahr=Jahr, monat=Monat) # create() uses force_insert. except IntegrityError: pass # It already exists. No Problem. # ... calculate some things.

Re: [django_tables2] Expected table or queryset, not 'str'.

2015-11-05 Thread Collin Anderson
Hi, Do you to post your traceback if you're still getting this error? Thanks, Collin On Wednesday, October 28, 2015 at 2:17:28 PM UTC+1, Leutrim Osmani wrote: > > Can you please tell me how did you fixed this error ? > > On Monday, April 29, 2013 at 9:21:29 AM UTC+2, binith a k wrote: >> >> You

Re: Standalone Project using django ORM

2015-11-05 Thread Collin Anderson
Hi, It looks like you stack trace is somehow getting cut off. My guess is it's trying to import something that either doesn't exist or has a syntax error. Collin On Wednesday, October 28, 2015 at 12:39:06 AM UTC+1, ADEWALE ADISA wrote: > > The screen shot is attached. There is no error

Re: Safe tag is working differently for different view.

2015-11-05 Thread Collin Anderson
Hello, Are you sure they're using the same template? (If you change something does it actually affect both views?) Is one of the views using mark_safe? Collin On Tuesday, October 27, 2015 at 9:29:02 PM UTC+1, sonu kumar wrote: > > I am having two views both are extending from same base.html

Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-05 Thread Simon Charette
Hi mccc, Would it be possible to provide an example of the models and actions required to trigger the deletion. I suppose the deletion is triggered by the many to many relationship assignment logic and we should simply raise a ValueError if `to_attr` is set the same name as the referred

Re: Custom QuerySet and __date field lookup

2015-11-05 Thread Simon Charette
Hi Adam, I couldn't reproduce your issue with Django 1.9.b1 with the following model definition: from __future__ import unicode_literals import datetime from django.db import models class EntryQuerySet(models.QuerySet): def today(self): today = datetime.date.today()

Re: How do I relate two tables using field name instead of id?

2015-11-05 Thread frocco
Thanks, I will look into adding id If I just do this, clinician = models.ForeignKey(Clinician) I get clinician_id does not exist In my related table I have def __unicode__(self): return self.clinicianname On Wednesday, November 4, 2015 at 11:19:40 AM UTC-5, frocco wrote: > > Hello, > > I

Re: How do I relate two tables using field name instead of id?

2015-11-05 Thread Gergely Polonkai
It is possible, but in an SQL database it may become ineffective. For this, you will have to make the name field unique, and put an index on it (uniqueness also creates an index, by the way). For the admin site to display names, though, you still have to define the __str__() method that does only

Re: How do I relate two tables using field name instead of id?

2015-11-05 Thread frocco
The two models from msaccess are linked by name field, not id. Can I like by name field in django and not use id? There was no id in the table On Wednesday, November 4, 2015 at 12:35:49 PM UTC-5, Dheerendra Rathor wrote: > > In your model use define __str__ method to name1. Then django admin

Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-05 Thread mccc
I'm using a Prefetch object to follow some GenericRelation, and I was playing around with the to_attr parameter; I had the DB debug turned on, as I was checking whether it was making any difference, and I started noticing some DELETE statements on the remote table, so I started investigating.

Re: Controlling access at table row level

2015-11-05 Thread Jani Tiainen
Django has foundation for object level (row level) perms: https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#handling-object-permissions So basically you just check: current_user.has_perm('permname', obj) For a full list of methods you can check:

Re: Controlling access at table row level

2015-11-05 Thread Mike Dewhirst
On 5/11/2015 9:35 PM, Steve West wrote: Hi all I'm implementing a Django project in which individual table rows are marked as either private or public. Have you looked at https://github.com/django-guardian/django-guardian I need to be able to filter accesses to the tables in such a way that

ANN: django-admin-tools 0.7.0 released

2015-11-05 Thread David Jean Louis
Hello, We are happy to announce the availability of the version 0.7.0 of django-admin-tools: https://pypi.python.org/pypi/django-admin-tools/0.7.0 Django-admin-tools is a collection of extensions/tools for the default django administration interface, it includes: * a full featured and

Controlling access at table row level

2015-11-05 Thread Steve West
Hi all I'm implementing a Django project in which individual table rows are marked as either private or public. I need to be able to filter accesses to the tables in such a way that logged-in users can see everything, but other users only get visibility of the 'public' rows. My initial