Re: Write django log to different.

2015-11-09 Thread Serdar Dalgic
Instead of solving this problem on django side, I'd recommend using a tool
such as logrotate for this problem
http://www.rackspace.com/knowledge_center/article/understanding-logrotate-utility


You can customise it to your needs, daily, weekly or per size basis.

One problem with solving it on django side would be, as the django settings
are loaded when you restart the server, and in production you may not want
to load the server every day, the TODAY_STRING would stay as the first day
the settings are loaded. So it's a better practice to solve the logging on
server side.

Best.

- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild

On Mon, Nov 9, 2015 at 4:40 AM, tolerious feng 
wrote:

> I want to write django log to different, especially I want to log daily
> log file, such as 2015-11-09-log.txt  2015-11-10-log.txt, this is my
> settings.py file:
>
> TODAY_STRING = datetime.datetime.now().strftime("%F")
> TODAY_LOG_DIR = os.path.dirname(__file__) + "/log/" + TODAY_STRING
> # TODAY_LOG_DIR = "/log/" + TODAY_STRING
> print "***"
> print SITE_SRC_ROOT
> print TODAY_LOG_DIR
> print os.path.join(SITE_SRC_ROOT, TODAY_LOG_DIR, "todaytotal.log")
> print os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "todaytotal.log"),
> if os.path.exists(TODAY_LOG_DIR):
> pass
> else:
> os.mkdir(TODAY_LOG_DIR)
>
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'formatters': {
> 'verbose': {
> 'format': '%(levelname)s: %(asctime)s %(module)s %(process)d 
> %(thread)d %(message)s %(filename)s:%(funcName)s:%(lineno)d'
> }
> },
> 'handlers': {
> 'total': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log", "total.txt"),
> },
> 'todaytotal': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> "todaytotal.txt"),
> },
> 'dengbin': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'dengbin.txt'),
> },
> 'haiyang': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'haiyang.txt'),
> },
> 'meibo': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> "meibo.txt"),
> },
> 'xiecheng': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'xiecheng.txt'),
> },
> 'tolerious': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'tolerious.txt'),
> }
> },
> 'loggers': {
> 'xiecheng': {
> 'handlers': ['xiecheng', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> },
> 'dengbin': {
> 'handlers': ['dengbin', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> },
> 'haiyang': {
> 'handlers': ['haiyang', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> },
> 'tolerious': {
> 'handlers': ['tolerious', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> }
> },
> 'root': {
> 'handlers': ['total'],
> 'level': 'DEBUG',
> },
> }
>
>
> but this doesn't work, it only log 2015-11-09-log.txt, when today is 
> 2015-11-10, 2015-11-10-log.txt not generated.
>
> --
> 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/0ca4d5be-88de-4e2e-afee-1c3b65bc3132%40googlegroups.com
> 

Re: ImportError failure

2014-10-22 Thread Serdar Dalgic
Hi Juan,

I believe you might have a problem while importing "example". Can you
check the line you're importing example and where did you put this
"exsite.example" module?

Your directory structure should be like this:

mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
exsite/
__init__.py
example.py
another_app/
__init__.py
   another_module.py

So that you can import exsite.example in your another_module.py like:

from exsite.example import AnyClassYouWantToImport

I hope this helps.

p.s. mind the "__init__.py"s on the modules you want to import. There
must be one in your "exsite" dir.
p.s.2. Instead of an example.py file under exsite dir, you may have
written it under __init__.py file as

mysite/
...
mysite/
__init__.py
...

in this __init__.py, you may have
class Example(object):
...
...

this is OK either ;)


- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild


On Wed, Oct 22, 2014 at 5:35 AM, Juan Carlos  wrote:
> Hi everyone,
>
> When I execute
> python manage.py runserver
>
> it appers:
> ImportError: cannot import name 'example' from 'exsite'
>
> The relative code in the settings.py file is:
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'exsite.example',
> )
>
> What can I do?
>
> My django version is 1.7, with Python 2.7.  I'm new in this interesting
> world of Django.  Thanks for your help, and time.
>
> Regards,
> Juan
>
> --
> 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/13bae8aa-77d9-4ba6-b038-d9ce37a37c9c%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/CAJH%2Bopprv6qLmfCvJwFdGwUs86JMOFBGtABu8Zq-Q_8zcdYPSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database operators for custom fields

2014-02-19 Thread Serdar Dalgic
Hi!

In python, '==' operator is set to '__eq__' and '!=' operator is set
to '__ne__' functions.

See more details in http://jcalderone.livejournal.com/32837.html

And In order to make queries from the ORM, Django uses Managers
https://docs.djangoproject.com/en/dev/topics/db/managers/

So you can write a Manager for the model that has this custom field,
override the __eq__ and __ne__ operations on this custom field and
implement as you like.

Good days!


On Wed, Feb 19, 2014 at 1:45 PM, Johannes Schneider
 wrote:
> hey list,
>
> I have a custom Field implemented for one of my models. How do I implement
> the database operations (e.g. '==', '!=') for the custom field which are
> used to execute database queries?
>
> bg,
> Johannes
> --
> Johannes Schneider
> Webentwicklung
> johannes.schnei...@galileo-press.de
> Tel.: +49.228.42150.xxx
>
> Galileo Press GmbH
> Rheinwerkallee 4 - 53227 Bonn - Germany
> Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
> http://www.galileo-press.de/
>
> Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
> HRB 8363 Amtsgericht Bonn
>
> --
> 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/53049967.8030907%40galileo-press.de.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild

-- 
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/CAJH%2Boppn9s%3D2q%3DFQB%3DsBFXObT-sGWNDa%2BLxGNWfB-bi4F31SXA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: new field in models

2013-07-23 Thread Serdar Dalgic
On Mon, Jul 22, 2013 at 10:53 AM, Harjot Mann  wrote:
> In django when we add a new field in existing class, we need to drop
> the table and then run the syncdb again. Is there any alternative for
> it so that we can add the field without dropping the table??
>

You can also run sqldiff django command if you have django_extensions
installed in your django app.

See http://pythonhosted.org/django-extensions/sqldiff.html for
details. It gives you the difference between your model and the
database structure. Then, you can apply this difference to your db.


-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Feed uploaded file into process

2013-05-13 Thread Serdar Dalgic
On Mon, May 13, 2013 at 1:56 PM, Torsten Bronger <
bron...@physik.rwth-aachen.de> wrote:

>
> The data is supposed to be sent as one big compressed file und
> uncompressed on the web server.  The tar'ing is done by the
> uploading person, before using the browser.  Then, it is sent
> through the Internet.  On my server, I whish to untar it *while* I
> receive it.
>
>
Hmm, ok then. So, what you need is untaring a stream, or a file (chunk by
chunk), if I understood right ;)

