Django 2.1 inspectdb supports Oracle ?

2018-10-11 Thread pk

The [version 2.0 
docs][https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-inspectdb]
 
states, "inspectdb works with PostgreSQL, MySQL and SQLite. Foreign-key 
detection only works in PostgreSQL and with certain types of MySQL 
tables.". This seems to exclude Oracle.

In constrast, the [version 2.1 
docs][https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-admin-inspectdb]
 
doesn't state this, but I'm seeing that it doesn't produce models with 
Oracle; is inspectdb V2.1 expected to work with Oracle tables and views ?

I've tried:

python manage.py inspectdb > models.py
python manage.py inspectdb --include-views > models.py

In both cases, no errors are produced and the output just contains:

'''
# [generated comments...]
from django.db import models
'''

Thanks,

pk

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a9174323-d2be-4635-b582-7152a18b0d6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


url template tag ; url generation

2010-09-08 Thread pk

In my template, I have:

Read More
»


I'm seeing that the url generated via the url template tag is, eg:

http://mydomain.com/mysite/param0val/param1val/param2val/

'mysite' is the project directory created via, eg, "django-admin.py
startproject mysite"; I don't want it to be part of the generated url;
I want the generated url to be:

http://mydomain.com/param0val/param1val/param2val/

1. Is there a way to accomplish this, preferably using the url
template tag ?

My urls.py contains:

(r'^(?P\w+)/(?P(\w|-)+)/(?P\d+)(-(\w+))*/
$', 'myapp.views.byname'),

2. Why/how is 'mysite' built into the url ?

Thanks,

pk

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: automatic documentation (docutils) does not pull in class methods?

2010-07-13 Thread pk


On Jun 22, 4:12 am, "euan.godd...@googlemail.com"
 wrote:
> You could try using Spinhx if you don't think docutils gives you
> enough flexibility. The autodoc extension is great.
>

However sphinx + autodoc does not know how to extra django model
definitions,
e.g.

   class A(models.Model):

  field_not_seen_by_autodoc = models.CharField(...)


Whereas the django admindocs utility knows about these fields.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: automatic documentation (docutils) does not pull in class methods?

2010-06-21 Thread pk
Answering my own question -- it is django.contrib.admindocs.view that
limits the admindocs view to only list methods on a model that has a
single argument. The lines:

  for func_name, func in model.__dict__.items():
  if (inspect.isfunction(func) and len(inspect.getargspec(func)
[0]) == 1):

There is currently an open ticket http://code.djangoproject.com/ticket/12974
that patches it to handle
the case where methods have decorator on them, hence reducing the
number of args to zero.

My question is why are we limiting the list of methods to single
argument (self) methods?
I put business logic in the model and usually the models will have
many more methods
that take additional arguments.

P.K.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



automatic documentation (docutils) does not pull in class methods?

2010-06-17 Thread pk
The automatic documentation generated, via docutils, in the admin
interface for a django app does not pull in documentation for methods
defined for classes, only attributes. Is this a "feature" of the
django implementation or docutils?

Thanks,
P.K.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: select childless parents, i.e. base with no derived classes in model inheritance

2009-01-02 Thread pk

The Place/Restaurant sample is from the model doc under
multi table inheritance:

http://docs.djangoproject.com/en/dev/topics/db/models

It is a simple inherited model relationship:

class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)

class Restaurant(Place):
serves_hot_dogs = models.BooleanField()
serves_pizza = models.BooleanField()



On Dec 30 2008, 5:09 am, Briel  wrote:
> The first query looks at the restaurant attribute in the place model,
> and gets all that have a NULL value in that field. Now  I don't know
> the restaurant/place setup, the docs I read uses book/auther examples.
> It looks like that the restaurant field is ForeignKey, and should be
> able to work the way intended. It would do a lookup for all places
> that doen't have a restaurant object associate with it. But, if the
> restaurant field is a BoolianField instead, then you can't use
> is_null, as both True and False isn't Null.
>
> Hope this helps, else be a little more explicit about the
> relationships.
>
>
--~--~-~--~~~---~--~~
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: select childless parents, i.e. base with no derived classes in model inheritance

2008-12-29 Thread pk

Alex,

First I made a mistake in the original post. The first query returns
*nothing*, not "all places". This is the correct "question:

1) print Place.objects.filter(restaurant__isnull=True).count()

