Django 1.8.1, DB router and get_absolute_url()

2015-05-20 Thread Davide Setti
Hi all,
I'm using Django 1.8.1 with some models on a legacy DB. They all are in the 
same app, so the router is simple:

class MyRouter(object):
MYAPP = 'pkmain'

def db_for_read(self, model, **hints):
if model._meta.app_label == self.MYAPP:
return 'other_db'
return None


And similar for other Router methods. Everything works fine but the View on 
site in the admin. The model implements:

def get_absolute_url(self):
return 'http://example.com/{}'.format(self.id)


The View on site returns:

OperationalError at /admin/r/1/8461424/ 

no such table: 

It seems to be looking for mytable in the wrong database. Suggestions?

Regards.


-- 
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/e679782c-a7a7-4ac7-9247-2eeb7bd478d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I can't load fixtures

2014-08-17 Thread Davide Scatto
when you run a test the django fixture discoverer search in all fixture 
subfolder in apps registered in settings.INSTALLED_APPS.
you don't need __init__.py file nor FIXTURE_DIRS (fixture folder is a 
subfolder of app folder, isn't it?).

did you add fixture param in yr test class?

what version of django are you using?

Davide

Il giorno giovedì 14 agosto 2014 19:05:30 UTC+2, Daniel Grace ha scritto:
>
> I created a fixtures file called testdata.xml in a fixtures folder, but I 
> can't load the fixtures file into the database.
>
> I placed an __init__.py file in the fixtures folder (not sure about this 
> step, is it needed?)
>
> I put the fixtures directory in settings.py:
> FIXTURE_DIRS = (
>'/myapp/fixtures/',
> )
>
> I tried two ways to load the fixture, but neither worked:
> >python manage.py syncdb
> Creating tables ...
> Installing custom SQL ...
> Installing indexes ...
> Installed 0 object(s) from 0 fixture(s)
> >python manage.py loaddata "myapp/fixtures/testdata.xml"
> C:\myenv\lib\site-packages\django\core\management\commands\loaddata.py:216: 
> User
> Warning: No fixture named 'myapp/fixtures/testdata' found.
>   warnings.warn("No fixture named '%s' found." % fixture_name)
> Installed 0 object(s) from 0 fixture(s)
>
> Any ideas?
> 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/58cab9f2-8c75-47c8-bcd6-0d257c683154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Should I use generic foreign key, and how?

2014-08-17 Thread Davide Scatto
another way is not to use fk but generic field, where patent_id is a normal 
integer field. In a custom manager you have to manage the data content in 
this field with data content in table field to retrieve yr linked record.

Il giorno sabato 16 agosto 2014 21:46:33 UTC+2, Aaron Law ha scritto:
>
>
> Hi all,
>
> I have php web programming background, and new to Django. I am helping my 
> brother to build an online system to manage inventory, and I've got a 
> database design & coding problem recently. Needing help!
>
> That is, I have a set of tables of "possible products", "inventory", 
> "suppiler", etc. I want to attach a "comment" to each of them. Therefore, I 
> think I should make a generic "comment" table to hold all the comments of 
> products, inventory, suppiler.
>
> --
> possible_products
> id: int (pk)
> name: varchar
> url: varchar
> price: decimal
> created_at: datetime
> updated_at: datetime
> --
> comments
> id: int (pk)
> parent_id: int (fk)
> content: text
> author: int (fk)
> table: char (which the table this comment belongs to)
> created_at: datetime
> updated_at: datatime
> --
>
> My problem is, when "possible_products" table is the parent of "comment", 
> then a foreign key of the parent (id number) is stored in the "comment" 
> table in order to link up them.
>
> However, how about the fk of the "inventory" table and the "suppiler" 
> table? It should not be that: I create 2 more columns of "inventory_id" nor 
> "suppiler_id" in "comments" table. (That is, I should not create the 4th 
> column when I want to link up the 4th parent table.)
>
> So, Should I use generic forgien key of Django? (so that, my "comment" 
> table design is right.) And how to use/implement it?
>
> P.S I mainly develop the system in the Admin section of Django.
>
> Regards,
> Aaron Law Ho hon
> --~--~-~--~~~---~--~~
> Free as in Freedom ;-)
> --~--~-~--~~~---~--~~
>  

-- 
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/6c2ac6dc-44c0-4681-960b-29983f609469%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: query on models

2014-05-07 Thread Davide Scatto
Do you start from Ques model? What are your starting data?