I've found these links, they can be useful for you:
http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk
http://stackoverflow.com/questions/1838699/how-can-i-decompress-a-gzip-stream-with-zlib

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Feed uploaded file into process

2013-05-13 Thread Serdar Dalgic
Hallo Torsten,

I'm just brainstorming about the situation, I think the best solution would
be some kind of Javascript functions in the frontend part, before
implementing a file upload. You can tar the file in a temporary directory,
an upload that temp file with the real file's name.tar.gz

I'm not so much into JS, so sorry for not providing any sample code for
this.


On Sun, May 12, 2013 at 4:53 PM, Torsten Bronger <
bron...@physik.rwth-aachen.de> wrote:

> Hallöchen!
>
> I want users to upload very large tar balls to my site.  I think it
> is sensful to feed them to "tar -xzf" during the upload.  Is this
> possible with Django?  I think the standard way with iterating over
> chunks doesn't start before the whole file has been already stored
> on disk, does it?  (I don't even need the original file.)
>
> Tschö,
> Torsten.
>
> --
> Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
>   or http://bronger-jmp.appspot.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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Guidance

2013-04-16 Thread Serdar Dalgic
On Tue, Apr 16, 2013 at 3:32 PM, Kishan Mehta  wrote:
> Hi, I am new to django. while learning from django book i came across
> request.POST.get()
> request.GET()
>
> etc methods.
>
> anyone can tell a where i can read more about this methods.
>

Take a look at this documentation
https://docs.djangoproject.com/en/dev/ref/request-response/ (select
the django version from the down right part of the page, the link I
sent is the development version.)