returns 0

and 2) print Place.objects.filter
(restaurant__serves_hotdog__isnull=True).count()

works correctly, returning a count of all Places that is not a
restaurant.


The first query does not even join the child table. It tries to do:

SELECT COUNT(*) FROM "place" WHERE "place"."id" IS NULL

Where as the second query does a LEFT OUTER JOIN between parent and
child table, then
added a where clause to test for the hotdog field being null,
essentially filtered out the rows
that have no hotdog fields at all.

Seems like query 1 is broken?

P.K.

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



select childless parents, i.e. base with no derived classes in model inheritance

2008-12-29 Thread pk

I have a need to select base classes that does not have derived class
defined using the ORM. Using the Place/Restaurant example in the
Django doc, I find that:

1) Place.objects.filter(restaurant__isnull=True)

returns all places.

and
2) Place.objects.filter(restaurant__serves_hotdog__isnull=True)

works, returning all Places that is not a restaurant.

I wonder though, is this the *correct* way to do the query?

P.K.

--~--~-~--~~~---~--~~
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: Template inheritance

2008-11-03 Thread pk

One simple way to think about template inheritance (which is a GREAT
feature) is to think
of it as "specialization":

You first define the general look of a website, the logo, banner, menu
bars, footers.
All that goes into the base template A. In fact, you can render just
the base template A
and see an "empty" site.

Then for each actual website page, you have a template B that defines
the "insides"
of the base template, e.g. the main content area. As your page
specific view
renders the specialized template B, which only contains the "insides",
the django
template engine puts B within the context of A, and renders a full
page with the almost
all of A with one or more blocks replaced by specific content supplied
by B.

B will have none of the HTML elements that make up most of the final
web page.
It only contains the bits that need to be inserted into a {% block %}
inside A.

The neat thing about the django system is that B can replaces multiple
parts of A.
For example, a site has a two column type display, each column is a {%
block %}
that can be replaced. You can write a B1 page that just replaces what
is in column A,
or you can write a page B2 that replaces both columns in A.

P.K.

--~--~-~--~~~---~--~~
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: Using settings.py mechanism for application settings

2008-11-03 Thread pk

To clarify the question a bit more, I am talking about an "app" in the
sense of a reusable component that is developed by me but want
to distribute for others to use.