Il giorno mercoledì 7 maggio 2014 15:24:38 UTC+2, Anushree ha scritto:
>
> I have the following models. I want to retrieve list of question banks 
> related to a particular subject. Is it possible to do without modifying the 
> existing data models?Thank you
> class Subject(models.Model):
> name = models.CharField(max_length = 255)
> desc = models.TextField(blank=True)
> def __unicode__(self):
> return self.name
>
> class QuestionBank(models.Model):
> name = models.CharField(max_length=255)
> desc = models.TextField()
> def __unicode__(self):
> return self.name
>
> class Ques(models.Model):
> content = models.TextField()
> ques_type = models.CharField(max_length = 1 , default= 'A')
> score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
> ques_bank = models.ForeignKey(QuestionBank)
> subject = models.ForeignKey(Subject)
>

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


Re: Django URLS help app not defined

2014-05-06 Thread Davide Scatto
it seems in yr project urls.py you don't import vmware.
 
  from django.conf.urls import patterns, include, url
  from django.contrib import admin
  from . import vmware

  urlpatterns = patterns
 

Il giorno martedì 6 maggio 2014 07:09:51 UTC+2, G Z ha scritto:
>
> project name = provisioning
> app name = vmware
>
> In my projects urls.py I have the following. I assume I set the new url 
> link customers to myapp.urls because im watching a youtube video and thats 
> what he did.
>
> from django.conf.urls import patterns, include, url
> from django.contrib import admin
> admin.autodiscover()
> urlpatterns = patterns('',
> url(r'^admin/', include(admin.site.urls)),
> url(r'^customers/', include(vmware.urls)), #i'm assuming its my 
> appsname.urls
> )
>
> In my vmware directory I have the urls.py file as the video had me design. 
> To which I have the following code:
>
> from django.conf.urls import patterns, include, url
> from django.view.generic import ListView
> from vmware.models import Customer
> 
> urlpatterns = patterns('',
>   url(r'^customers/', ListView.as_view(
> 
> queryset=Customer.objects.all().order_by"-id")[:100],
> template_name="VMS.html")),
> )
>
> Now when I syncdb and runserver I get no erros. But when I try to resolve 
> the page I get the following. It says vmware is not defined but it is 
> defined in my installed apps.
>
> Environment:
>
>
> Request Method: GET
> Request URL: http://23.239.206.142:8001/admin/
>
> Django Version: 1.6.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'vmware')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
> in get_response
>   101. resolver_match = resolver.resolve(request.path_info)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in resolve
>   337. for pattern in self.url_patterns:
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in url_patterns
>   365. patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in urlconf_module
>   360. self._urlconf_module = import_module(self.urlconf_name)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in 
> import_module
>   40. __import__(name)
> File "/root/djangoprojects/provisioning/provisioning/urls.py" in 
>   12. url(r'^customers/', include(vmware.urls)),
>
> Exception Type: NameError at /admin/
> Exception Value: name 'vmware' is not defined
>
>

-- 
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/a1232c90-22fe-45d5-abf3-53b51827c483%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


So you decided that you want to join a startup, right?

2012-11-28 Thread Davide Pluda
Well,

You are smart and and if you are still reading you are probably looking for 
a fun and interesting place to work.

I am david and the CTO of Wedding Snap (weddingsnap.com) a photo sharing 
application that collects pictures during events.
To build and manage the infrastructure that keep all this crazy amount of 
pictures and video we are looking for an amazing and self-motivated django 
developer that is going to join the tech team :) 
 (https://www.weddingsnap.com/site/about/)
I am not kidding when I say that you are going to be in charge for at least 
a critical system.

Still reading? AWESOME.

We are a fast growing startup incubated in 500 startups (500.co) and have 
access to the most skilled advisors in the tech industry ;)
We are lean and iterating fast, we have been on the marke for 7 months and 
we want to be the first point of capture for all your picture and video ( 
if interested I will explain you better ).

more info?
www.weddingsnap.com/site/jobs/


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Q2MbCxwHIVcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Port Django to Javascript

2012-04-05 Thread Davide Callegari
Hi Sébastien,
thanks to the database routing system and the possibility add any backend 
database (or data source, however you wanna call it) directly into broke, or 
your project.
You can think of it as a sort of plugin system that anyone can use.

For instance, if you are using django-piston or django-tastypie to create a 
nice public API, you can create a db backend to match your public api, however 
you wanna create it.
Using the models you can do stuff like:

MyModel.objects.filter({ id__gte: 10 }).using('nodejs-remote-backend').all()

and you get all the data you want from that db backend or you can use a db 
router to make sure all the requests for that model are redirected to that 
specific db backend.

Thanks for the support :)

Davide


Il giorno 05/apr/2012, alle ore 10:42, sebastien piquemal ha scritto:

> I guess the people that don't get the point have probably never made a heavy 
> Javascript application ... Ever used Backbone.js ?
> 
> client-side - one page - websites are much nicer to use than any website with 
> a page load after every click.
> 
> So I totally understand why you would do such a project, and I actually think 
> it is a lovely idea !!! On the other hand, I've started to think lately that 
> Django is not the best backend solution for building such applicatons.
> So, @davide, how do you plan on making sure that any weird API can be 
> plugged-in to the system ... will you separate nicely the model layer from 
> the "backend" (web API, or dummy data store, or whatever) ???
> 
> Cheers anyway, and I'll follow the project !
> 
> Sébastien

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django error about utf8 with BOM when running "python manage.py compilemessages"