> Also in future if i want to know which method does what exactly where to
> go..
>  I tried google but could not  find any useful thing.
>

I'd strongly recommend you to complete the tutorial
https://docs.djangoproject.com/en/1.5/intro/tutorial01/ and make sure
that you understand every aspect well.

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-social-auth problem with facebook

2013-04-15 Thread Serdar Dalgic
Hi,

On Mon, Apr 15, 2013 at 9:01 AM, Jeff Hsu  wrote:

> Hi, I just pip installed django-social-auth from omab today on
> github(beginner here).  I think I can almost get it to work with facebook
> login, but I always have this "InternalError: Exception Value: current
> transaction is aborted, commands ignored until end of transaction block",
> after I log in with my facebook account and before I redirect to the
> profile page.  The request url shows
>
> http://127.0.0.1:8000/complete/facebook/?redirect_state=xxx&code=xxx&state=xxx.
>  I'm using Django 1.5.  Can anybody give me some directions to debug this?
>
>
Your question is Django-Social-Auth specific. If you ask that question
http://groups.google.com/group/django-social-auth you would get more
accurate and fast answer. I'd suggest you to do so.

I've met the same error while using postgresql as the database, and the
reason was that, when a transaction meets an error, it changes its
stabilized state. If you do not rollback this transaction, further
transactions after this one gives such error. You should find the
problematic transaction to get rid of this error. For details, see
https://docs.djangoproject.com/en/dev/topics/db/transactions/#handling-exceptions-within-postgresql-transactions

More info about this issue from Django Social Auth users/developers would
appear on Django Social Auth mailing list.

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: PostgreSQL on windows 7 (psycopg2 install problem)

2013-04-14 Thread Serdar Dalgic
On Sun, Apr 14, 2013 at 5:45 PM, Mustafa Tulu  wrote:
> Hi All,

Hi;

>
> When I try to install the package into my virtualenv in pycharm, it tries to
> compile the source into binaries, it fails at linking stage, giving errors
> like:
>  Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
> object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
> pqpath.obj : error LNK2019: unresolved external symbol _PQclear
> referenced in function _pq_raise
> connection_int.obj : error LNK2001: unresolved external symbol _PQclear
> cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
> error_type.obj : error LNK2001: unresolved external symbol _PQclear
> pqpath.obj : error LNK2019: unresolved external symbol _PQerrorMessage
> referenced in function _pq_raise
>

This problem is not django-specific.

Make sure you have python-dev and libpq-dev packages installed on your
environment. After that, try "pip install psycopg2"

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Suddenly manage.py syncdb fails with 'no such table django_session'

2013-04-09 Thread Serdar Dalgic
On Thu, Apr 4, 2013 at 10:24 PM, Thomas Weholt  wrote:
> I haven't changed settings.py since my last successful run. I've also
> googled the problem (and it seem to pop up once in a while), but none of the
> solutions provided solved the problem. I've also made the path to the
> databasefile absolute, like so:
>
> import os
> PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(PROJECT_PATH, 'database.db'),
> 'USER': '',
> 'PASSWORD': '',
> 'HOST': '',
> 'PORT': '',
> }
> }

Just a guess, can you try writing to another path? I mean smt like
this. 'NAME': os.path.join('/tmp', 'database.db'),

I've checked the stackoverflow questions about this issue too, I guess
there could be a problem about writing on the same path, but I don't
have a valid explanation. :)

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to rename objects (Urgent)

2013-04-09 Thread Serdar Dalgic
On Tue, Apr 9, 2013 at 1:23 AM, Giorgos Kontogiorgakis
 wrote:
> Hi Serdar!
>

Hi!

>
> class Links(models.Model):
> interfacein = models.CharField(max_length=20L, db_column='InterfaceIn')
> interfaceout = models.CharField(max_length=20L,
> db_column='InterfaceOut')
> capacity = models.FloatField(null=True, db_column='Capacity',
> blank=True)
> delay = models.FloatField(null=True, db_column='Delay', blank=True)
> class Meta:
> db_table = 'Links'
>
> So,on my interface when i click on the "Links" i can see the objects that
> are into my database,all of them have the name "Links objects" and then when
> i click on 1 of them THEN i can see my fields.I don't want to change the
> name on any field or something but the name of "Link objects"
>

