Re: upgrading from 1.11 and ran into builtin permission clash
> What do I do about this? Clearly I should remove the permission I created. How do I deal with the migration? Should I remove the permission while I run the app as Django 1.11 before moving on to a 2.2 environment? You could rename the current view_inventorychangelog record with a data migration to avoid the constraint, upgrade to 2.2, and then move any references to the old DB record to the new using a data migration. > Sorry, I can't answer your question. But, I am wondering why you are > upgrading to a very out of date version of Django that is no longer > supported. I think 3.2 is the oldest supported version. Why not > upgrade to 4? The options for uplifting severely out of date projects are to either step-by-step migrate through older versions, or rewrite in the target version. Cheers, Michael Manfre -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1fd50ee-97da-4ccd-86ba-90743ebf908cn%40googlegroups.com.
Re: how to get get-pip.py
On Thu, Jun 4, 2015 at 7:15 PM, Steve Burrus wrote: > when I try to run Python it comes for me normally! [ No problem ] I not > heard yet about a pip.exe file. Just where is that contained in the Python > ins tallation anyway? I will try that "pip install virtualenv" soon. > C:\Python34\Scripts\pip.exe I recommend adding C:\Python34\Scripts to your path right after the C:\Python34 folder (each path should be separated by a semicolon) Regards, Michael Manfre -- 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/CAGdCwBuCETybj7AQ0U%3D_0SgHf_ah7CymZpBegnFF3gLdivJkYQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: how to get get-pip.py
"sudo apt-get install ..." is a command that works on Ubuntu and a few other flavors of linux. It does not work on Windows. Which version of Python did you install? If it's Python 3.4 or newer, pip is bundled. Python 3.4 is installed to "C:\Python34\" as the default. To use pip, you would execute "C:\Python34\python -m pip install PACKAGE_NAME" without the surrounding quotes. To avoid having to type the full path all the time, you will need to add it to your path. Please read https://docs.python.org/3.4/using/windows.html#excursus-setting-environment-variables If you are using a version of Python earlier than 3.4, follow the instructions found at https://pip.pypa.io/en/latest/installing.html Regards, Michael Manfre On Thursday, June 4, 2015 at 1:33:47 PM UTC-4, Steve Burrus wrote: > > *I am sorry Dhavi but your command didmn't work! Now I don't think you > know that I am on a Windows system and that "sudo" command do esn't work > on windows. Any other ideas for me? * > > > *On Thu, Jun 4, 2015 at 3:04 AM, DHaval Joshi > wrote:* >> >> >> >> *try this sudo apt-get install python-pip* >> >> >> >> *On Thu, Jun 4, 2015 at 8:54 AM, Steve Burrus > > wrote:* >> >>> *Well Mikea I hardly did it the first time that I tried but I was able >>> to get Python 3.4 installed ! And I also got that ez-setup installed okay. >>> But where do I go from here to get pip going okay? incidentally I tried >>> doing step 5 "C:\users\steve\pip install django" but that didn't work! >>> There must be another path to the django install.* >>> >>> * >>>Steve Burrus * >>> >>> >>> *On Wed, Jun 3, 2015 at 9:04 PM, Mike Dewhirst >> > wrote:* >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> *Sorry Steve I didn't realise you needed help to get Django installed. >>>> You said you were having a problem with pip. Generally the best way to get >>>> help is to explain exactly what you have done and detail the error >>>> messages >>>> generated. Putting your message in bold doesn't help. I just checked my >>>> sent messages and see that I replied to you a couple of days ago at which >>>> time you said you had Django working. I can understand that you are having >>>> problems in a Windows environment because I am forced to use it myself and >>>> I too have to cope with its idiosyncrasies. I didn't know there is a >>>> Windows version 10 and I see from Tuesday's post you say it is a beta >>>> version. If you have no other choice of platform you should expect a beta >>>> version of any operating system to have problems which the supplier really >>>> wants to hear about so they can sort it out. So, to help Microsoft out I >>>> suggest the following: 1. Uninstall Django and Python 2. Install Python >>>> 3.4 >>>> for Windows (3.5 is quite new) exactly as described on the Python website. >>>> 3. Fully document any errors encountered 4. Report such errors to >>>> Microsoft >>>> if any 5. If there were no errors installing Python 3.4 and you are able >>>> to >>>> get a non-Supervisor command prompt running, then install Django like >>>> this: >>>> C:\users\steve\pip install django 6. If you encounter any problems at all >>>> you must let Microsoft know because they will want to fix it. Mike On >>>> 4/06/2015 11:16 AM, Steve Burrus wrote: * >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>
Re: Microsoft SQL Server and Azure SQL Database support
django-pyodbc-azure might be a better choice and it seems to be more actively maintained. On Thursday, May 21, 2015 at 8:30:33 AM UTC-4, felix wrote: > > El 20/05/15 14:39, Meet Bhagdev escribió: > > When I last checked the Django ORM did not have official support for SQL > Server and Azure SQL DB. Is there a way to use SQL Server and more > importantly Azure SQL DB by modifying the DATABASES configuration > in settings.py > > > Try django-pyodbc. On Linux I've used it for SQL Server. > -- 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/ab9b9c1d-356d-45a9-8b43-e09897d4bcab%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Leveraging the ORM for very complex queries
The internals of the ORM are deemed a private API and have undergone significant changes in the past without being constrained by the two release deprecation cycle. As some one who was forced to write query construction code based upon Django internals, my recommendation is to only do that if you have no other choice. You will eventually get hit by a change in a subsequent release of Django that forces you to remain on a no longer supported version of Django while you update the hack for the new version of Django or (better) rewrite it to use supported APIs. Regards, Michael Manfre On Monday, May 4, 2015 at 7:17:49 AM UTC-4, Suriya Subramanian wrote: > > Hi Russ, > > Thank you for your answer. I am aware of raw. However, that's now what I > am looking for. Let me give a few examples of queries that I would like to > write: > > 1) Window functions over an ORM query: > SELECT "date", SUM("weight__sum") OVER (ORDER BY "date") > FROM > ( > MyModel.objects.values('date').annotate(Sum('weight')).query > ) T > > 2) Join of two ORM queries > ( complex ORM query ) NATURAL JOIN ( complex ORM query ) > > Writing query 1 and 2 fully in SQL is painful, since they leverage a lot > of Python and ORM logic (for example: parsing URL arguments and filtering). > Composing SQL and ORM, even if it means having to deal with the guts of > SQLCompiler.as_sql() seems to be a decent solution for me. I am asking if > there any best practices to follow or gotchas to watch out for. > > Thanks, > Suriya > > On Monday, May 4, 2015 at 5:35:50 AM UTC+5:30, Russell Keith-Magee wrote: >> >> Hi Suriya, >> >> It sounds like you're looking for raw SQL queries: >> >> >> https://docs.djangoproject.com/en/1.8/topics/db/sql/#performing-raw-queries >> >> This allows you to issue a SQL query in SQL, rather than trying to bend >> the ORM to meet some complex query requirement. >> >> You can't compose a raw query like a normal Django ORM query (e.g., you >> can't add a filter clause to an raw query), but a raw query object behaves >> exactly like queryset when it returns results - it is iterable, it returns >> full Django objects, and so on. >> >> Yours, >> Russ Magee %-) >> >> On Sun, May 3, 2015 at 9:22 AM, Suriya Subramanian >> wrote: >> >>> Hello, >>> >>> I have to write some complex SQL queries that I am unable to express >>> using the ORM. I construct these complex queries by writing a few simple >>> ORM queries, getting the SQL using QuerySet.query and combining them with >>> various SQL operators manually. These hand-crafted queries are not very >>> flexible because it is very easy to modify the final SQL. >>> >>> My question: Is there a way to programmatically construct the complex >>> queries. I see that I can get the generated SQL and parameters by invoking >>> SQLCompiler.as_sql(). Can I invoke as_sql() on the individual query sets >>> and then construct the complex query? What are some gotchas that I need to >>> watch out for? >>> >>> Thanks, >>> Suriya Subramanian >>> >>> -- >>> 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...@googlegroups.com. >>> To post to this group, send email to django...@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/b4465893-6d08-4ed3-babd-1f6e0f0f52ab%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/b4465893-6d08-4ed3-babd-1f6e0f0f52ab%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> 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/682fc76f-5faa-4dd2-8297-4fb61c320ff1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Windows path for django_crontab
If you don't end up using Celery, another option for a periodic action is to create a management command and schedule it to run with Task Scheduler (http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx). Regards, Michael Manfre On Sunday, January 18, 2015 at 11:12:49 PM UTC-5, sarfaraz ahmed wrote: > > Thanks for replies I really wish people who posted packages should mention > clearly about which OS it;s going to work. I ended up wasting two workdays > in experimenting with kronos,DJANGO-CHRONOGRAPH > <https://www.djangopackages.com/packages/p/django-chronograph/>, > DJANGO-CRONJOBS > <https://www.djangopackages.com/packages/p/django-cronjobs/>,DJANGO-CRON > <https://www.djangopackages.com/packages/p/django-cron/>. > > Surprisingly, DJANGO cron says that it is meant for Windows hosting where > user does not have access to setup the cron jobs. I tried that to... > nothing runs > > Regards, > Sarfaraz Ahmed > > > > -- 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/15c841a4-9c39-4cf0-9831-06fd24651844%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Django-mssql repo has switched to Git
A heads up to anyone using Django-mssql. The project has shifted from Hg to Git (still on Bitbucket). For most people, this will have no impact. If any of you had a dependency to a specific changeset, you will need to update the reference to use Git instead of Hg. I've been using Git daily for a few months and I'm hoping this change will make it easier for me to be more efficient with managing the pull requests that have kindly been submitted. Regards, Michael Manfre -- 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/CAGdCwBvhPTr9vnktF6x16Faa0PZ3gDt%3D8p9TY%3Dp2ufS53M%2BbYQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Porting to Django Linux with SQL Server Backend
It's hard to give constructive feedback without knowing any of the specific errors you encountered, but django-mssql only works on Windows. Depending on the error you encountered with pymssql, you could try django-pymssql (https://github.com/aaugustin/django-pymssql). Regards, Michael Manfre On Wednesday, October 15, 2014 9:03:54 AM UTC-4, robert brook wrote: > > The group has been developing locally with sqllite on Windows. > > We are porting the installation to a Linux environment /windows sql server. > > Looking for suggestions for database connectors from Linux to sql server > 2014 > using: > python3.3 > django 1.7 > > I have installed a local copy of sql server to try and find a connector > package > I have tried the following packages on my windows machine with a local > copy of sql server > > django-pyodbc-azure -This worked after creating a local odbc connection > > The following failed with a variety of errors. > django-pyodbc > pymssql > django-sqlserver > django-mssql > > Any suggestions for the sql server connection for any of these would be > appreciated. > > Thanks in advance > -- 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/4aec095d-58ab-48b0-85ce-385a6e5ac925%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Config: DB or git?
On Wednesday, October 1, 2014 9:30:24 AM UTC-4, Collin Anderson wrote: > > If you're not a programmer or sysadmin, it should be done in the >> > database. >> > > Basically if only users are configuring things (who don't know how to use > revision control), then I think it makes sense to have it in the database. > I don't think your claim holds true for larger projects or at organizations that have more business processes. At my current company, the configuration for the service must be in a database (DynamoDB) to allow for centralized management, auditing, and the ability to change the configuration without a deployment or service restart. Regards, Michael Manfre -- 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/c2a810e0-0edd-4d1a-85c7-e5022559fb0f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Is 1.7 RC1 supposed to support migrations changing user model? Not sure whether to report error as bug!
Report it. Migrations is a new feature and it is better to report any encountered issues now before it is released. Regards, Michael Manfre On Wednesday, July 9, 2014 3:10:26 AM UTC-4, graeme wrote: > > Having read through the comments on this bug: > > https://code.djangoproject.com/ticket/22563 > > I can see that migrations were not originally intended to support changing > AUTH_USER_MODEL > after the initial migration. > > However I am confused about whether it now should. The later comments and > the documentation imply that swappable models > should work provided they have migrations. > > I got the same error as reported in the bug report, but the workaround was > simpler (manually add a dependency on the initial > migration for the app containing my custom user model to the migration > that added a foreign key to it). > > Is this a bug that should be reported, or do we live with workarounds? > -- 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/282129d7-1ff3-4522-a157-8d1f6730ee99%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: trying to configure MSSQL 2012 as backend with Django.
>From looking at the configuration that was posted, the solution was likely to remove "django.db.backends." from the ENGINE. That prefix is only for backends that are included with Django. Regards, Michael Manfre On Sunday, June 15, 2014 5:33:45 PM UTC-4, Ezequiel Bertti wrote: > > What was the solution? > > > On Sun, Jun 15, 2014 at 5:03 PM, sarfaraz ahmed > wrote: > >> Thanks for your help. The issue is resolved ... thanks :) >> >> >> >> On Mon, Jun 16, 2014 at 1:10 AM, sarfaraz ahmed > > wrote: >> >>> Yes, I saw and tried the steps mentioned in that link. I get following >>> error >>> >>> "No module named sqlserver_ado.base". >>> >>> This is lines in setting.py Please help >>> >>> DATABASES = { >>> 'default': { >>> 'NAME': 'blogger', >>> 'ENGINE': 'django.db.backends.sqlserver_ado', >>> 'HOST': ' ', >>> 'USER': 'sa', >>> 'PASSWORD': '*', >>> } >>> } >>> I am new to DJANGO... >>> >>> Regards, >>> Sarfaraz Ahmed >>> >>> >>> On Mon, Jun 16, 2014 at 12:57 AM, Mark Phillips < >>> ma...@phillipsmarketing.biz > wrote: >>> >>>> Did you look here?? >>>> >>>> http://django-mssql.readthedocs.org/en/latest/ >>>> >>>> Mark >>>> >>>> >>>> On Sun, Jun 15, 2014 at 11:35 AM, sarfaraz ahmed >>> > wrote: >>>> >>>>> Hello Friends, >>>>> >>>>> I am trying to moving away from sqlite. Trying to use MS SQl 2012 as >>>>> backend. So far I installed django-mssql on my machine. When I type >>>>> import >>>>> sqlserver_ado... It works fine. >>>>> >>>>> I am new to Django. Please provide me with example to get my MSSQL >>>>> connected to django. More than one example will be appreciated. I check >>>>> lot >>>>> of post however but i am unable find any solution. With proper example. >>>>> >>>>> Thanks in advance. >>>>> >>>>> Regards, >>>>> Sarfaraz Ahmed >>>>> >>>>> -- >>>>> 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...@googlegroups.com . >>>>> To post to this group, send email to django...@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/61f97c7b-6f0f-4132-92ad-a3d986c7fb7f%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/django-users/61f97c7b-6f0f-4132-92ad-a3d986c7fb7f%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> 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...@googlegroups.com . >>>> To post to this group, send email to django...@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/CAEqej2MMx6WBps%2BhNBA%2B5RueY18z212JQWs_NL5A2Rd-qR2Tqw%40mail.gmail.com >>>> >>>> <https://groups.google.com/d/msgid/django-users/CAEqej2MMx6WBps%2BhNBA%2B5RueY18z212JQWs_NL5A2Rd-qR2Tqw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Thanks with regards, >>> Sarfaraz Ahmed >>> >>> >>> >> >> >> -- >> Thanks with regards, >> Sarfaraz Ahmed >> >> >&g
Re: Using SSL and Apache on Windows together
There isn't anything special about setting up Apache with SSL for use with Django. There are plenty of easy to finds tutorials about configuring Apache [1]. I gave a talk about running a Django project on Windows using Apache [2]. I ran in to performance issues due to the GIL and Apache on Windows being thread based, instead of process based. Sadly, there is no video from the talk, but the slides have plenty of information to get you headed in the right direction. If possible, try to use something other than Apache as the SSL end point, such as haproxy. [1] http://manfre.github.io/django-on-windows-talk/ [2] http://httpd.apache.org/docs/current/ssl/ssl_howto.html Regards, Michael Manfre On Sunday, February 9, 2014 9:43:16 AM UTC-5, Robert Jonathan Šimon wrote: > > I was trying to find something on the web, but i didnt found anything. I > want to use HTTPS with my Django project on Windows server. I have > installed Django 1.6 a Python 3.3 64Bit. How can i configure SSL > connection, and are there any problems with it? > Thank for all the help > -- 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/8609a894-de81-4a2d-861a-3e89d64d4b21%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: DecimalField and SQL Server
Which database backend are you using to connect to SQL Server? Regards, Michael Manfre On Friday, December 6, 2013 6:45:30 AM UTC-5, Derrick Jackson wrote: > > Hello all, > > I have a strange occurrence I'd like to share to see if any of you have > run into the same thing. I am using Django 1.5.4, SQL Server 2008, and > have the following field definition in one of my models: > > gift_value = models.DecimalField(max_digits=20, decimal_places=2, > verbose_name='Gift Value') > SQL Server table has the field's dataType as numeric(20,2). > > In my form if I enter the following values: > > 44 is saved as 16 > 22 is saved as 08 > 66 is saved as 24 > > Well you get the picture, no need for me to bore you with more examples. > Have any of you see this happen before? > -- 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/cd7bd3d2-29ef-4bf7-a575-19b113d79735%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Generate a random directory for files to be uploaded
There are two things that you'll need to do. Set the random directory name on the UpFile instance in the view and define a function to use with upload_to that uses the random directory name on the instance to define the file's target path. https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to Regards, Michael Manfre On Saturday, November 23, 2013 10:33:59 AM UTC-5, Matt Lind wrote: > > So I am trying to modify django-jfu ( a multi uploader) to send files to a > unique directory for every unique upload session performed. This is just > due to my application's requirements and to prevent file collisions during > the operations later down the road in my app. > > Anyway, here is views.py (I think the most relevant portion anyway, I > could be wrong) > > def upload( request ): > > # The assumption here is that jQuery File Upload > # has been configured to send files one at a time. > # If multiple files can be uploaded simulatenously, > # 'file' may be a list of files. > #Create the file object > file = upload_receive( request ) > > #Create an instance of our Uploader Class and pass it the file object > instance = UpFile ( file = file ) > #Save the file object > instance.save() > > And the "UpFile" class in models.py: > > class UpFile(models.Model): > file = models.FileField( upload_to = > MEDIA_ROOT+'/'+"".join([random.choice(string.ascii_letters) for n in > xrange(12)])) > > The problem I am having is that it appears that the "random" section at > the tail end of the "upload_to" option in models,py is processed only once > when the server is started (or restarted). > > This won't work for my particular application, as I need the "top level" > for any uploaded of a set of files to be unique. > > For example if I have the following "upload sessions" > > Session 1: User only uploaded a single file. A new random/unique > directory should be generated under MEDIA_ROOT, and the file should be > placed in that directory. > Session 2: User uploaded 2 files. A new random/unique directory should > be generated under MEDIA_ROOT, and BOTH files should be uploaded to that > directory (NOT a different directory per file) > Session 3: User uploaded 100 files. Like session 2 above, a new > random/unique directory should be generated under MEDIA_ROOT and all 100 > files should be placed underneath. > > Later on I plan on cleaning house, but for now simply getting that logic > down will get me moving again... > > Thanks for any help you can provide. > -- 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/50e14318-214e-4560-a27e-03325e250998%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: connecting to MS SQL server in addition to default MySQL
Any particular reason you want to completely avoid the ORM? My main project that uses django-mssql started off with a lot of raw queries (including stored procedure calls) to work with the legacy business database. It was a maintenance headache and one of the main reasons I added support to django-mssql to allow using resultsets generated by stored procedures with Django's raw command [1]. To work directly with mssql from linux, you'll probably want to use pyodbc [2]. If running Django on windows, you can either use pyodbc or install django-mssql and execute raw queries. [1] http://django-mssql.readthedocs.org/en/latest/usage.html#rawstoredproceduremanager [2] https://code.google.com/p/pyodbc/ Regards, Michael Manfre On Wednesday, August 7, 2013 1:42:48 PM UTC-4, larry@gmail.com wrote: > > I have a django app that connects to a MySQL server in the usual way. > I've noe been asked to add some new functionality that requires that I > pull data from a MS SQL server database running on a Windows box. I > don't want to use the django ORM with the db, just access it directly > with some sql in my python code. What's the best way to accomplish > this? > -- 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: NuoDB released 1.2 along with a Django Driver
Copyright (c) 2012, NuoDB, Inc. All rights reserved. You might want to update the license to reflect that most of the code is actually a copy & paste from Django's postgresql_psycopg2 backend, which was obvious because whoever worked on the backend forgot to remove all of the "postgresql" comments from the code. Regards, Michael Manfre On Tuesday, August 6, 2013 2:18:35 PM UTC-4, Lindsey Hoyem wrote: > > Read a full description of the 1.2 Release here : http://bit.ly/187MJYX, > including previews, bug fixes, and product enhancements! If your > interested in the Django Driver, it can be found on github: > http://bit.ly/15Gpis6 -- 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: SQL Server Support - Does it Exist
Although there is no official support for SQL Server, there are two available backends to choose from; django-mssql and django-pyodbc. There has also been some recent discussion on the django-developers mailing list about SQL Server's support and the idea of having officially recognized extensions (see [1]). [1] https://groups.google.com/d/msg/django-developers/O-g06EM6XMM/Y7PcP5VUzYMJ I'm the maintainer of django-mssql and have been using it on http://www.src.org since Django 1.1 and has upgrade to the Django stable version shortly after each release. We're currently on Django 1.4.x and plan on upgrading to Django 1.5 in the next few months. Django-mssql requires pywin32 and must be run on a Windows server. During the ~1.5 years between your post and the previous one in this topic, the django-mssql project has made a lot of improvements, including better documentation [2]. [2] http://django-mssql.readthedocs.org/en/latest/ If your web servers are non-windows, then you can use django-pyodbc. The google code hosted project [3] is a bit out of date, but there is a slightly newer fork available on GitHub [4]. [3] https://code.google.com/p/django-pyodbc/ [4] https://github.com/avidal/django-pyodbc Regards, Michael Manfre On Saturday, March 23, 2013 12:35:08 AM UTC-4, Liang wrote: > > Sadly, django doesn't support sql server officially is the only stopper > for me to adopt django. > > On Friday, 15 July 2011 09:07:23 UTC+8, Russell Keith-Magee wrote: >> >> On Fri, Jul 15, 2011 at 6:03 AM, bruno desthuilliers >> wrote: >> > >> > >> > On 14 juil, 23:15, Python_Junkie >> > wrote: >> >> I have searched for the drivers to use the syncdb utility with MS SQL >> >> Server but have been unsuccessful. >> > >> > https://docs.djangoproject.com/en/1.3/ref/databases/ >> > >> > Django doesn't support MS SQL. >> >> Django doesn't provide *official* support MSSQL. However, we do have a >> supported backend API, and there are several third-party projects that >> implement MS SQL support [1]. I can't comment on their completeness or >> stability, but the projects exist. >> >> [1] >> https://docs.djangoproject.com/en/1.3/ref/databases/#using-a-3rd-party-database-backend >> >> Yours, >> Russ Magee %-) >> >> -- 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: MS Access integration with DJango through conversion to (Postgres or MySQL) xor direct interaction
An access database should not be used for a production site. There are various ways/tools for migrating from access to other databases. Search for how to export from ms access and it should turn up a lot of different methods for migrating to mysql or postresql. Access to MySQL example - http://www.kitebird.com/articles/access-migrate.html Regards, Michael On Nov 30, 12:58 am, Alec Taylor wrote: > Good afternoon, > > Is there an ORM library for python/django which integrates with MS > Access? - I know SQLalchemy dropped support after 0.4, but maybe > there's another to use? > > Alternatively how would I convert one to PostgreSQL or MySQL then > interpret it into ORM syntax for use in i.e. SQLalchemy? > > Thanks for all suggestions, > > Alec Taylor -- 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.
TimedThrottleFilter: Django logging filter to throttle logging
I recently encountered the problem of underlying IO issues triggering gigs of repeated logs that were compounded by the extra logging. To help improve the signal to noise ratio of the logs and prevent the downward spiral of IO issues causing logging that cause more IO issues, I created a logging filter to help reduce the repeated messages. The basic design of the filter is to classify each message based upon a few configurable criteria and then only allow a configurable number of repeated messages in a given interval. The cache is used to track the frequency. There were three specific logging cases I addressed with my approach. System wide issues, a single point of failure, and user specific issues. The user specific issues are mostly to address our GSA and other internal crawlers. To catch system wide issues, logging messages are grouped by exception type and repr(), if type is Exception. Single point of failure really means a single logging call in the code. These are detected by logger name, function name and line number. The filter can be configured (in settings) to ignore specific logging statements to allow uncaught or common exception handlers from being incorrectly grouped together. Specific user logging messages are grouped if the filter can access the request. Code and example LOGGING configuration can be found at https://gist.github.com/1264432 Regards, Michael Manfre -- 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, Apache, MySQL on Windows in Production
I have a decent amount of experience with running apache, mod_wsgi and django on windows (w/ MS SQL). Apache's process module on windows (mpm_winnt) may result in you having to configure around some serious GIL related performance issues. You might not hit the problems if the site is low traffic. You can work around it with a load balancer (either apache, haproxy, or other of your choice) sitting in front of several apache instances on the same machine with ideally each having their processor affinity set to a different, single processor. You'll need to keep the threads per child low to avoid memory bloat. This set up basically fakes the other process modules available on linux. I also did a bit of testing with nginx on windows. It's very resource efficient and fast, but it didn't run well as a service on windows. It orphaned processes when restarting the service. Regards, Michael Manfre On Jul 26, 2:10 pm, Andre Terra wrote: > I recently compiled nginx with an additional module on windows and so far, > so good. I'm probably skipping Apache altogether for this small website. > > As far as PostgreSQL goes, from what I've seen, it works flawlessly on > Windows. Never heard of anyone complaining about that. > > Cheers, > AT > > > > > > > > On Tue, Jul 26, 2011 at 3:03 PM, CrabbyPete wrote: > > I've run django on Windows Server with apache and it was easy to > > deploy. Forget IIS. I've deployed Nginx and uWSGI on linux and that > > was even easier. > > I've never done Nginx on windows, but I don't think it would be a big > > deal. > > > On Jul 26, 1:25 pm, Dimitry Zolotaryov wrote: > > > So if I run into performance issues, I can always pipe from Apache to > > > something like gunicorn and keep Apache serving static media? > > > > Dimitry > > > > On 26 juil, 13:03, Javier Guerra Giraldez wrote: > > > > > On Tue, Jul 26, 2011 at 11:33 AM, Dimitry Zolotaryov > > wrote: > > > > > Knowing this, any advice on the original question would be greatly > > > > > appreciated. > > > > > I haven't done any deployment on windows; but i do know some helpful > > facts: > > > > > - microsoft invests a lot of money in making sure that high-profile > > > > OSS projects do run and run well on windows. That definitely includes > > > > Apache, Python, and MySQL at least. don't know if PostgreSQL enjoys > > > > this treatment (might erode into MS-SQL server mindshare?) > > > > > - nginx and mod_wsgi can be compiled, and kinda run; but with severe > > > > limitations. mod_wsgi in particular can't run in daemon mode. > > > > > - any pure-Python setting should run without surprises, that lets you > > > > choose either gunicorn or flup (for FastCGI) behind Apache. contrary > > > > to some comments, a well-supervised flup setup can perform just as > > > > good as the cool guys; but if you're not familiar with it gunicorn > > > > might be easier. again, it's more a question of familiarity than of > > > > performance. > > > > > good luck! > > > > > -- > > > > Javier > > > -- > > 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. -- 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: Do reverse relations eventually kill performance?
Subclass Manager and make this the default manager for all owner restricted models. Override filter() and get() to check for the "owner" arg. Raise an error if it is not specified. Also set use_for_related_fields = True for the manager to cover the reverse relations. Regards, Michael On Oct 25, 7:28 am, Gerard wrote: > Hiya Tim, > > Thanx for the response. Thing is I already have queries running like this: > > Customer.objects.filter(user=request.user).order_by('company_name') > > The problem however is that I dont trust myself enough to never make a > msitake to show the wrong data to the wrong user. All my models have a > "owner" field, but if the queries are not using that there's unwanted data > disclosure. > > I'm trying to figure out if it's possible to write a tiny piece of > middleware that alarms me when a query is invoked without filtering on the > owner field. > > And at least have it running during development. Would that be afeasible > option? > > Thanx, > > Regards, > > Gerard. > > > > Tim Chase wrote: > > Gerard wrote: > >> Hi all, > > >> I'm working on a safe way to get users to only see there own records. I've > >> been working on subclassing model.Manager and requiring a 'owner' parm for > >> filter() or otherwise returning an emtpy query set .. just to failsafe my > >> own view coding. > > >> Then I figured I could get records in my view via the user.whatever_objects > >> like this: > > >> user = User.objects.get(username=request.user) > >> customer_list = user.customers.all().order_by('company_name') > > >> But that would make two db connects. When growing in scale, could this > >> eventually be a performance bottleneck? > > > This might be rewritable as > > > Customer.objects.filter(user=request.user).order_by('company_name') > > > or > > > request.user.customers.all().order_by('company_name') > > > Test each to see how many queries (not connections) are sent in > > each case. > > > -tim > > -- > self.url =www.gerardjp.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Restricting date_hierarchy
I am working against a legacy database with over 25 years of historical data. I really like the functionality provided by date_hierarchy, but having all 25 years appear above the list is quite ugly. My users will only ever need the past 2-3 years. Is there a way of restricting the year links shown in the date drill down? -- Michael Manfre --~--~-~--~~~---~--~~ 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 generate unique sequence for each organisation in a SaaS app
You can do this without a stored procedure, but it will require two db queries. Create a custom field with an overridden pre_save that fetches the last RecordNum for the org and returns the next in the sequence. You'll want an index on org and recordnum. class AutoRecordNumberField(models.IntegerField): def pre_save(self, instance, add): if not add: return getattr(instance, self.attname) return getattr(instance, 'next_available_recordnum') class TheModel(models.Model): org = ... recordnum = AutoRecordNumberField() @property def next_available_recordnum(self): try: num = TheModel.objects.filter(org=self.org).values_list ('recordnum').order_by('-recordnum')[0] except: return 1 return num[0] + 1 On Sep 15, 4:05 am, Sid wrote: > I'm working on a django SaaS app, which hosts data for multiple > organisations. Each record in a table has a unique RecordNumber. > > I could use autofield to give each record a unique incrementing Id > automatically, but that is globally unique. As in org1 might have say, > RecordNum=1 or 2 or 7 etc and org2 might have RecordNum=3,4,5,6 > > I want each organisation to have its own sequence, i.e. all > organisations might have RecordNum=1 or 2...etc. I can still use > autofield as primary key to identify the row. But i need the RecordNum > field as it will be visible to the end users as sequence numbers > within their org. > > UUID, are too cumbersome to type in while searching for a record. > > I found this > -http://stackoverflow.com/questions/1104741/generating-sequential-numb... > But i before resorting to stored procedures, i want to make sure there > isn't any other way. > > Ohh and btw i'm on MySQL. --~--~-~--~~~---~--~~ 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: multi-table inheritance - how to access child object methods/attributes
This digs through _meta to figure any related fields and tries each until one works. class Document(models.Model): ... def __unicode__(self): name_map = self._meta._name_map subs = [x for x in name_map if isinstance(name_map[x][0], RelatedObject)] for field in subs: try: sub = getattr(self, field, None) return sub.__unicode__() except ObjectDoesNotExist: pass return u'Document {0}'.format(self.id) On Sep 8, 9:01 am, Jan Ostrochovsky wrote: > Ugly workaround: > > class Document(models.Model): > pass > def __unicode__(self): > if self.accountingdocument: > return self.accountingdocument.__unicode__() > else: > return self.__class__.__name_ + ' ' + self.id_ > > But I'd prefer solution, where Document class does not know about its > child classes (AccountingDocument, etc.). Any idea? > > On Sep 8, 8:31 am, Jan Ostrochovsky > wrote: > > > Hello, > > > class Document(models.Model): > > ... > > > class AccountingDocument(Document): > > ... > > > How am I able to access methods an attributes of some > > AccountingDocument instance (e.g. its __unicode__()) from Document > > instance? How am I able to retrieve child object from its parent? > > > I tried to search on the web, but I am not a lot wiser after that... > > > Thanks in advance. > > > Jano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---