2012-03-27 Thread Davide Setti
On Thursday, March 8, 2012 10:04:09 PM UTC+1, Tom Evans wrote:
>
> Yes, just remove the BOM:
>
> http://en.wikipedia.org/wiki/Byte_order_mark
>
But that file is in django, not in his code, am i wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Rc7vQY_Gnq8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



shared authentication and profiles

2011-04-22 Thread Davide Setti
Hello,
we're going to build some "federated" apps. Let's call them
app1.example.com and app2.example.com. I need to do two things:

1. single sign on
2. share some data between the two profiles. For example i want to
keep username, name and surname in the same place, while the phone
number should just stay in app1.

For point 1 i see there's https://github.com/easel/django-shared-auth
, but i don't understand why i need to use it. What if i simply share
cookie between subdomains and the session table?

For point 2, do you know if there are already apps to do this? I know
that i can use Database Routers to keep centralized data in a
different DB, but i would like to know if there are out-of-the-box
solutions...

Regards
-- 

Davide Setti
blog: http://blog.flatlandia.eu
code: http://github.com/vad

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Modifying the User model

2009-04-11 Thread Davide

That's the workaround we were about to implement. But what I was
searching for, was a more consistent way to modify the **model**
itself (which will be reflected into the database structure and
consequently in the forms), not the way Django handles the forms.
I think Django choice isn't so silly, as we have to remember it is a
general purpose user class (in some applications you won't even need
email adress).

Thanks anyway for your help ;)
Davide

On Apr 10, 8:12 pm, soniiic <soni...@gmail.com> wrote:
> The way I achieved this was to make my own registration form and use
> this:
>
> email = forms.EmailField(widget=forms.TextInput(attrs=dict
> (attrs_dict,maxlength=75)),label=_(u'Email address'))
>
> where attrs_dict was earlier defined as:
> attrs_dict = { 'class': 'required' }
>
> also, the email address isn't checked for uniqueness (which i think is
> silly) so I added this:
>
> def clean_email(self):
>                 """
>                 Validate that the email is not already in use.
>
>                 """
>                 try:
>                         user = 
> User.objects.get(email__iexact=self.cleaned_data['email'])
>                 except User.DoesNotExist:
>                         return self.cleaned_data['email']
>                 raise forms.ValidationError(_(u'This email is already taken. 
> Please
> choose another.'))
>
> On Apr 10, 6:51 pm, Davide <da.crive...@gmail.com> wrote:
>
>
>
> > Hi all,
> > we've been using the django User model from contrib.auth.models
> > As we want to re-use as much code as possible, is there a way to edit
> > the class properties, making the "email" field required? As a default
> > this is not a required field. Gooogled for some answers but didn't
> > find one, but if I missed something please let me know.
> > Thanks in advance,
> > Davide
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Modifying the User model

2009-04-10 Thread Davide

Hi all,
we've been using the django User model from contrib.auth.models
As we want to re-use as much code as possible, is there a way to edit
the class properties, making the "email" field required? As a default
this is not a required field. Gooogled for some answers but didn't
find one, but if I missed something please let me know.
Thanks in advance,
Davide

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem with django tagging application

2008-02-21 Thread Francesco Davide Calabrese
See the changes listed here:
http://code.google.com/p/django-tagging/wiki/BackwardsIncompatibleChanges
you may be able to give directly the queryset rather than the model

On Thu, Feb 21, 2008 at 1:25 AM, cesco <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I'm using the latest version of the django tagging application (rev.
> 132) and I'm having problems with the get_by_model method of the
> TaggedItem manager.
>
> Say I have a QuerySet1 generated as follow:
> QuerySet1 = TaggedItem.objects.get_by_model(MyModel, 'tag1')
> and a QuerySet2 generated as follow:
> QuerySet2 = TaggedItem.objects.get_by_model(MyModel, 'tag2')
>
> If at this point I try to '&' the two query sets as in:
> QuerySet3 = QuerySet1 & QuerySet2
> then I get the following error:
> "ambiguous column name: tagging_taggeditem.object_id"
>
> Do you have any idea of why I'm getting this error and how I could
> solve the problem?
> For completeness in dpaste is the complete traceback I get:
> http://dpaste.com/36177/
>
> Any help would be very appreciated.
>
> Thanks
> Francesco
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: save() called 2 times.

2006-05-05 Thread Davide Bertola

Victor : in that post it says that _post_save() is called twice, I
tryed to create that _post_save() but I see nobody calls it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---