James is right that for any of my own app, I can just tell the user
to put in some settings in the project level settings.py file. In fact
that is exactly what I do now. However that does not buy me the
feature where, for django's own apps, have their default settings
stored in global_settings.py (or whatever is the file's name). So
I need to test for and supply default if my user does not supply
a settings value. Meanwhile the django built in settings mechanism
has a very nice way to specify defaults -- which is what I like
to "Reuse".

P.K.

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



Using settings.py mechanism for application settings

2008-10-31 Thread pk

There are always needs for application level configuration settings. I
really like the way settings.py works, with a package (django) level
default settings overridable by local settings. However looking at the
whole LazySettings setup it is not easily used outside of django/conf.
Am I missing something? Should that mechanism be refactored so that it
can be used for user applications? Is there a better way to do
application level configuration -- i.e. for app designed to be
distributed and reused?

Thanks,
P.K.

--~--~-~--~~~---~--~~
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: Template variable in filter?

2008-05-03 Thread pk

Isn't this already in settings.py?
Look at the code for the filters
/django/template/defaultfilters.py
it reads DATE_FORMAT and TIME_FORMAT from the settings file.

P.K.

On Apr 29, 2:25 am, Mike Chambers <[EMAIL PROTECTED]> wrote:
> Is it possible to include a template variable inside a filter?
>
> Specifically, I want to have a global setting for the date format string:
>
> Something like:
>
> settings.py
> --
> DATE_TIME_FORMAT = "M j, F \a\t P"
>
> template
> --
> {{ comment.date_submitted|date:{{DATE_TIME_FORMAT
>
> I am guessing that I could write a custom filter that handles this, was
> curious if there was another way to do it.
>
> mike
--~--~-~--~~~---~--~~
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: Should I set up Django locally or on a web server?

2008-05-03 Thread pk

if you are running Leopard (IMPORTANT) it is very easy to setup
Django.
I wrote up what I did here:
http://www.pkshiu.com/loft/archive/2008/01/django-on-leopard

The key is to just use sqlite and the development server to do
development.

There are some issues with sqlite compare to postgresql (I use that
for production). sqlite is more forgiving in some situations so you
will
find some subtle errors later on, but it's not a big deal.

P.K.

--~--~-~--~~~---~--~~
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: Templating patterns

2008-05-03 Thread pk

sometimes extending the template system with application specific tags
solves my problem. YMMV of course.

On May 2, 1:49 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I've got a lot of templates with the same pattern, so i want to put
> some code like this in a template.
>
> {% if iterable %}
> {% for variable in iterable %}
> <{{tag}}> something  
> {% endfor %}
>
> Is it  posible to send the {{tag}} variable as a parameter from
> another template (where i use the include tag) ?
--~--~-~--~~~---~--~~
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: Extending pythonpath within python code

2007-12-22 Thread pk

os.path.normpath('e:/a/b/c') will give 'e:\\a\\b\\c'

On Dec 22, 6:50 am, Julien <[EMAIL PROTECTED]> wrote:
> Thanks for the tip!
>
> However, it's a bit strange because it only accepts paths with double
> back slashes, instead of the forward slashes required for declaring
> the template path for example.
>
> import sys
> sys.path.append('E:\\workspace\\myproject\\trunk\\apps')
> works
>
> but:
> import sys
> sys.path.append('E:/workspace/myproject/trunk/apps')
> doesn't work
>
> Is there a way around that? As I'm storing the absolute path of my
> project in a constant variable (with forward slashes), I'd like to do
> something like this:
>
> ABSOLUTE_PROJECT_PATH = 'E:/workspace/myproject/trunk/
> sys.append(ABSOLUTE_PROJECT_PATH + 'apps/')
>
> TEMPLATE_DIRS = (
> ABSOLUTE_PROJECT_PATH + 'templates/',
> )
>
> PS: As you may have guessed, I'm running under Windows.
>
> On Dec 22, 8:03 pm, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
>
> > On Sat, 2007-12-22 at 00:58 -0800, Julien wrote:
> > > Hi there,
>
> > > To keep my projects tidy, I'm used to having all my apps in a
> > > subfolder "apps".
> > > This means that I need to add that subfolder to the pythonpath. I can
> > > do this in apache or by doing runserver --pythonpath=apps.
>
> > > However, I'd like to extend the pythonpath within the code, for
> > > example in settings.py(*). That would save me from altering apache
> > > config files and would therefore make deployment a little easier.
>
> > > Is that possible, and is it recommended practice?
>
> > The python path lives in sys.path (which is a simple list). This means
> > that you can add new directories with sys.path.insert(0, 'your/path') or
> > sys.path.append('your/path'), whichever you like.
>
> > I do this all the time, mainly in the FastCGI caller script, but also in
> > settings.py to enable access to middleware classes and templatetags
> > which I use in nearly every project.
--~--~-~--~~~---~--~~
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: Django documentation in chm (Dec 22, 2007)

2007-12-22 Thread pk

Thanks very much for doing this. While reading on djangoproject is
nice, sometimes it is faster/better to have a local version -- When I
am coding on a plane, for example !

P.K.

On Dec 22, 8:36 am, char101 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have created a chm format of the django docs taken from svn at Dec
> 22, 2007.
>
> Link:http://charupload.wordpress.com/2007/12/02/django-documentation-chm/
>
> Note: don't right click and save as on the links because it's a link
> to a page on divshare, not a direct link to the file.
>
> Cheers,
> Charles
--~--~-~--~~~---~--~~
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: Database filters

2007-12-20 Thread pk

Are you using the built-in Group and User classes? If what you are
quoting is cut-and-pasted from your console, you maybe using your own
model? Maybe you should show us the actual source code.

FYI -- the built-in classes are django.contrib.auth.models.Group
and ..User
not Groups nor Users

P>P.K.


On Dec 20, 11:13 am, kbochert <[EMAIL PROTECTED]> wrote:
> I have an app, and I have added 3 Users in 2 Groups.
> How do I get the users that belong to a specific Group??
>
> Using the shell on the built in Django models I get:>>> G = Groups.objects
> >>> U = Users.objects
> >>> U.all()
>
> [, ]>>> G.all()
>
> [, ]
>
> Ok so far?  ( the double User: in U.all() concerns me a bit)
>
> >>>U.all().filter(groups__id = 1)
> []
> >>>U.all().filter(groups__id = 2)
>
> []
>
> Makes sense- I've used the admin to put one user in each group.
>
> >>>U.all().filter(groups__name = 'Admin')
>
> [, ]
>
> ??? Why both users???
> Shouldn't this give me a list of the Users in the 'Admin' group?
--~--~-~--~~~---~--~~
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: Dynamic Choicefield

2007-12-09 Thread pk

This is a pretty common problem. Each form object gets instantiated as
you need them.
So in your POST handling, you need to instantiate the form with the
same product field
so that it can populate the choice field setting correct. i.e.
FormForOptionQuantity(product,request)

P.K.


On Dec 9, 7:31 am, pinco <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to populate dynamically at runtime a choicefield and
> subsequently validate the user choice, but without results.
> The goal is to permit the user, in an e-commerce application, to
> choose the number of products to buy through a choicefield, with a
> list of integer from 1 to a maximum number set to the amount of
> products in stock (i.e. if I have 5 products in stock, the choice
> should be restricted to 1, 2, 3, 4, 5).
>
> The following snippet actually populated in a right way the
> choicefiled:
>
> class FormForProductQuantity(forms.Form):
> quantity = forms.ChoiceField()
>
> def __init__(self, product, *args, **kwargs):
> super(FormForProductQuantity, self).__init__(*args, **kwargs)
> self.fields['quantity'].choices = [(str(product.id) + "_" + 
> str(c),
> c) for c in range (1, product.stock_quantity)]
>
> The problems come when I try to validate user's choice and add the
> product to the shopping cart with the following snippet:
>
> def add_product_to_cart(request, product_id):
> if request.method == 'POST':
> product = Product.objects.get(pk=product_id)
> form = FormForOptionQuantity(request.POST)
> if form.is_valid():
> ... do something
>
> which raise an the error:
>
> Traceback:
> ...
> Exception Value: 'QueryDict' object has no attribute 'stock_quantity'
>
> I have no idea on how to correct my code.
>
> Thank you in advance for any help.
--~--~-~--~~~---~--~~
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: How to display if a user is logged in? Do I develop a custom template tag?

2007-11-29 Thread pk

There are two issues.

1) you can't change the auth_user table/class. There are different
ways to "extend" the auth_user class. The "B-List" site has some
article on how you may do it. http://www.b-list.org/

I have my own "user" class that is one-to-one implemented as "many-to-
one" back to the auth_user, which I store all application related user
data.

2) You need a logical many-to-many relationship between your products
and users. However you may want to consider using an intermediate
cross reference class/table as well, as you may need to store other
data relating to the relationship, like when the "fav" was added,
ranking information, etc etc.

P.K.

On Nov 26, 10:30 pm, Greg <[EMAIL PROTECTED]> wrote:
> Ok...I'm looking into using django's builtin Authentication models.  I
> can use that to add users.  However, I still need to associate a user
> with their favorites once they login.  So do I need to add a
> ManyToManyField in my User table that points to my products table?
>

--~--~-~--~~~---~--~~
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: How to display if a user is logged in? Do I develop a custom template tag?

2007-11-26 Thread pk

There are a couple of things you have to do to get the "user" object
automatically available to all templates.

1. Follow the authentication setup as suggested.
2. Then read the bit about request_context:
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext
You have to make sure to pass the additional
context_instance=RequestContext(request) when calling
render_to_response.

I also write a little context processor that inserts extra session
variables from the session table to the context so that my application
session objects are always available in my templates.

P.K.

On Nov 26, 4:59 pm, Greg <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a website where people can login and keep track of their
> favorite products.  Whenever they login I create a session variable:
> 'request.session['member_id']'.  If this session variable is set then
> I know that a user is logged in.  In order to get this to work I have
> to send the session variable in the return statement of every view.
> Then in my template I have an if statement that either displays
> 'Login' or 'Welcome, User' depending on if
> 'request.session['member_id']' is True or False.
>
> I've created custom tags before where I bring back data from a a
> class.  However, I'm not sure how I create a custom tag to send a
> session variable.  Because the session variable is part of a request
> object, and i don't know how to have my custom tag have access to the
> 'request'.
>
> Anybody know how I can develp this so that I don't have to send my
> session variable in the return statement of every view?
>
> Thanks
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---