So, If I understood you right, you should define __unicode__ method in
the Links table. And return the representation of the objects.

> Links-->Links object(multiple times)[i want to change
> that]-->interfacein,interfaceout,capacity,delay(with their values)
> Thx for ur time and i hope you can help me :))
>

Add this method to your List Class.
def __unicode__(self):
return "%s, %s, %s, %s" % (self.interfacein, self.interfaceout,
self.capacity, self.delay)

The values will be casted to string. If you want, you can change the
format of the floating numbers while creating the return string.

My suggestion is, just write a __unicode__ method, and start playing
with it. :) Btw, no need to syncdb ;)

I hope this helps.

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to rename objects (Urgent)

2013-04-08 Thread Serdar Dalgic
On Mon, Apr 8, 2013 at 7:26 PM, Giorgos Kontogiorgakis
 wrote:
> Hi there guys!I have an answer about renaming objects on my webinterface.For
> example i have a table named "Map" and i have many obejcts in there(Map
> object,Map object,Map object,Map object,Map object,Map object) How is it
> possible to rename them?I mean i want to have something like (Map Asia,Map
> Europe,Map America,Map Africa and so on) for every object to give him a
> different name.
>

Hi Giorgos;

I assume you mean django admin by webinterface. If I understood you
right; In your models, if you define a __unicode__ function, you can
get what you want. Just a plain example:

Class Map(models.Model):
name = models.CharField(max_length=64)
..
..
def __unicode__(self):
return self.name

Assuming you create maps like this:

asia=Map(name="Map Asia")
asia.save()

For more details, take a look at
https://docs.djangoproject.com/en/dev/ref/models/instances/#unicode

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is there a way to see manage.py sql output of "managed=False" models?

2013-04-02 Thread Serdar Dalgic
On Wed, Apr 3, 2013 at 12:02 AM, Bill Freeman  wrote:
>
> Yes.  I must confess that I like your solution better.  But some folks are
> loth to edit the stuff that isn't their code.
>

Thanks. Yeah, there is such behavior among folks.

> Maybe create a patch adding a command line flag that says you want the
> unmanaged moddels as well, and offer it to the core team?  Them taking it,
> however, wouldn't help you with 1.3.2.
>

Yeap, I'm aware of this. I'll create a ticket on this issue then, and
provide the patch for the current codebase. Before doing this, I
wanted to ask to django-users group whether I'm missing smt or not.
Thanks for your feedback.

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is there a way to see manage.py sql output of "managed=False" models?

2013-04-02 Thread Serdar Dalgic
On Tue, Apr 2, 2013 at 11:48 PM, Bill Freeman  wrote:
> Perhaps take the site down (or clone it), set managed = True, ask manage.py
> for sql for that app, and put everything back?
>

Sure, that's a way to do it. But I'm looking for a practical way to do
it. Otherwise, commenting out the managed=True lines in the models.py
is an option too :)

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Is there a way to see manage.py sql output of "managed=False" models?

2013-04-02 Thread Serdar Dalgic
Hi;

In my project, we are using django 1.3.2, and we're on the verge of
migrating to 1.4.
I wrote a standalone app, in which I've created some models with

class Meta:
managed = False

setting in every model class. (The reason why I did like this is, I
prefer to use a different DB than the default one for mapping those
models.)
Now, I want to create the tables on my **app_db_name** DB, so I use the command

python manage.py sqlall appname --database=app_db_name

However this manage.py sql(all) commands checks for the models and if
they are set to be managed by the users, this command gives no
outputs.

So, I've hacked into the code a little, and found that
**django.db.backends.creation** module's **sql_create_model()**
function has such a check:

def sql_create_model(self, model, style, known_models=set()):
"""
Returns the SQL required to create a single model, as a tuple of:
(list_of_sql, pending_references_dict)
"""

if not opts.managed or opts.proxy:
return [], {}
   

So I solved my problem by commenting out this if clause.

What I want to ask is, is there a better way of seeing my managed
models' sql create statements?
I'd prefer to have an option like "--show-managed" to "python
manage.py sql" or sqlall commands, so that this can me done.

What are your comments on this issue?

Thanks.

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.