Re: Use one correspondig database user for each application user
Answer: Connection pooling Sharing a single DB user for all/multiple Web app users allows connection pooling. Otherwise, you have to create a new DB connection for each HTTP request, or at least for each web app user. Creating DB connections is relatively slow. At least, I learned this reason 20 years ago, and assume it is still true. On the other hand, I've never checked to see whether Django uses a connection pool by default, and it seems pretty quick. Does Django use a connection pool? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/11/17 6:10 AM, Antonis Christofides wrote: Hi, This was discussed three months ago (the subject was "DATABASE DICTIONARY in Settings.py"), and this was my opinion: As you know, RDBMS's keep their own list of users and have sophisticated permissions systems with which different users have different permissions on different tables. This is particularly useful in desktop applications that connect directly to the database. Web applications changed that. Instead of the RDBMS managing the users and their permissions, we have a single RDBMS user as which Django connects to the RDBMS, and this user has full permissions on the database. The actual users and their permissions are managed by Django itself (more precisely, by the included Django app django.contrib.auth), using database tables created by Django. What a user can or cannot do is decided by Django, not by the RDBMS. This is a pity because django.contrib.auth (or the equivalent in other web frameworks) largely duplicates functionality that already exists in the RDBMS, and because having the RDBMS check the permissions is more robust and more secure. I believe that the reason web frameworks were developed this way is independence from any specific RDBMS, but I don't really know. So the canonical way of working is to have a single database user as which Django logs on to the database, with full permissions on the database (including permission to create and delete tables), and many Django users, each one with different permissions. Typically only one Django superuser is created. I call the superuser "admin", which I believe is the common practice. You can probably do things differently, and maybe there exist custom database backends that would allow you to switch the database user on login, but if there's no compelling reason you should really stick to the canonical way. Regards, Antonis Antonis Christofides http://djangodeployment.com On 2017-07-11 12:40, guettli wrote: I guess most applications have exactly one database user. Why not use one database for each application user? Example: User "foo" in my web application has a corresponding database user "foo". This way you could use row level security from the database. PostgreSQL has a lot of interesting features: https://www.postgresql.org/docs/devel/static/ddl-rowsecurity.html Use case: Show me all items which user "foo" is allowed to see. -- 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/7d1eaa8c-d80a-4390-aaf9-8a95d3fcf6b4%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 https://groups.google.com/group/django-users. To view this discussion on the web visit
Re: Restricting the user from closing the browser tab so that the server side APIs are called.
Rahul, I don't think you're going to find a reliable way to ensure that the APIs are called from the browser. There are too many ways for the user to close the browser, or for the browser to crash, or for the browser to lose connectivity to the server unexpectedly (ISP has a glitch, local wireless router has a glitch, laptop carried too far from the WiFi router, cell phone enters a tunnel or drives into some other dead zone), etc. Instead, you may want to do something like this to handle the cases where the user never clicks your end-call button: - Have a frequent timer in the browser make an Ajax call to the server saying that it is still active -- a "keep-alive" or "heartbeat" call, as it is sometimes known. - Have a server-side process do the necessary cleanup that the API call would have done, but only if the keep-alive calls stop coming in. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 5/31/17 5:05 PM, Rahul Paul wrote: Hi, We are working on a django project in which we are developing a two way audio visual solution for the users. Now we have certain set of APIs that need to be called from _javascript_ through ajax request when user ends the call through our end-call button. Some of these ajax calls are sequential i.e. based on result of one ajax call another ajax call is made. Now our problem is if the user close the tab or browser using the cross button of tab or browser, then these APIs are not called and many of our functionalities does not work. Hence to solve this we were looking into the following options : 1. Restricting the user from closing the tab or browser until the user clicks on end-call button and all functionalities related to ending the call is done. 2. Calling the APIs before the browser or tab close when user tries to close the browser or tab. 3. Opening our template as a modal so that we can modify the closing of modal to satisfy our use case. First option is not possible since it poses security risks w.r.t. browser. Currently our web page is opening as new tab. We have tried opening the page as new window and hiding the menu bar, minimize/maximize and cross button, but we could not hide the cross button. We tried the second option using window.onbeforeunload and window.onunload feature of _javascript_ window object, but we could not call the APIs. We are now thinking of the third option, but here we are stuck as we are not sure if the template can be directly rendered as a modal from django views. Also our web page will have the following major components : * video tag, where 2-way A/V will play. * iframe where we have another feature. * chat section where communication happens through django channels. * File upload and download feature. * Many functionalities are based on API call hence many ajax request. In short our web page will be heavy and will have a lot of _javascript_ files to be loaded. So will we get the same efficiency with modal as we get with proper web page? What will be the limitation and if possible how we can render our template as modal? Our main intention have the same flow when the user clicks the end-call button or close the tab or browser i.e. all the functionalities that are happening when end-call button is clicked, must also happen when the user close the tab or browser. Please help me with resolving this issue. You can also provide options other then what we have considered. All suggestions are welcome. Thank you. -- 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 v
Re: Class based view without rendering form
Shivendra, If you want to have an effect at the server without leaving the current page, you'll find that Django itself does not do that. Instead, you'll have to do one of: - Use _javascript_ in the page to make an Ajax or WebSockets call to the server (handled by a Django view if you like) to tell it to update the DB, or... - Use Django "Channels" to communicate with the server via WebSockets. If you find yourself doing lots of Ajax calls to the server, you may want to check out the Django REST Framework which makes it easier to write Django views that accept Ajax calls and return JSON data instead of returning full HTML pages. Or, you can accomplish a similar effect via plain vanilla Django, if you allow the button click to trigger a regular form submit, and have the response look exactly like the original page, so it's not obvious to the user that a full page request was done. But, it sounds like you've already decided you don't want to do that. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 5/28/17 9:25 PM, shivendra bind wrote: Hi, I recently started learning Django. Please help me with following problem. Background: I am using Python 3.5 and Django 1.11.1. I have 2 model class, Album and Song. A song always references to an album. I am using class based views to perform CRUD operations. Problem: how to update single field (favorite album/song) without rendering any form? What it means is user should be able to click a button, which updates column is_favorite in database, without leaving the current page . Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bfde298e-0b3e-4de5-9097-2a83b6ade1d4%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f8a2e862-8622-b5d5-9389-d98367c6fc8b%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: best practices for handling charts
Alceu, I agree that a client side API makes sense in this case. Solves the whole question of temp files. You may want to look into the Google Chart API. It's a REST service, where you pass the data to be graphed, the style of graph desired (line, bar, pie, 3D pie, Venn, Scatter, Radar, Geographic map, Speedometer, etc.), and lots of other optional attributes, as URL params and it returns you a PNG file of the graph. So you simply put URLs in your web page, and the browser collects and displays the graphs. Very easy to use! See my quick summary of it, with lots of dynamically generated examples, here: - http://bristle.com/Tips/Internet.htm#google_chart_api --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 5/23/17 11:40 AM, Alceu Rodrigues de Freitas Junior wrote: Thanks for answering James, I commented your e-mail below: Em 23/05/2017 12:06, James Schneider escreveu: On May 23, 2017 6:33 AM, "Alceu Rodrigues de Freitas Junior" <alceu.freitas...@gmail.com> wrote: Hello to all, I have some charts created with matplotlib and I would like to include them in my Django application. What is the considered best practices in order to do that? I'm considering processing the data and generating PNG files in "temporary" locations, so I when the chart file is created I just need to refer to it in the template. This could create a problem because I would need to remove the chart file after a while, or even better, when the user logs out of the application. I did a quickly search in this group archive and couldn't find anything close related to this. It doesn't look simple to execute any kind of task when the user logs out (signals?) and there is a the risk of users just closing their browsers (which will require that I use crontab or something like it to delete old files). Another possibility is to just open a new browser window and include in the response only the image itself. Is there any better way to implement that? Do you have any reason to keep the charts that are generated? You may be better off using JS to render the chart on the client side, then you don't have to worry about managing files. Maybe something like Flot charts? There's a ton of these libraries out there. http://www.flotcharts.org/flot/examples/ Well, besides having to learn a new API and not reusing the read-to-use code from matplotlib? :-) Just kidding, it makes sense to use client-side for that and avoiding the temporary files problem completely but I really would like to reuse what is already implemented, unless it gives more trouble than using something like Flot. -- 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/c95a5ccb-37c6-53ee-26a3-9296265ee371%40gmail.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 https://groups.google.com/group/django-users.
Re: audit trail functionality in database model
Enrico, In the sample MySQL trigger code of my previous message, you'll see that I always store, in the primary table, the string username of the most recent user to update the table. Therefore, that value is available to the DB trigger as NEW.update_user. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/22/17 7:37 AM, enrico baranski wrote: Thinking about this topic more detailed made me realize that I also need to track the user who performed the insert/change (delete is globally not permitted) actions. However, that are user names managed via Django ... so when i use DB triggers I only can track the MySQL user who is used by the Django application. Probably that leads to the situation that I need to take care of this in Django or does anyone have another idea how to deal with that? -- 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/63c129b8-6279-4410-8242-ccffef134b6f%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/193ab42b-0e2b-e81e-bd71-c1ab63ee7d60%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: audit trail functionality in database model
ng, not foreign key, to preserve history when users are deleted.' ,create_dt DATETIME NOT NULL COMMENT 'Date and time of creation of this database row.' ,update_user VARCHAR(255) NOT NULL COMMENT 'User who last updated this database row. String, not foreign key, to preserve history when users are deleted.' ,update_dt DATETIME NOT NULL COMMENT 'Date and time of last update of this database row.' ,status_id INTEGER NOT NULL COMMENT 'The status of the data in this database row (active, inactive, archived, etc.). FK to itf_dict value of category STATUS_LOOKUP.' ,CONSTRAINT pk_product PRIMARY KEY (itf_product_id) ) COMMENT='Products' ENGINE=InnoDB ; ALTER TABLE itf_product ADD CONSTRAINT fk1_product FOREIGN KEY fk1_product (status_id) REFERENCES itf_dict (itf_dict_id) ; -- Disallow multiple products with same name. -- No, we really want to disallow only for records with STATUS=ACTIVE, -- which can't be done here with a UNIQUE constraint, so this is enforced -- in the Java BO code instead of here. -- CREATE UNIQUE INDEX ak1_product ON itf_product (name); GRANT SELECT, INSERT, UPDATE, DELETE ON itf_product to itfweb; DROP TABLE IF EXISTS itfa_product; CREATE TABLE itfa_product (audited_change_user VARCHAR(255) NOT NULL COMMENT 'User who made this change. String, not foreign key, to preserve history when users are deleted.' ,audited_change_dt DATETIME NOT NULL COMMENT 'Date and time of this change.' ,audited_change_type VARCHAR(255) NOT NULL COMMENT 'INSERT, UPDATE, or DELETE. No need for lookup in ITF_DICT since there are only these 3 types of triggers.' ,itf_product_id INTEGER NULL COMMENT 'Copied from audited table.' ,name VARCHAR(255) NULL COMMENT 'Copied from audited table.' ,descrip VARCHAR(255) NULL COMMENT 'Copied from audited table.' ,notes VARCHAR(255) NULL COMMENT 'Copied from audited table.' ,create_user VARCHAR(255) NULL COMMENT 'Copied from audited table.' ,create_dt DATETIME NULL COMMENT 'Copied from audited table.' ,update_user VARCHAR(255) NULL COMMENT 'Copied from audited table.' ,update_dt DATETIME NULL COMMENT 'Copied from audited table.' ,status_id INTEGER NULL COMMENT 'Copied from audited table.' ) COMMENT='Audit table. No need for constraints.' ENGINE=InnoDB ; GRANT SELECT, INSERT, UPDATE, DELETE ON itfa_product to itfweb; -- DROP TRIGGER itft_ai_product; DELIMITER ;; CREATE TRIGGER itft_ai_product BEFORE INSERT ON itf_product FOR EACH ROW BEGIN -- Purpose: Inserts an audit record into audit table. -- -- MODIFICATION HISTORY -- Person Date Comments -- ----- -- --- -- Fred Stluka 2/12/2007 Original version. -- INSERT INTO itfa_product (audited_change_user ,audited_change_dt ,audited_change_type ,itf_product_id ,name ,descrip ,notes ,create_user ,create_dt ,update_user ,update_dt ,status_id ) VALUES (NEW.update_user ,SYSDATE() ,'INSERT' ,1 + (SELECT IFNULL(MAX(itf_product_id),0) from itf_product) -- Can't just use NEW.itf_product_id. AUTO_INCREMENT -- hasn't yet generated a non-zero value. This works OK -- as long as the highest generated value hasn't been -- deleted from the table. -- -- Can't use: 1 + (SELECT MAX(itf_product_id) from itf_product) -- because it causes the first INSERT to fail. -- MAX comes up NULL and gets added to 1 which produces NULL. -- IFNULL fixes that. -- -- Could perhaps use an AFTER trigger instead of a BEFORE -- trigger, and NEW.itf_product_id would work?? ,NEW.name ,NEW.descrip ,NEW.notes ,NEW.create_user ,NEW.create_dt ,NEW.update_user ,NEW.update_dt ,NEW.status_id ); END; ;; DELIMITER ; -- DROP TRIGGER i
Re: audit trail functionality in database model
Enrico, I've done this in the past. I didn't use Django directly for the audit tables. Instead I defined DB triggers on each primary table that inserted a row of audit values into the audit table. I can send you sample trigger code that works in Oracle and MySQL. The nice things about this approach are that Django can entirely ignore the audit tables, manipulating only the primary tables, and that audit table entries are ALWAYS created, even of you bypass Django and do a direct INSERT, UPDATE, or DELETE to a primary table. You should still be able to define the audit tables as Django models, to get the benefit of schema migrations, etc., and to make it easier to write an audit trail viewer. In my case, I didn't have an explicit "version" field in the primary tables, but you could have the triggers handle that also. Or you could do it in the Django save() method of each model, or in a custom manager. If you go the custom save() or custom manager route, you could do all of the work there, and avoid the need for triggers, but then it would be easy to bypass the audit table by doing a direct INSERT, UPDATE, or DELETE to a primary table. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/21/17 7:15 AM, enrico baranski wrote: Hi all Django users, I'm quite new to Django and currently experimenting with the database model. Defining fields appears to be quite intuitive and is well described in the documentation. However, I am looking into audit trail functionalities. What that means to me. I have two tables, one is my master data table (rooms) and one is my audit trail table for the rooms table. So I aim on two major things, first I would like to increment a field "version" in my room-table to track any change on the table record. Inserting the record means version=1 and as soon as the record is changed the field version should increment to 2 and so on. Second thing would be to automatically track the changes from one version to another in my audit trail table. So I am looking for a way to automatically make table entries when I update the main table ... My final goal is to define the audit trail functionalities in the database models so it is forced on any record manipulation. I hope I could describe my issues comprehensible and would be very happy to get some feedback from you guys. Thanks a lot and best regards, enrico -- 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/8f9d2c8e-3fd9-4e75-b628-4e6ff99ee83c%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/88db55d7-f28b-3099-50a4-1ed3b674e5e4%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: What is the fate of closed database connections?
Mike, Good info. Yeah, keep experimenting and report what you find here. Hopefully someone will jump in with a definitive answer for you. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 4:52 PM, Michael Grundler wrote: CONN_MAX_AGE = 1 behaves similarly to 2 and None. I will try and do some testing with additional spatialite DB drivers. Perhaps its worth noting that I have not seen any of these problems when using postgresql as the DB backend. Many thanks, Mike On Tuesday, January 17, 2017 at 4:18:01 PM UTC-5, Fred Stluka wrote: Mike, I agree. It seems that 0 and 2 should have similar effects in your case. Have you tried 1? So, 2 behaves like None, eh? Perhaps that's because they are both allowing connections to be reused. 0 explicitly prevents connection pooling, so that each request opens/uses/closes its own connection. Maybe there's a bug related to closing connections as you originally suggested? Have you tried a different driver for the spatialite DB? Also, can you experiment with a different DB to shed some light in the problem? Personally, I've found it VERY easy to flip between MySQL and SQLite. On my project, we use MySQL in PROD, but we run all of our regression tests against SQLite. To make this happen, all I had to do was add this to our settings file: RUNNING_UNIT_TESTS = 'test' in sys.argv if RUNNING_UNIT_TESTS: DATABASES['default'] = { 'ENGINE': 'django.db.backends.sqlite3', } Any other ideas, anyone? --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 3:59 PM, Michael Grundler wrote: Fred, I observe this behavior using uwsgi + nginx. Per your suggesting I tried a CONN_MAX_AGE = 2, which seems to have the same qualitative behavior as CONN_MAX_AGE = None (i.e. the error message does not appear in the log after repeatedly refreshing the browser on the admin page). I don't understand why a CONN_MAX_AGE = 0 would yield qualitatively different behavior than CONN_MAX_AGE = 2. Many thanks, Mike On Tuesday, January 17, 2017 at 2:59:21 PM UTC-5, Fred Stluka wrote: Mike, As of version 1.6, Django supports persistent DB connections (connection pooling). CONN_MAX_AGE specifies the number of seconds that a connection will remain open and be reused. You can set it to 0 to cause each DB interaction to open, use, and close its own connection. You can set it to None to allow an unlimited number of connections. See: - https://docs.djangoproject.com/en/dev/ref/databases/ However, the behavior you're seeing doesn't seem to match this documented behavior. I'd have expected CONN_MAX_AGE = 0 to prevent connections from being reused, so they should
Re: What is the fate of closed database connections?
Mike, I agree. It seems that 0 and 2 should have similar effects in your case. Have you tried 1? So, 2 behaves like None, eh? Perhaps that's because they are both allowing connections to be reused. 0 explicitly prevents connection pooling, so that each request opens/uses/closes its own connection. Maybe there's a bug related to closing connections as you originally suggested? Have you tried a different driver for the spatialite DB? Also, can you experiment with a different DB to shed some light in the problem? Personally, I've found it VERY easy to flip between MySQL and SQLite. On my project, we use MySQL in PROD, but we run all of our regression tests against SQLite. To make this happen, all I had to do was add this to our settings file: RUNNING_UNIT_TESTS = 'test' in sys.argv if RUNNING_UNIT_TESTS: DATABASES['default'] = { 'ENGINE': 'django.db.backends.sqlite3', } Any other ideas, anyone? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 3:59 PM, Michael Grundler wrote: Fred, I observe this behavior using uwsgi + nginx. Per your suggesting I tried a CONN_MAX_AGE = 2, which seems to have the same qualitative behavior as CONN_MAX_AGE = None (i.e. the error message does not appear in the log after repeatedly refreshing the browser on the admin page). I don't understand why a CONN_MAX_AGE = 0 would yield qualitatively different behavior than CONN_MAX_AGE = 2. Many thanks, Mike On Tuesday, January 17, 2017 at 2:59:21 PM UTC-5, Fred Stluka wrote: Mike, As of version 1.6, Django supports persistent DB connections (connection pooling). CONN_MAX_AGE specifies the number of seconds that a connection will remain open and be reused. You can set it to 0 to cause each DB interaction to open, use, and close its own connection. You can set it to None to allow an unlimited number of connections. See: - https://docs.djangoproject.com/en/dev/ref/databases/ However, the behavior you're seeing doesn't seem to match this documented behavior. I'd have expected CONN_MAX_AGE = 0 to prevent connections from being reused, so they should be closed at the end of the request that used them. So, unless you have 65 or more concurrent requests, you should not be hitting your limit. I'm not surprised that CONN_MAX_AGE = None has an effect, but I wouldn't have been able to predict whether it makes things better or worse. It allows Django to reuse connections so fewer of them should be created, but it also allows Django to pool them for as long as it likes, so a large number of them may accumulate. Have you tried any other values for CONN_MAX_AGE, like 1 or 2? Also, are you using the Django development server? The docs linked above say: "The development server creates a new thread for each request it handles, negating the effect of persistent connections. Don’t enable them during development." --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 2:25 PM, Michael Grundler wrote: When Django closes a database connection at the end of a request/response cycle does that connection stil
Re: how to do ces monitoring on django application
Anjali, What do you mean by "ces monitoring"? I've never heard of it. When I searched: - http://google.com/search?q=ces+monitoring I found some references to IBM products. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 6:06 AM, anjalim...@gmail.com wrote: I want to do ces monitoring for my application. I got one module as statsd but that wasn't helpful. Can anyone provide me suggestions how I can do that. Thanks in advance, Anjali -- 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/7f89f222-be77-4410-8e0d-856ae4a0c02d%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a3a4648-b7cb-9300-b4a3-a517e98d90eb%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Django search
Branko, You may need to explain a little more. It sounds like you have search working when you type the search string into a HTML text box. True? What do you want to do with the menu and checkbox? Are you trying to arrange for the text of the menu label and the text of the checkbox label to be combined somehow to form the search string? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 9:32 AM, Branko Zivanovic wrote: Thank you for reply! I'm fine with text input but I also want select menu and checkbox. I want to use it to somehow filter my search. I'm not sure how it fits anyway in bigger picture. How do people make search with select menu and checkbox? Best, Branko понедељак, 16. јануар 2017. 07.13.44 UTC+1, Constantine Covtushenko је написао/ла: Hi Branco, Sorry, but can you be more specific? If you've got the result what is your concern? Do you only need to switch into forms? Regards, Constantine C. On Sun, Jan 15, 2017 at 2:41 PM, Branko Zivanovic <internati...@gmail.com> wrote: How do i implement search on django website with select menu and checkbox? I've succeeded in adding basic text input and it works but I didn't use django forms. How do I add this type of search? -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/078841f1-a976-4c22-bb2f-ff5069bdce1d%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9fc70bbe-487d-4c4b-8f9a-77ad79281193%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a899b1c5-a9ad-015f-e451-20363de1b8c1%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: What is the fate of closed database connections?
Mike, As of version 1.6, Django supports persistent DB connections (connection pooling). CONN_MAX_AGE specifies the number of seconds that a connection will remain open and be reused. You can set it to 0 to cause each DB interaction to open, use, and close its own connection. You can set it to None to allow an unlimited number of connections. See: - https://docs.djangoproject.com/en/dev/ref/databases/ However, the behavior you're seeing doesn't seem to match this documented behavior. I'd have expected CONN_MAX_AGE = 0 to prevent connections from being reused, so they should be closed at the end of the request that used them. So, unless you have 65 or more concurrent requests, you should not be hitting your limit. I'm not surprised that CONN_MAX_AGE = None has an effect, but I wouldn't have been able to predict whether it makes things better or worse. It allows Django to reuse connections so fewer of them should be created, but it also allows Django to pool them for as long as it likes, so a large number of them may accumulate. Have you tried any other values for CONN_MAX_AGE, like 1 or 2? Also, are you using the Django development server? The docs linked above say: "The development server creates a new thread for each request it handles, negating the effect of persistent connections. Don’t enable them during development." --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/17/17 2:25 PM, Michael Grundler wrote: When Django closes a database connection at the end of a request/response cycle does that connection still maintain its hold on the database? I ask because I am running an app on a spatialite (v4.3.0a) database, which, due to a limitation in the GEOS library (v3.6.1-CAPI-1.10.1 r0), can only accept a maximum of 64 connections. When I configure Django so that CONN_MAX_AGE = 0, the server log will eventually begin filling up with messages that read "ERROR: Too many connections: max 64". If I enable persistent connections by setting CONN_MAX_AGE = None, these messages disappear. To me this suggests that when Django closes a connection at the end of a request/response cycle that connection persists from spatialite's perspective. Is this expected behavior? The error message is easily reproduced by starting a project configured to use spatialite, logging into the admin page, and then refreshing your browser repeatedly until 64 requests have been made. Thanks for any insights, Mike -- 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/8b2d88c4-056c-4eeb-9dc9-7295f7ff0961%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6d7eefba-47ac-5a7c-a6b2-1bc38091f7e2%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: How to make a queryset into a database, starting from a template html
Carlobo, If you want the nation field to be given a value as soon as a a dialing prefix is entered, without posting the page to the web server and retrieving a new page, you're going to have to use _javascript_ and the perhaps the technique called Ajax. Django and its Python code run only on the server, not in the browser. So, it cannot fill in one field based on another, except by posting the partially completed form to the server and having it sent back with the one additional field filled in. The disadvantages of this approach include: - Slower than the approaches described below - Harder to preserve the user's context in the Web page (which field had the keyboard focus, how far down the page was scrolled, etc.) - May place a heavier load on the server If you want to use _javascript_, you can include the _javascript_ code in an HTML
Re: Odd problem: some database updates do not appear on other pages until server restart
Bob, On 8/19/16 8:02 AM, bobhaugen wrote: > On Friday, August 19, 2016 at 5:20:45 AM UTC-5, Michal Petrucha wrote: > > Moving the call to with_user to form.__init__ solved the problem in the form ModelChoiceField. > > These questions remain unanswered, although I intend to do a bunch more testing: > > How pervasive is this problem? Does it affect template variables like {{ object.foreign_key_method }} where the foreign_key_method returns a queryset? I think this is very pervasive. That is, it happened a few times to my team until we educated all developers to never use the choices, limit_choices_to, or queryset parameters of a Model field or Form field. Instead, we always explicitly set them in __init__() instead. I assume other teams also make this mistake often. For us, this mistake caused 3 separate type of problems: 1. The problem you described: Old data from the DB was "cached" until we restarted the Django server, because the DB query was done only when the Model or Form class was defined, not when each Model or Form instance was created. So, in answer to your question above, yes, it would also affect template variables that refer to the data that was loaded from the DB when the class was defined. 2. Occasional import loops, which prevented the Django server from starting the app, because the value of the choices, limit_choices_to, or queryset parameter caused another model to be loaded. This would trip us up badly because the import loop would often occur in our TEST or PROD environments (Django loaded via Apache WSGI) but not in our DEV environments (Django DEV server), since the order of class imports could be different in those 2 different configurations. See: - https://groups.google.com/forum/#!topic/django-users/ONGCSO37UWY 3. There's a warning here about this mistake being able to pollute your TEST execution with PROD data: - https://docs.djangoproject.com/en/dev/topics/testing/overview/#the-test-database > Is this behavior clearly documented anywhere? It didn't jump out at us. We got burned by and it and put in some time to diagnose it. Then we found the above link that warns of one of the problems. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/4ae3b41a-1bbb-0f9f-660a-938a80ace6d0%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: multiple databases - two questions
Mike, Yeah. Makes sense. Good thought about the UUIDs! My success was due partly to the fact that I could afford to move entire tables, not just selected rows, and could move all related tables as well. Trying to move just some of a related set of data from one DB to another with each DB generating its own set of auto-incremented PKs would have been a problem. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/2/17 11:04 PM, Mike Dewhirst wrote: On 3/01/2017 12:32 PM, Fred Stluka wrote: Mike, Maybe you don't need a custom DB manager. Perhaps a simple DB router would suffice? It's a Django way to specify which DB to use based on which model is being used, whether it is being read/written, etc. That's the approach I took. The essence of the problem: it ain't simple. There are many and varied relationships and any transfer of *related sets* of data to another database means transferring existing PKs which tie the sets together. Maybe if it was a foreseen design criterion we would have used UUIDs instead of incrementing integer ids. The DB router is designed for naturally segmented schemas being on different databases. My attempt was against the grain. Cheers Mike See: - https://docs.djangoproject.com/en/dev/topics/db/multi-db/#topics-db-multi-db-routing --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/4/16 12:37 AM, Mike Dewhirst wrote: (this one might be easier to read) I am planning some utility helper code to push selected records and their children from our staging database into the production database. The current database would be 'default' and I could add a second one called 'production' then read from 'default' and write to 'production'. (I need to check we are on the staging server). The docs say ... https://docs.djangoproject.com/en/1.8/topics/db/multi-db/#using-managers-with-multiple-databases ... but I don't quite understand. There are no custom managers involved; only the out-of-the-box MyModel.objects. Q1. Should I be using db_manager()? The plan is to write some utility code like this ... from substance.models import Substance def write_substance_to_production(subst): prd_subst, create = Substance.objects.using('production').get_or_create( name=subst.name, ) if create: pass # copy all subst attributes except id to prd_subst Q2. Is this a reasonable approach? Thanks for any hints Mike -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/ee0a7b26-3330-60e2-2ad1-9ef2baa6ba40%40bristle.com . For more options, visit https://groups.google.com/d/optout.
Re: multiple databases - two questions
Mike, Maybe you don't need a custom DB manager. Perhaps a simple DB router would suffice? It's a Django way to specify which DB to use based on which model is being used, whether it is being read/written, etc. See: - https://docs.djangoproject.com/en/dev/topics/db/multi-db/#topics-db-multi-db-routing --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/4/16 12:37 AM, Mike Dewhirst wrote: (this one might be easier to read) I am planning some utility helper code to push selected records and their children from our staging database into the production database. The current database would be 'default' and I could add a second one called 'production' then read from 'default' and write to 'production'. (I need to check we are on the staging server). The docs say ... https://docs.djangoproject.com/en/1.8/topics/db/multi-db/#using-managers-with-multiple-databases ... but I don't quite understand. There are no custom managers involved; only the out-of-the-box MyModel.objects. Q1. Should I be using db_manager()? The plan is to write some utility code like this ... from substance.models import Substance def write_substance_to_production(subst): prd_subst, create = Substance.objects.using('production').get_or_create( name=subst.name, ) if create: pass # copy all subst attributes except id to prd_subst Q2. Is this a reasonable approach? Thanks for any hints Mike -- 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/ee0a7b26-3330-60e2-2ad1-9ef2baa6ba40%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: localStorage to save answer to form until it is sent to server
Raniere, Another possibility is to do the temporary storage on the server instead of the client. Use _javascript_ to make an occasional Ajax call to the server to store the current data in the session. Don't necessarily have to store it in the DB. Make the occasional calls based on a _javascript_ timer or something. Many web-based tools use this technique. For example, Google Docs. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/10/16 7:39 PM, Mike Dewhirst wrote: On 11/11/2016 2:41 AM, Raniere Silva wrote: Hi all, I have some text area on my form that I expected that the user will take a few minutes to answer and I want to avoid them to need to type everything again if something happen (e.g. their device got out of battery). Something that I think I could use is localStorage to store the temporary answer. I couldn't find a native solution to my problem neither a package. Did I missed something? Or I'm on the wrong path? I have a copy of Mark Pilgrim's HTML5 Up and Running. Chapter 7 probably covers everything you want. Here are chapter 7 section headings copied from the O'Reilly site. Google "html5 up and running" and that site appears at the top of the list. 1. Diving In 2. A Brief History of Local Storage Hacks Before HTML5 3. Introducing HTML5 Storage 4. Using HTML5 Storage 5. HTML5 Storage in Action 6. Beyond Named Key/Value Pairs: Competing Visions 7. Further Reading Cheers, Raniere -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/2f5c60ff-76bd-4706-bc04-2a0adf1c4a76%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2bf2352a-a9ce-2845-0f34-ad6068fe6973%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Admin - saveasnew to another database
Mike, On 11/11/16 8:00 AM, Mike Dewhirst wrote: > ... My solution is to tell the users to avoid doing real work on the > staging server. It exists only to check out new features. ... I have a similar issue with users of my TEST vs PROD web sites. They develop experimental data in TEST and then want me to move it to PROD once they have it ready. So far, I've been able to accommodate them by dumping part or all of the TEST DB and importing it into the PROD DB using native tools that come with the DBMS (MySQL in this case). But, the best solution, I think, is to add a "Draft" field to the models, so that they can perform their experimental data changes in PROD flagging them as draft, and then clear the draft flag when they are ready for other users to see the new data. This may require an access control system that allows privileged users to mark data as draft, and to specify which other users can see/edit the draft data, etc. May also need multiple different drafts, so you get into version tracking, etc. Not simple, but may be the best answer to your problem. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/11/16 8:00 AM, Mike Dewhirst wrote: To finish this thread, I have decided to abandon the attempt. My solution is to tell the users to avoid doing real work on the staging server. It exists only to check out new features. I feel better now. Thanks Melvyn and Tim Mike On 10/11/2016 11:08 AM, Mike Dewhirst wrote: On 10/11/2016 12:06 AM, Tim Graham wrote: I see. Although I would be interested to see what you come up with, @Tim It is getting there so if you are really interested I'll post it somewhere when it is working. I'm getting router errors at the moment which I might be able to workaround by permitting null in a FK fields during obj.save(using=db). Might ask some questions on this later. I don't really want to permit null in this particular case. my initial reaction is that we wouldn't accept a patch for Django to do this. It seems too complex and brittle. Having done some work on this I agree with you but disagree with Melvyn. The task is complex and would be almost impossible to generalise. For example, from a number of substances the user may have done serious work on only a few and won't want the others transferred. So I'm building a facility to transfer one substance at a time. If there is a future requirement for bulk transfer I can iterate. The transferred substance might be a mixture in which case I have to collect the ingredient substances plus the m2m through records which are effectively the recipe. Some of the ingredients might themselves be mixtures. Not worrying about that at the moment. For each substance there are 6 OneToMany, up to 15 OneToOne and two m2m relationships plus a OneToOne where the sibling has lots of its own complex relationships including a recursive OneToOne to form a daisy-chain of history. I'm skipping that one for the moment. I agree with Melvyn See below that it seems unusual to use Django's multi-database facilities to transfer data between staging and production. On Wednesday, November 9, 2016 at 4:51:39 AM UTC-5, Melvyn Sopacua wrote: On Wednesday 09 November 2016 13:59:35 Mike Dewhirst wrote: > On 9/11/2016 9:13 AM, Tim Graham wrote: > > Interesting idea. I'd be interested to here more about the use case. > > Simple. I permitted my users to "play" on the staging site and now one > of them wants to transfer their work to the production site. Your approach is wrong. You think of this as one django project and trying to chea
Re: Help with django form an ajax, error 500
Elros Romeo, Can you see the log file? It may show details of the 500 error, which will likely be some error reported by your Django code. Could be anything from a Python syntax error to a failed attempt to connect to a DB, to a misconfigured settings file, or anything else. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/17/16 9:31 PM, agapito treviño wrote: Elros Romeo as defined by the form.as_p.? I want to implement this El viernes, 15 de julio de 2016, 18:49:00 (UTC-5), Elros Romeo escribió: Hi, i hope you can help me, im trying to make a django post form without reloading the page using ajax, but im getting error 500 when submit, can you help me to fix this, this is my code: models.py class ProductoConcepto(models.Model): producto = models.ForeignKey(Producto) orden = models.ForeignKey(Cobro) cantidad = models.FloatField() urls.py from django.conf.urls import patterns, include, url from django.contrib import admin from cobro import views urlpatterns = [ url(r'^cobro/agregar_concepto/$', views.addconcept_product, name='add_concepto'), ] views.py def addconcept_product(request): if request.method == 'POST': if form.is_valid(): producto = request.POST['producto'] orden = request.POST['orden'] cantidad = request.POST['cantidad'] ProductoConcepto.objects.create(producto=producto, orden=orden, cantidad=cantidad) return HttpResponse('') template span> Cerrar Agregar nuevo concepto Datos de concepto a agregar: {% csrf_token %} {{form2.as_p}} </div> <div> $(document).on('submit', '#formulario-modal', function(e){</div> <div> e.preventDefault();</div> <div> $.ajax ({</div> <div> type: 'POST',</div> <div> url: '{% url 'add_concepto' %}',</div> <div> data: {</div> <div> producto: $('#id_producto').val(),</div> <div> orden: $('#id_orden').val(),</d
Re: Unable to get tests to work
Matt, At a glance, the directory structure looks OK. Seems odd though that you have some *.pyc files with no corresponding *.py file. For example, frontend/tests.pyc and nas/tests.pyc. Could such a file be tripping up the test runner? That might explain why it fails when no arguments -- searching for all tests and getting confused -- but succeeds when told to run only backups.tests. Same for all of the erp/*.pyc files. Perhaps try deleting all *.pyc file in the entire tree and then run the tests, letting them be recreated from the *.py files as needed. Also, I see a backup/tests.py with no *.pyc file. Is there a syntax error in that file that makes it not compile? Or is it just not getting that far? Also, what is in pytest.ini? Is it perhaps directing the test runner to look for tests that don't exist? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/18/16 3:49 PM, Matt wrote: Sorry replied to the wrong thread: https://dpaste.de/OF8j On Wednesday, August 17, 2016 at 11:16:27 PM UTC-6, Gergely Polonkai wrote: Hello, this “refreshes.backups.tests” thing bothers me a lot. Could you show us your directory structure, please? Best, Gergely On Wed, Aug 17, 2016, 23:03 Matt <kicke...@gmail.com> wrote: Ok a step forward. When I spell out the tests it works: https://dpaste.de/2MXf But when I run test without arguments, it fails out: https://dpaste.de/cgTH There is more than the backups app here, but I plan to replicate out the fix when I get it. On Wednesday, August 17, 2016 at 2:34:45 PM UTC-6, Fred Stluka wrote: Matt, Oops! Right. I just noticed that in the dpaste. My next guess is you may need to change the name "good_index_text" to something that starts with "test_" to get it to be recognized as a test. Or maybe something to do with "refreshes"? The test trace shows it trying to run testcase "refreshes.backups.tests", but in the manual import you did from the python shell, you only import "backups.tests" --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/17/16 4:27 PM, Matt wrote:
Re: Unable to get tests to work
Matt, Oops! Right. I just noticed that in the dpaste. My next guess is you may need to change the name "good_index_text" to something that starts with "test_" to get it to be recognized as a test. Or maybe something to do with "refreshes"? The test trace shows it trying to run testcase "refreshes.backups.tests", but in the manual import you did from the python shell, you only import "backups.tests" --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/17/16 4:27 PM, Matt wrote: Sorry for the typo, but I have already do that way. I have the output in the the first link. On Wednesday, August 17, 2016 at 2:24:19 PM UTC-6, Fred Stluka wrote: Matt, Drop the "s" from "tests": ./manage.py test backups --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/17/16 4:17 PM, Matt wrote: When I'm trying to get tests to work it simply states that its unable to import .tests. I'm not sure what I'm missing here. Here is some output please let me know if you need more: ./manage.py tests backups https://dpaste.de/4U9C The test file: https://dpaste.de/bBZt -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/89d6fac7-0848-4e35-8b4a-62d24178c3aa%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/04fcacea-15d0-42af-afe5-424c2d1df86f%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fe478f0c-532e-8ad4-9b66-2a8145677f86%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Unable to get tests to work
Matt, Drop the "s" from "tests": ./manage.py test backups --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/17/16 4:17 PM, Matt wrote: When I'm trying to get tests to work it simply states that its unable to import .tests. I'm not sure what I'm missing here. Here is some output please let me know if you need more: ./manage.py tests backups https://dpaste.de/4U9C The test file: https://dpaste.de/bBZt -- 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/89d6fac7-0848-4e35-8b4a-62d24178c3aa%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d6df2c33-01fc-ae4f-d9f9-4fb6296f5342%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: How to save one field value from a model to another field of a linked model.
Md. Ohiduzzaman, Looks good so far. What happens when you try it? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/16/16 1:34 PM, Md. Ohiduzzaman wrote: I have designed a linked model named Shiftdate as: class Shiftdate(models.Model): shift_date = models.DateField(blank=False,unique=True) sit_date = models.ForeignKey(Sitting, on_delete=models.CASCADE)Using this model I changed sit_date to shift_date which is like: Sitting Date Shifting Date 2016-09-01 Sept. 15, 2016 2016-09-08 Sept. 19, 2016 Now I need to save this shifting date to the Sitting date as sit_date in Sitting model. My Sitting model is:class Sitting(models.Model): sit_date = models.DateField(blank=False,unique=True) cut_off_date = models.DateField(null=True, blank=True) ballot_date = models.DateField(null=True, blank=True) sess_no = models.ForeignKey(Session, on_delete=models.CASCADE) genre = TreeForeignKey('Genre', null=True, blank=True, db_index=True) I use def get_shift_date(self):return self.sit_date=self.shift_date -- 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/8894d393-5d97-4c97-ba56-1a319d93acec%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c32af6d2-4ab6-73c5-8934-e08b4a3ff0a9%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Database data caching in Django?...
Django users, Is there an easy way to enable an automatic write-through database cache in Django? I'd want memcached or something to cache all data read by the Django ORM and use the cached copy on future reads, and of course update the cache as well as the DB (a "write-through" cache) when writing data. Is there a piece of middleware I can activate to cause the ORM to do this automatically for all DB queries? Thanks! Details: I'm interested in caching the results of queries to the DB, not caching the results of templates or views. So, it is different from the following, which I already know how to do: - Caching of template files: - http://us5.campaign-archive1.com/?u=a8d4be66d1927077a9255182d=a6f7d644a7=c90970e145 - https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.cached.Loader - Caching of all Django views for an entire site: - https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache - Caching of specific Django views: - https://docs.djangoproject.com/en/dev/topics/cache/#the-per-view-cache - Caching of fragments of a Django Template: - https://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching I'm also hoping to not have to add cache API calls throughout my code, as described here: - https://docs.djangoproject.com/en/dev/topics/cache/#the-low-level-cache-api I'd like the Django ORM to make the API calls for me automatically when I call objects.get(), objects.filter(), save(), etc. I'd hoped to enable it simply by adding middleware or a custom manager or something. Any suggestions? I feel like I may be missing something obvious. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/054667d7-381c-9783-a959-626d72574537%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Forcing Localization
Adam, Is it possible to force localization to a particular regional standard, no matter where I am viewing the page from? I don't know for sure, but it seems like some of these settings should be relevant. It's a place to start anyhow. Anyone have a more specific answer? # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # On Unix systems, a value of None will cause Django to use the same # timezone as the operating system. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'US/Eastern' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True INPUT_FORMATS = [ '%Y-%m-%d', # '2006-10-25' '%m/%d/%Y', # '10/25/2006' '%m/%d/%y', # '10/25/06' '%b %d %Y', # 'Oct 25 2006' '%b %d, %Y', # 'Oct 25, 2006' '%d %b %Y', # '25 Oct 2006' '%d %b, %Y', # '25 Oct, 2006' '%B %d %Y', # 'October 25 2006' '%B %d, %Y', # 'October 25, 2006' '%d %B %Y', # '25 October 2006' '%d %B, %Y', # '25 October, 2006' ] --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/7/16 9:48 PM, Adam Starrh wrote: I am writing an application for my small business based in India, where numbers are commonly understood in terms of lakhs and crores. ie. 1,000,000 is displayed as 10,00,000 I am assuming that enabling localization will cause numbers to display this way when I am viewing my application from an Indian server. However, I would also like to view the data this way when I am in the United States. Is it possible to force localization to a particular regional standard, no matter where I am viewing the page from? -- 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/604036bf-2557-4c63-8718-3950dd89010f%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52ffb9cd-000c-6e58-dc5e-a03341da2998%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Testing if a view have an html element with at least one attribute
Ludovic, On my project, we have lots of test cases that do a GET or POST and then check the returned HTML. We use the BeautifulSoup HTML parser from our Django tests to avoid the types of errors you're getting with simple string comparisons. I'm not sure if there any pros/cons vs lxml, but it works great for us! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/31/16 5:08 PM, Andreas Kuhne wrote: Jupp, thats about what I meant :-) Probably the best way, if you don't want to check text. Regards, Andréas 2016-07-31 18:01 GMT+02:00 ludovic coues <cou...@gmail.com>: Currently, I am using lxml. More dependencies but it's the cleanest method I've found currently. I use it like that: from django.test import TestCase from lxml import etree class FormTest(TestCase): def test_input(self): response = self.client.get('/accounts/login') self.assertEqual(response.status_code, 200) doc = etree.HTML(response.content) self.assertEqual(len(doc.findall('.//input[@name="username"]')), 1) 2016-07-31 17:46 GMT+02:00 Andreas Kuhne <andreas.ku...@suitopia.com>: > 2016-07-31 15:59 GMT+02:00 ludovic coues <cou...@gmail.com>: >> >> Oh, sorry. A bit of misunderstanding and miscommunication on my part. >> >> The exemple I gave is just a quick way to reproduce my problem. The >> real test use self.client, reverse, cast response.content to a string. >> What I gave is a minimal exemple. >> >> Also, I assumed you talked about comparing bit of html element, not >> the raw content returned by the view. I'm quite uneasy to have the >> test failing if a class is added or removed from the element. But yes, >> your solution work for the current state of the application. >> >> 2016-07-31 14:46 GMT+02:00 Andreas Kuhne <andreas.ku...@suitopia.com>: >> > 2016-07-31 13:56 GMT+02:00 ludovic coues <cou...@gmail.com>: >> >> >> >> First, thanks for the suggestion. >> >> >> >> I just tried that, didn't work. >> >> Here is the test file I used: >> >> >> >> >> >> from django.test import TestCase >> >> >> >> class HTMLTestCase(TestCase): >> >> >> >> def test_input_in_fieldset(self): >> >> fieldset = """ >> >> >> >> >> >> >> >> maxlength="254" name="username" rows="3" type="text" required /> >> >> >> >> """ >> >> self.assertInHTML('', fieldset) >> >> self.assertInHTML('', fieldset) >> >> >> >> >> >> First input is to have a working exemple, second is taken as is from >> >> my view. Not closing the input in assertInHTML give an error `Couldn't >> >> find ' >>
Re: Is it possible to share a DB between Django and another application
Albert, Yes, any other app , written in Python or any other language, should be able to access your relational DB concurrently with your Django app, if it has the right credentials. This is true for PostgreSQL, MySQL, Oracle, DB2, or any other RDBMS you might use. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/20/16 11:03 AM, Albert180 wrote: Hello I wanted to know if it's possible to share a Database between a Django App ( The WebApp) and another external App which processes the Data ? -- 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/5b863fe3-c99f-44cf-b3fa-1773911a2223%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0454491-752b-3daf-65cc-d9950ef45751%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Email List
David, There may be a package that does it all for you. But if not, you can create a model that stores email addresses and send to those addresses via the Django mail package. See docs at: - https://docs.djangoproject.com/en/dev/topics/email/ Here's what my code to send email looks like: from django.core.mail import EmailMessage, EmailMultiAlternatives def send(to, subject, body="", cc=[], bcc=[], html_body=None): try: # Pulls implicitly from settings.py, but can each be overridden here. # EMAIL_HOST # EMAIL_PORT # EMAIL_HOST_USER # EMAIL_HOST_PASSWORD # EMAIL_USE_TLS # DEFAULT_FROM_EMAIL if html_body: email_message = EmailMultiAlternatives() else: email_message = EmailMessage() email_message.to = to email_message.cc = cc email_message.bcc = bcc email_message.subject = subject email_message.body=body if html_body: email_message.attach_alternative(html_body, "text/html") email_message.send(fail_silently=False) success = True except smtplib.SMTPServerDisconnected as e: msg = u'Unable to connect to SMTP server ' + settings.EMAIL_HOST msg += u' to send e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPSenderRefused as e: msg = u'The SMTP server ' + settings.EMAIL_HOST msg += u' refused to send e-mail from ' + unicode(e.sender) msg += u' when asked to send e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPRecipientsRefused as e: msg = u'The SMTP server ' + settings.EMAIL_HOST msg += u' refused to send e-mail to recipients ' + unicode(e.recipients) msg += u' when asked to send e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPDataError as e: msg = u'The SMTP server ' + settings.EMAIL_HOST msg += u' refused to accept the message data' msg += u' when asked to send e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPConnectError as e: msg = u'Could not establish a connection with the' msg += u' SMTP server ' + settings.EMAIL_HOST msg += u' to send e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPHeloError as e: msg = u'The SMTP server ' + settings.EMAIL_HOST msg += u' refused our HELO message' msg += u' when sending e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPAuthenticationError as e: msg = u'Unable to authenticate with SMTP server ' + settings.EMAIL_HOST msg += u' when sending e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPResponseException as e: msg = u'The SMTP server ' + settings.EMAIL_HOST msg += u' returned: (' + unicode(e.smtp_code) + u') ' + unicode(e.smtp_error) msg += u' when sending e-mail to ' + unicode(email_message.to) exception = e except smtplib.SMTPException as e: msg = u'Unable to send e-mail to ' + unicode(email_message.to) exception = e except BaseException as e: msg = u'An unexpected error occurred ' msg += u' when sending e-mail to ' + unicode(email_message.to) msg += u' during step: "' + progress + u'"' exception = e finally: if not success: raise EmailException(msg, exception) --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/18/16 7:02 AM, 'davidt' via Django users wrote: I have a model that includes an option to subscibe to an email list. However, being somewhat new to Django I am assure how to create a bulk email list form this to send to the appropriate people. I have read various documents on this and have ended up somewhat confused. Could someone please offer me some enlightenment as to the best way to do this? Many thanks in advance. -- You received this message because you are subscribed to the Goo
Re: Slow Django dev server reload
Krishna, Only a third of your count -- 551 % tcsh % python -v manage.py runserver >&! ~/1.1 % grep -E "^import" ~/1.1 | wc -l 551 So, you didn't see any noticeable pauses as the -v output was streaming to the terminal window? Sounds like it's just doing a lot of work, not stalling out anywhere in particular. Why so many imports? Seems odd that I have more models, but fewer lines of code, and far fewer imports. Are all of your imports still needed? Or are many of them obsolete and could be deleted? We tend to get rid of our dead ones pretty quickly because PyCharm shows them as grey when they're not needed. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/5/16 2:00 PM, Krishna Bharadwaj wrote: Hi Fred, Thanks for providing your project as a reference and also the python verbose tip. I just started my dev server with the -v option to see how many import statements are fired. grep '^import ' returned about 1500 lines in the output (about 75 models with about 40k lines of code). I could not narrow down the problem to any specific import / module. Curious to know how many imports were fired in your case? On Tuesday, 5 July 2016 01:50:26 UTC+5:30, Fred Stluka wrote: Krishna, I'm using: - Mac OSX 10.11.5 (El Capitan) - 2.3GHz Intel Core i7 - 16 GB 1333 MHz DDR3 - 512GB SSD - Python 2.7.3 - Django 1.4.2 - MySQL 5.1.33 And it takes less than a second from when I type: % python manage.py runserver until I see: Validating models... 0 errors found Django version 1.4.2, using settings 'hhl.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. I have about 40 models.py files, of which 25 are empty and exist only to prevent warnings when run automated tests. The other 15 contain about 100 Django models with a total of about 27,000 lines of code. The 100 models all get validated against a locally running MySQL server. So, it should NOT be that slow on your Mac. To narrow down the problem, I suggest you use the -v option: % python -v manage.py runserver and watch to see what seems to be taking so long. Any other suggestions, anyone? --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/4/16 2:20 AM, Krishna Bharadwaj wrote: Hi Fred, It takes about 3.5 - 5 seconds on my machine (Mac OSX - 2.6 GHz Intel Core i5, 8 GB 1600 MHz DDR3 and SSDs). I was curious to know if I was doing something wrong. Any pointers regarding this will be very helpful. On Sunday, 3 July 2016 20:47:50 UTC+5:30, Fred Stluka wrote: Krishna, How long is "a long time"? I have a project of ~200K lines of python/django code. The dev server reloads in a second or so. --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/3/16 8:42
Re: unindent does not match any outer indentation level
Deepak, The error: "unindent does not match any outer indentation level" means that you have a line of code that is less indented than the immediately previous line, but is not lined up with any line before that. In your case, it's this line: def __unicode__(self): which should be indented exactly as much as the line: def get_absolute_url(self): --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/5/16 6:21 AM, deepak manupati wrote: am getting unindentation error can any one fix my problem File "/home/deepak/Desktop/ecommerce-2/src/products/models.py", line 31 def get_absolute_url(self): from django.core.urlresolvers import reverse from django.db import models class ProductQuerySet(models.query.QuerySet): def active(self): return self.filter(active=True) class ProductManager(models.Manager): def get_queryset(self): return ProductQuerySet(self.model,using=self._db) def all(self,*args,**kwargs): return self.get_queryset().active() class Product(models.Model): title = models.CharField(max_length=120) description = models.TextField(blank=True, null=True) price = models.DecimalField(decimal_places=2, max_digits=20) active = models.BooleanField(default=True) objects = ProductManager() def get_absolute_url(self): return reverse("product_detail", kwargs={"pk":self.pk}) def __unicode__(self): return self.title -- 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/fd982cf1-e022-4953-8764-34b78c511cbc%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dc47b91d-6e47-e554-5eff-90a4a88238b2%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: How can i add my django project to Bitbucket ?
Deepak, Bitbucket has pretty good documentation, including a Getting Started section. Should tell you all you need to know. See: - https://www.google.com/search?q=bitbucket+getting+started --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/5/16 7:18 AM, Deepak Sharma wrote: I have created a simple django project and i have created a simple app in it . Now i want to use Bitbucket for code development since we are working in a team how could i possibly do that ? -- 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/2a4952bd-bf36-42d9-a479-68e95b623ae2%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4018e03a-c861-fde2-3ed0-60c34d01c55c%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Slow Django dev server reload
Krishna, I'm using: - Mac OSX 10.11.5 (El Capitan) - 2.3GHz Intel Core i7 - 16 GB 1333 MHz DDR3 - 512GB SSD - Python 2.7.3 - Django 1.4.2 - MySQL 5.1.33 And it takes less than a second from when I type: % python manage.py runserver until I see: Validating models... 0 errors found Django version 1.4.2, using settings 'hhl.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. I have about 40 models.py files, of which 25 are empty and exist only to prevent warnings when run automated tests. The other 15 contain about 100 Django models with a total of about 27,000 lines of code. The 100 models all get validated against a locally running MySQL server. So, it should NOT be that slow on your Mac. To narrow down the problem, I suggest you use the -v option: % python -v manage.py runserver and watch to see what seems to be taking so long. Any other suggestions, anyone? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/4/16 2:20 AM, Krishna Bharadwaj wrote: Hi Fred, It takes about 3.5 - 5 seconds on my machine (Mac OSX - 2.6 GHz Intel Core i5, 8 GB 1600 MHz DDR3 and SSDs). I was curious to know if I was doing something wrong. Any pointers regarding this will be very helpful. On Sunday, 3 July 2016 20:47:50 UTC+5:30, Fred Stluka wrote: Krishna, How long is "a long time"? I have a project of ~200K lines of python/django code. The dev server reloads in a second or so. --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/3/16 8:42 AM, Krishna Bharadwaj wrote: Hi everyone, I am working on a project which is substantially big (~40k lines of python/django code including management commands). Dev server seems to be taking a lot of time to reload after making changes. I was wondering if this is due to any bad programming practice at my end? Or is this expected once the project grows big? I wanted to know if anyone in the group is dealing with it in a better way? - Regards Krishna Bharadwaj -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a97cacc1-c8c8-4075-a853-5f5d1bb156d6%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d1e25f49-5672-4dd0-bdf1-cf8ffd012e4b%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@goo
Re: Slow Django dev server reload
Hildeberto, No, the number of migrations does affect how long it takes to run automated tests, but should not affect how long it takes the dev server to start. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/4/16 3:46 AM, Hildeberto Mendonça wrote: Isn't it related to the amount of migration files in your project? On Mon, Jul 4, 2016 at 9:13 AM, Babatunde Akinyanmi <tundeba...@gmail.com> wrote: This is a punch in the dark. It takes about 3 - 5 seconds on my my windows machine when I run the dev server using pycharm's inbuilt terminal and my code is way below 5k lines On Jul 4, 2016 7:20 AM, "Krishna Bharadwaj" <krishna.bm...@gmail.com> wrote: Hi Fred, It takes about 3.5 - 5 seconds on my machine (Mac OSX - 2.6 GHz Intel Core i5, 8 GB 1600 MHz DDR3 and SSDs). I was curious to know if I was doing something wrong. Any pointers regarding this will be very helpful. On Sunday, 3 July 2016 20:47:50 UTC+5:30, Fred Stluka wrote: Krishna, How long is "a long time"? I have a project of ~200K lines of python/django code. The dev server reloads in a second or so. --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/3/16 8:42 AM, Krishna Bharadwaj wrote: Hi everyone, I am working on a project which is substantially big (~40k lines of python/django code including management commands). Dev server seems to be taking a lot of time to reload after making changes. I was wondering if this is due to any bad programming practice at my end? Or is this expected once the project grows big? I wanted to know if anyone in the group is dealing with it in a better way? - Regards Krishna Bharadwaj -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a97cacc1-c8c8-4075-a853-5f5d1bb156d6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are su
Re: Slow Django dev server reload
Krishna, How long is "a long time"? I have a project of ~200K lines of python/django code. The dev server reloads in a second or so. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 7/3/16 8:42 AM, Krishna Bharadwaj wrote: Hi everyone, I am working on a project which is substantially big (~40k lines of python/django code including management commands). Dev server seems to be taking a lot of time to reload after making changes. I was wondering if this is due to any bad programming practice at my end? Or is this expected once the project grows big? I wanted to know if anyone in the group is dealing with it in a better way? - Regards Krishna Bharadwaj -- 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/a97cacc1-c8c8-4075-a853-5f5d1bb156d6%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b613caa1-84d0-c778-3c49-ba8f0a178254%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Recommended courses/materials for Python/Django course...
Thanks for the feedback! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 6/17/16 10:04 AM, 06use...@gmail.com wrote: My 2 cents : I have started learning Python and Django from scratch 15 months ago. I have bought 3 books which were VERY useful : 1) Two scoops of Django (Django 1.8) Daniel & Audrey Roy GreenFeld : very good introduction to the Django world 2) Django by Example (Antonio Melé) : excellent implementation of several real-world django projects (code can be dowloaded) 3) Beginning django CMS Nigel George : very good explanation of how to use Django CMS Cheers. -- 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/cd420c85-590b-4a87-aabb-954ec7189d10%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f3f1925d-8e96-e057-7342-0be244afc326%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Recommended courses/materials for Python/Django course...
Ludovic, Thanks for the tip! I'll check them out. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 6/16/16 3:00 AM, ludovic coues wrote: The "Python Crash Course" aim to teach python from nothing in the first half and to put that knowledge in application in the second half through 3 projects. These are a 2D game, some data visualization technique from diverse source and a django application. Some people have some difficulty with the official django tutorial. https://tutorial.djangogirls.org/en/ offer a really nice alternative, more accessible to beginner and more complete too, with a section on handling form in django for exemple. I have also head of tango with django but I can't comment on this one. -- 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/e37767fb-deff-d347-b821-975b04c3541a%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Recommended courses/materials for Python/Django course...
Python/Django users, Any Python and/or Django courses/materials to recommend? I may be teaching a Python/Django class soon. My client may be willing to jumpstart by buying existing course materials (lecture slides, notes, homeworks, labs, reference links, any other materials). We'll certainly be happy to make use of any free materials. Do you have any Python and/or Django courses/materials to recommend? I've taken a quick look and found: - Main web sites: - http://python.org - https://djangoproject.com (excellent docs and tutorial!) - Free courses: - https://developers.google.com/edu/python - Free/paid courses: - http://learnpythonthehardway.org/book - Books - 2 Scoops of Django - Paid courses: - Coursera - Codecademy - Khan Academy - Udacity - edX - Alison - Lynda - NewCircle.com Any advice? Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/891ed395-21e8-80ac-8bf5-4598903cc748%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Reportlab no module named pdfgen
David, It works fine for me. Must be something about your environment. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 5/23/16 4:33 PM, david rodgers wrote: Hello All, I am trying to use reportlab to generate pdfs from html. When I pip install reportlab it say its installed correctly. However, when I try 'from reportlab.pdfgen import canvas' I get an error saying no module named pdfgen. Any ideas to help solve this would be much appreciated. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56450467-71c1-496c-9e48-a82d12660743%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/34045cf8-19eb-c19e-e58a-390bca1e4f09%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Moving django app(nginx server) from iMac to Linux environment
Dhruv, Should be no changes required. I develop on Mac and just copy my Django files (*.py, *.html, etc.) to my Linux server when I deploy. You said you already have the same Django/gunicorn/nginx installed on both machines, right? And you did a pip freeze on one and a pip install -r on the other? Nothing left to do. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 5/20/16 4:14 PM, Dhruv Jain wrote: We have a basic Django(1.4.5) application setup on a linux machine which runs via gunicorn. We have another application which is the main application which we plan to deploy on the linux machine mentioned above, currently runs on an iMac Django/gunicorn/nginx server with Mysql. We have Django/gunicorn/nginx installed on linux machine and have also installed all dependencies which we got using pip freeze on the iMac. Now we basically need to transfer the application currently hosted on the iMac to this linux machine and make it run in the linux environment. Can anybody help me figure out what all changes I need to make in the django code to make it run on linux environment(mysql settings,etc?) Thank you! -- 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/ab49ac8d-d173-4285-a5ed-5fc66b6fadee%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1e1be827-3ebc-a57f-e9b7-33a9c7a72bd2%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Is it good idea to transition from MS Access to a webapp? And if so, is Django a good tool to do it?
Patrik, Yes, Django can be used for that. The "ORM" features and the "templates" and "views" of Django make it very easy to do a "CRUD" app for a users to create/ retrieve/update/delete data in any RDBMS. There are some built-in security features like logins, protection against "CSRF" attacks, etc. Django "formsets" make it easy to show multiple rows with a details panel for the row currently selected. With a web app, you won't have to re-distribute the front end. Just push a new version to the server. Django's templates and views both support "inheritance", which should solve your problem of managing multiple related forms. And, there are many Open Source custom widgets for Django and for _javascript_ that will give you all the sub-grouping and tree-views that you need. Django scales very well to large amounts of data, large numbers of screens, and large numbers of users. There are many performance tuning options, including "caching" of templates, and of fully-constructed pages, and of DB data. Also, lots of other "middleware" for security, performance, logging, and other "aspects" of the software. Yes, you can run a Django server locally, behind a "firewall", or can expose it to the world, securing various parts as needed. To make it as secure as possible, I'd put in on a Linux server that is protected by tools like Logwatch, Fail2ban, and Tripwire. See: - http://bristle.com/Tips/Unix.htm#unix_security And be sure to redirect all page requests from HTTP to HTTPS. I do all of this and more, including processing financial transactions and supporting "multitenancy", restricting access by thousands of different users, each to his own data, plus "attribute based access control" for cases where data is shared, at the Web site I'm currently working on: - http://HelpHOPELive.org Sorry for all the terms and acronyms, but if you're considering writing such an app, you'll need to be aware of them and they're all pretty easy to Google. Feel free to reply with more questions. Also, you'll quickly get a feel for Django's power if you go through the on-line tutorial at: - https://docs.djangoproject.com/en/dev/intro/ Enjoy! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 4/29/16 12:57 PM, Patrik Mjartan wrote: Hi, I work for a very small company that I developed an application for, all using MS Access (it has back-end MS Access db - although this is planned to change to some more robust RDBMS, and a front-end app built in MS Access). Currently this app is used to calculate the exact wages of some employees (sorry, English is not my native language so I don't know how that type of wage is called here, but basically we look at how many products they produced and calculate it based on that. It's not a hourly wage). However, this summer I would like to expand it to do some order management too (ie. each order has specific products that need to be produced... each of those can be produced by our employees and so it's directly linked to the wages). However, it is very hard to manage everything using MS Access. Basically each time I make any change to FE or BE, I have to re-distribute the FE to all of the front-users. This is not a HUGE problem, the big problem, however, is within the MS Access itself, that is, it's very hard to manage all the forms as they are listed as simple names (ie. you cannot sub-group them efficiently to make a tree-view). Overall I cannot see myself working with MS Access in 5 years time as I can already see the scalability problems after a few months of working with it. What I thought of, however, is making a website that is only for local use, but is it possible to have the same functionality as a regular front-end app? Is this good idea to begin with? I had a brief look at Django (I'm VERY new to web-dev, but I'm a fast learner I like to think) and I really like it so far. But is it possible to have the same level of functionality MS Access offers? That is, for example a
Re: Any way to tolerate Unicode w/o changing '' to u''?...
Tim, Excellent response, thanks! The link to the doc is just what I needed. One more question. I'm still getting UnicodeEncodeError on some calls to str() because I should now be calling unicode() instead. Any easy way to map all of my str() calls to unicode() call? Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 4/14/16 10:05 PM, Tim Graham wrote: You want `from __future__ import unicode_literals`: https://docs.djangoproject.com/en/dev/ref/unicode/#general-string-handling On Thursday, April 14, 2016 at 6:27:07 PM UTC-4, Fred Stluka wrote: Django users, In my Django app, I want to allow users to enter Unicode strings. But if they do, I get UnicodeEncodeError when I call format() to embed their string into other strings. Is there an easy way to tolerate the Unicode? Details: After prompting the user for name, I may have a line of code like: log('Name entered was: {0}'.format(name)) With Python 2.7.3 and Django 1.4.3, this raises exception UnicodeEncodeError if the user entered a string containing Unicode chars, because it tries to embed Unicode chars into my ASCII string template. So, I have to I change it to: log(u'Name entered was: {0}'.format(name)) I have many thousands of such lines in my 200,000+ lines of Python and Django code. Is there a master switch somewhere that would cause a Python 2.x string literal to default to Unicode instead of ASCII, as it does in Python 3? Or do I have to explicitly change '' to u'' in all such places? I looked into adding a line like this to the top of the file, but no luck because it seems to only affect the encoding of Unicode string literals (u''), not regular string literals (''): # -*- coding: utf-8 -*- Any suggestions? Much appreciated. Thanks! --Fred Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/3da21b79-4bfd-4f05-bbc4-579505365376%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/57184BE1.1030505%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: No Downtime Code Releases
Ben, I minimize downtime as much as possible by doing things in advance like copying all of the new files to a staging area on the PROD system, automatically inserting PROD passwords, running collectstatic, dumping the DB in case of problems, etc. Then, I put up the maintenance page, quickly rsync the new files into place, run migrations, and hide the maintenance page. We used to shoot for releases with no downtime by copying the *.py files into place, and letting Django notice and re-load the *.pyc files automatically, but we ran onto some strange issues sometimes. Seems like Django continued to use some of the cached *.pyc files for a while. It's worked out better to always delete all *.pyc files before rsyncing the *.py files into place, and to always restart the Apache server just before hiding the maintenance page, so we're sure everything gets reloaded cleanly. This has also been a good idea as we've added more caching: - Template files - Fully assembled pages - DB data - etc. Hope this helps, --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 4/19/16 12:12 PM, Avraham Serour wrote: I don't think you would gain anything by separating your models to a different repository, what are you trying to gain here? if you put a maintenance page when doing migrations it won't matter if the models are from a different package or not. you could still run migrations on a live system, you just should take into account that there could still be parts of the system using something is not there yet/anymore so you should break migrations into 2 whenever you are adding or removing something. when adding a model or field you should first run the migrations and only after that deploy the new code using the new model/field when removing something you should first stop using it and then migrate. you could plan your deployment/releases and know in advance if you are either adding or removing something and never add and remove in the same release meaning commit and deploy the model and only after that commit the code using the new model or you can checkout the code on the side and runs migrations using this separate env, this way you could add a new model and use it in the same commit. for removing you can just do it backwards. Avraham On Tue, Apr 19, 2016 at 3:38 AM, <bliyan...@rentlytics.com> wrote: Hey, I have two issues I'm looking at solving at work, and I'm looking for a couple suggestions as to how other people have solved this. The two things are: * scale out their django installation to allow for smaller releases (I'm thinking microservices, but it could also be internal django apps or who knows what else) * minimizing the impact of migrations during releases (aka we want to be able to release in the middle of the afternoon Currently we put up a maintenance page whenever we are doing database operations (aka migrations). This seems like a recommended best practice. One way I was thinking about addressing this issue was to break all of our models out into a separate repo. That way we'd only need to deploy migrations when the models themselves have deployed. For code that needs the models, we could pip install the repo as an app and away we go. Likewise it seems like I could break up different parts of our app via a similar strategy. Does this seem viable? How have other people solved this kind of problem? Thanks, -Ben -- 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 djang
Re: PyCharm not stopping at breakpoint
Schaf, Yes, I've seen that. In my case, it's not a bug. It's an intentional design decision that is necessary for a symbolic debugger to work the way you want it to. Happens in all symbolic debuggers, including PyCharm. Here's a explanation I sent my team recently: Team, I just figured out something that has been a mystery to me for a while. In some cases, I've found that the PyCharm debugger does 2 weird things: A. Runs the code differently when I step through it than when I run it flat out B. Skips breakpoints that I've set (even if I'm very careful to have only one Run and/or Debug tab running at a time) I figured out why. It's a problem common to all symbolic debuggers but it doesn't come up very often, so I hadn't had to think about it for a while. It's bitten me a few times lately because I've been doing detailed debugging of the validation code that Django runs for forms. Basically, the problem is that there are 2 things symbolic debuggers typically do: 1. Execute code internally to compute values to show you in the Variables and Watches frames of the debugger 2. Skip any breakpoints that occur while executing such code internally The standard Django Form class has this code: def _get_errors(self): "Returns an ErrorDict for the data provided for the form" if self._errors is None: self.full_clean() return self._errors errors = property(_get_errors) So, errors is a property that calls _get_errors() whenever PyCharm tries to get its value to show it to me, which happens each time I hit a breakpoint or single-step past a line of code. But probably only if I have the Variables pane open with the tree expanded to show the value of errors. The first time it's called, _get_errors() notices that _errors is None, and calls full_clean(), which sets _errors to an ErrorDict. After that, it never calls full_clean() again. Our clean() methods and other validation code are called by full_clean(). I was trying to debug our clean() method, and had set a breakpoint there. But PyCharm doesn't hit breakpoints there when it's running the code internally to compute a value to show it me. See #2 above. The first evaluation of errors is the only one that calls full_clean() and that was happening much earlier when I was poking around in the debugger, peeking at things to see if they had changed yet, than when I was running the code flat out. See #1 above. The upshot was that my breakpoint was never being hit. I had to add logging statements to convince myself it was really running, and to debug what was going wrong. In a nutshell: "Holy Heisenberg Uncertainty Principal, Batman!" --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 4/18/16 9:04 AM, schaf...@gmail.com wrote: HI All, I have some unit tests (using django-nose). As one was failing I wanted to debug the test (to see what's going on), but pyCharm does not stop at the breakpoint. I'm working with Python 2.7.6, Django 1.5.1, django-node 1.2, nose 1.3.3. PyCharm 4.5.3 Do you have any ideas? Thanks Regards -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dca07250-eed1-4f19-b24a-c533c650acab%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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/57157C96.30701%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Any way to tolerate Unicode w/o changing '' to u''?...
Stephen, Perfect! Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 4/14/16 6:32 PM, Stephen J. Butler wrote: from __future__ import unicode_literals On Thu, Apr 14, 2016 at 5:26 PM, Fred Stluka <f...@bristle.com> wrote: Django users, In my Django app, I want to allow users to enter Unicode strings. But if they do, I get UnicodeEncodeError when I call format() to embed their string into other strings. Is there an easy way to tolerate the Unicode? Details: After prompting the user for name, I may have a line of code like: log('Name entered was: {0}'.format(name)) With Python 2.7.3 and Django 1.4.3, this raises exception UnicodeEncodeError if the user entered a string containing Unicode chars, because it tries to embed Unicode chars into my ASCII string template. So, I have to I change it to: log(u'Name entered was: {0}'.format(name)) I have many thousands of such lines in my 200,000+ lines of Python and Django code. Is there a master switch somewhere that would cause a Python 2.x string literal to default to Unicode instead of ASCII, as it does in Python 3? Or do I have to explicitly change '' to u'' in all such places? I looked into adding a line like this to the top of the file, but no luck because it seems to only affect the encoding of Unicode string literals (u''), not regular string literals (''): # -*- coding: utf-8 -*- Any suggestions? Much appreciated. Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/57101921.80505%40bristle.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD4ANxXL-MwsXsqeC%3DK%3DdifeD2c9QaaWFJsw30MeHGwSPfMxQw%40mail.gmail.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/57101CAC.9000804%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Any way to tolerate Unicode w/o changing '' to u''?...
Django users, In my Django app, I want to allow users to enter Unicode strings. But if they do, I get UnicodeEncodeError when I call format() to embed their string into other strings. Is there an easy way to tolerate the Unicode? Details: After prompting the user for name, I may have a line of code like: log('Name entered was: {0}'.format(name)) With Python 2.7.3 and Django 1.4.3, this raises exception UnicodeEncodeError if the user entered a string containing Unicode chars, because it tries to embed Unicode chars into my ASCII string template. So, I have to I change it to: log(u'Name entered was: {0}'.format(name)) I have many thousands of such lines in my 200,000+ lines of Python and Django code. Is there a master switch somewhere that would cause a Python 2.x string literal to default to Unicode instead of ASCII, as it does in Python 3? Or do I have to explicitly change '' to u'' in all such places? I looked into adding a line like this to the top of the file, but no luck because it seems to only affect the encoding of Unicode string literals (u''), not regular string literals (''): # -*- coding: utf-8 -*- Any suggestions? Much appreciated. Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/57101921.80505%40bristle.com. For more options, visit https://groups.google.com/d/optout.
What Python/Django code checkers do you recommend?...
Python/Django programmers, What code review tools do you use? Do you run them automatically when checking in new code? Do you recommend them? Details: I'm working on a large Python/Django Web app (1,000 files, 200,000 lines of code, 3.5 years) and spend a good chunk of my time reviewing code written by other team members. I'd like to automate many of the checks that I currently do manually: - Coding standards violations -- Lack of logging -- Missing docstrings -- Hardcoded literals instead of named constants or utility functions -- Standard columns in all DB tables (create_user, create_date, update_user, update_date, status, etc.) -- etc. - Architecture violations -- Doing things in the UI layer vs the business logic layer -- Respect the MVC boundaries -- etc. - Logic errors - Defensive coding -- Unchecked assumptions -- Missing else clauses on if statements -- Missing exception handlers -- Exception handlers that suppress errors -- etc. - Security and data validation -- Vulnerability to injection attacks (SQL, JS, etc.) -- Data validation and security enforcement in browser vs. server -- etc. - Massive inefficiencies -- Cursor loop vs more specific DB SELECT -- Caching opportunities -- etc. - Reuse opportunities - Lack of test cases - DB migration issues -- Non-idempotent migrations -- Edited migrations -- Migrations that call non-migration code that might change - User experience -- Show clear error messages in all cases of user error - etc. What tools do you recommend to automate such checks? I'm currently most interested in Python/Django, as well as _javascript_/CSS/HTML. Some automation tools I've found include: - Gerrit https://www.gerritcodereview.com/ - BitBucket Server (was Stash) https://www.atlassian.com/software/bitbucket/server/ Such automation tools support a workflow of human interactions for manual code reviews (comments, replies, todos, etc.). They also call code review tools like the following to scan the code automatically: - Sonar (multiple languages via plugins) http://www.sonarqube.org/ - JSHint (_javascript_) http://jshint.com/ - JSLint (_javascript_) http://www.jslint.com/ - TSLint (TypeScript) https://palantir.github.io/tslint/ - PMD (mostly Java/JS, some Python) https://pmd.github.io/ - Checkstyle (Java, not Python) http://checkstyle.sourceforge.net/ - FindBugs (Java, not Python) http://findbugs.sourceforge.net/ - CodeNarc (Groovy and Java, not Python) http://codenarc.sourceforge.net/ I've also done a quick Google for Python/Django-specific tools: - http://google.com/search?q=python+code+checkers - http://google.com/search?q=django+code+checkers and found: - code-checker https://pypi.python.org/pypi/code-checker/ - PyChecker https://pypi.python.org/pypi/PyChecker - Pyflakes https://pypi.python.org/pypi/pyflakes - PyLint https://pypi.python.org/pypi/pylint - pep8 https://pypi.python.org/pypi/pep8 - Flake8 (wraps Pyflakes, pep8 and others) https://pypi.python.org/pypi/flake8 - Django Lint https://chris-lamb.co.uk/projects/django-lint - QuantifiedCode https://www.quantifiedcode.com/ My IDE is PyCharm, which has the ability to check some things, but I haven't yet investigated or configured it much. What do you recommend? Any good or bad experiences to share? Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/5707D5A0.8020408%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Forms vs Angularjs
Fabio, Good point! Browser-side security is VERY easy to bypass. For example, just use Firebug or the built-in dev tools of Firefox, Chrome, or Safari (or probably even IE by now), to edit the HTML of the current page and then click the OK/Send/Submit button. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/22/16 10:35 AM, Fabio C. Barrionuevo da Luz wrote: self.fields[name].widget.attrs['disabled'] = 'disabled' self.fields[name].widget.attrs['readonly']=True is not make real readonly to field, because if user can edit the html on client side, and remove disabled="disabled" and readonly input atributtes to problem of readonly fields, i currently use this: https://github.com/luzfcb/django-simple-history/blob/wip-generic-views2/simple_history/forms.py I prevent it here https://github.com/luzfcb/django-simple-history/blob/wip-generic-views2/simple_history/forms.py#L24 -- 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/57003696.2070502%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Migrating older 1.4 project to 1.9
Roger, Yeah, I too have a large project that I'll hopefully be migrating from 1.4 to 1.9 soon. It's about 3.5 years worth of work, over 200,000 lines of code in about 1000 Python source file and Django template files. So any tips you come up with will be invaluable. Please post anything you learn to this thread. Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/30/16 9:23 AM, bobhaugen wrote: We feel your pain. If you do it, and write down how it goes, we would be grateful. https://github.com/valnet/valuenetwork On Tuesday, March 29, 2016 at 4:19:59 PM UTC-5, Roger Dunn wrote: I've inherited a moderately large project written 2 years ago using Django 1.4, and wondering if it is worth creating a fresh 1.9 project and porting in the old code, or doing an in-place upgrade to 1.9? I have it running on 1.4 'as is' but if I run*python manage.py migrate* it comes unglued as a lot of stuff has changed since 1.4. -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/2a3de1fc-5032-4807-b008-66f2e381ac7f%40googlegroups.com <https://groups.google.com/d/msgid/django-users/2a3de1fc-5032-4807-b008-66f2e381ac7f%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56FBDDBE.9020409%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: EMAIL_BACKEND doesn't works with Amazon SES!?
Good explanation, Michal! Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/29/16 3:34 AM, Michal Petrucha wrote: On Mon, Mar 28, 2016 at 05:56:12PM -0700, Neto wrote: I'm trying to send emails with Amazon SES, but when I use default EMAIL_BACKEND raise error: Config: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # this is default EMAIL_HOST = 'email-smtp...amazonaws.com' EMAIL_PORT = 465 EMAIL_HOST_USER = '...' EMAIL_HOST_PASSWORD = '...' EMAIL_USE_TLS = True Error: raise SMTPServerDisconnected("Connection unexpectedly closed") smtplib.SMTPServerDisconnected: Connection unexpectedly closed The problem is that there are two different ways of establishing a TLS connection to an SMTP server. One is the so-called SMTPS, which is commonly used on port 465, where the client opens a TLS tunnel right away, and all SMTP communication happens through this tunnel. The other option is STARTTLS, which is normally supported on ports 25 and 587. With this protocol, the client first opens a regular plain-text SMTP session with the server, and they exchange the STARTTLS SMTP command, after which they perform the TLS handshake, and only then is everything transferred over a secure TLS tunnel. Django supports both protocols, however, these days SMTPS is considered obsolete by some people, and a lot of folks will tell you that STARTTLS is the way to go. You set EMAIL_USE_TLS to True in your config, this tells Django to use the STARTTLS protocol, but you also set it to connect to a port on the server where it expects the SMTPS protocol instead. If you want to use SMTPS (which is what you need to do in order to connect to port 465 successfully), you need to set EMAIL_USE_TLS to False, and instead set EMAIL_USE_SSL to True. The other option is, as Raffaele suggested in another reply, to keep using EMAIL_USE_TLS, and switch the port to 587. Good luck, Michal -- 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/56FB05CF.4060603%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Forms in Django
Stanislav, If you have any more questions, feel free to post them here. BTW, one thing I forgot to mention about the flexibility of the ORM is that you can have it access multiple databases from the same app, by setting DATABASE_ROUTERS to refer to a class that tells it things like which DB to use for reading and for writing each model. Also, I've had very good luck using the ORM to migrate from one DB server to another. For example, on my current project we're re-writing an old ColdFusion app that used an old Microsoft SQL Server DB as a new Django app that uses MySQL. With a one-line command, we were able to create Django models from all of the MS SQL Server tables: % manage.py inspectdb Then with another one-line command, we were able to create MySQL tables from the models: % manage.py syncdb Never had to look at the different DDL of MS SQL Server vs MySQL, or the native tools of each to export and import DDL. Since then, we've kept our DEV, TEST, and PROD instances of the MySQL DB up to date via Django "migrations". And when we accumulated enough automated regression tests that it took too long to run the test suite, we changed the DATABASES setting to use SQLite instead of MySQL when running tests, by simply adding: RUNNING_UNIT_TESTS ='test' in sys.argv if RUNNING_UNIT_TESTS: DATABASES['default'] = { 'ENGINE':'django.db.backends.sqlite3', Again, we never had to look at the different DDL of MySQL vs SQLite, or the native tools of each to export and import DDL. Django did it all for us. Suddenly the entire regression test suite runs in 30 seconds instead of 75 minutes. Really nice! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/19/16 8:08 AM, Stanislav Vasko wrote: Outstanding answer, many thanks! This is exactly what i thought there must be :) Dne sobota 19. března 2016 2:43:31 UTC+1 Fred Stluka napsal(a): Stanislav (aka Stanley?), As my company motto says: "Glad to be of service!". I'm very impressed with Django. It's a mature product that does a good job of: "Making simple things easy, and complex things possible" It has good simple default behaviors, but also hooks that you can use to drill down to more detail when necessary. For example, in my Django templates, I sometimes use: {{form}}but sometimes have to resort to: {{ form.first_name }}{{ form.last_name }}{{ form.phone }}and occasionally even: {{ form.first_name.value }}{{ form.first_name.label }}{{ form.first_name.errors }}{{ form.last_name.value }}{{ form.last_name.label }}{{ form.last_name.errors }}{{ form.phone.value }}{{ form.phone.label }}{{ form.phone.errors }}Similarly, in my Django ModelForms, I sometimes use: class PersonModelForm(forms.ModelForm):class Meta: model=Personbut sometimes have to resort to: class PersonModelForm(forms.ModelForm): class Meta: model=Person fields = ['first_name', 'last_name', 'phone',] and occasionally even: class PersonModelForm(forms.ModelForm): class Meta: model=Person exclude = ['middle_name',]or take over a field explicitly as: phone = forms.CharField(required = True,max_length = 50,label = u'',widget = forms.TextInput(attrs={'class' : 'form-control','id' : 'my_custom_HTML_id','placeholder' : 'Phone', }),)or even give up on doing it all declaratively and do something more dynamic in the __init__() of the Form, as: def set_placeholders_from_labels(form):for field in form.fields.itervalues():field.widget.attrs['placeholder'] = field.labelclass PersonForm(forms.Form): def __init__(self, *args, **kwargs):super(Donate2Form, self).__init__(*args, **kwargs)set_placeholders_from_labels(self) self.fields['amount'].widget.attrs['placeholder'] = ""if some_special_reason(): self.fields['amount'].initial = "100"keep_enabled = ['first_name','last_name']if some_mode_where_we_need_some_fields_disabled(): for field in self.fields:if field not in keep_enabled:self.fields[field].widget.attrs['disabled'] = TrueAnd with validation of user-entered data, I can declare many validation rules on the declarations of the fields, and can do validation programmatically in the clean_field_name() methods and the overall clean() method. Or can even use the clean() method of the Model instead of the clean() method of the form. T
Re: Forms in Django
Stanislav, Look at how you defined the fields of your Form class. You probably defined the phone field as something like: phone = forms.CharField( required = True, max_length = 50, label = u'Phone', ) Change it to: phone = forms.CharField( required = True, max_length = 50, label = u'', widget = forms.TextInput( attrs={ 'class' : 'form-control', 'id' : 'inputSuccess5', 'placeholder' : 'Phone', } ), ) --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/18/16 10:53 AM, Stanislav Vasko wrote: Hello, as a noob in Django, i will ask noob question about Forms, because i cant find. I have working app, based on Bootstrap with theme and custom css. Rather than Django admin i want to create/edit data from my fields. I tried to use Django forms, but no luck. It looks... bad :) Its simple, but i have no controll over the result: {% for field in form %} {{ field.errors }} {{ field.label_tag }} {{ field }} {% if field.help_text %} {{ field.help_text|safe }} {% endif %} {% endfor %} Insted of simple form i found form.as_p(), form.as_ul() aso, but it doesnt solve my problem too, just gives me little changed result. I need to be able insert and read data from my own tem plate, like: Please, can you help me how to get clean data and after update put them back? Thanks for any tips or direct link. -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/541fd731-d2b9-4fbd-807a-420ba5d21d3e%40googlegroups.com <https://groups.google.com/d/msgid/django-users/541fd731-d2b9-4fbd-807a-420ba5d21d3e%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56EC2CA2.2090001%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Forms in Django
Stanislav, Try these: {{ form.title.value }} {{ form.title.label }} {{ form.title.errors }} etc. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/18/16 2:55 PM, Stanislav Vasko wrote: This is exactly what im trying. But if i enter *{{ form.title }}* i get not the data to use in form, but whole: ** But as i study doc, there is no simple way like Django is providing in other part. So, maybe Fred's way is a good one (but quite strange) and still dont know how i will make Fieldsets and other stuff (i need to work with data and some the result). Maybe there is some better Django Form plugin, but i prefer not to use anything outside Django, because noone knows how it will work with new Django versions and how buggy it can be. As beginner i'm glad for solving own bugs not fighting others too :) You can also do a custom template. So instead of letting Django render the form, you code the html yourself. This is, instead of: {{ form.as_p }} do something like: {% csrf_token %} ... -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/bb89aebe-5c3a-41dd-8f58-00acb8d78289%40googlegroups.com <https://groups.google.com/d/msgid/django-users/bb89aebe-5c3a-41dd-8f58-00acb8d78289%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56EC5BDA.3050208%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Forms in Django
Stanislav (aka Stanley?), As my company motto says: "Glad to be of service!". I'm very impressed with Django. It's a mature product that does a good job of: "Making simple things easy, and complex things possible" It has good simple default behaviors, but also hooks that you can use to drill down to more detail when necessary. For example, in my Django templates, I sometimes use: {{form}} but sometimes have to resort to: {{ form.first_name }} {{ form.last_name }} {{ form.phone }} and occasionally even: {{ form.first_name.value }} {{ form.first_name.label }} {{ form.first_name.errors }} {{ form.last_name.value }} {{ form.last_name.label }} {{ form.last_name.errors }} {{ form.phone.value }} {{ form.phone.label }} {{ form.phone.errors }} Similarly, in my Django ModelForms, I sometimes use: class PersonModelForm(forms.ModelForm): class Meta: model=Person but sometimes have to resort to: class PersonModelForm(forms.ModelForm): class Meta: model=Person fields = ['first_name', 'last_name', 'phone',] and occasionally even: class PersonModelForm(forms.ModelForm): class Meta: model=Person exclude = ['middle_name',] or take over a field explicitly as: phone = forms.CharField( required = True, max_length = 50, label = u'', widget = forms.TextInput( attrs={ 'class' : 'form-control', 'id' : 'my_custom_HTML_id', 'placeholder' : 'Phone', } ), ) or even give up on doing it all declaratively and do something more dynamic in the __init__() of the Form, as: def set_placeholders_from_labels(form): for field in form.fields.itervalues(): field.widget.attrs['placeholder'] = field.label class PersonForm(forms.Form): def __init__(self, *args, **kwargs): super(Donate2Form, self).__init__(*args, **kwargs) set_placeholders_from_labels(self) self.fields['amount'].widget.attrs['placeholder'] = "" if some_special_reason(): self.fields['amount'].initial = "100" keep_enabled = ['first_name','last_name'] if some_mode_where_we_need_some_fields_disabled(): for field in self.fields: if field not in keep_enabled: self.fields[field].widget.attrs['disabled'] = True And with validation of user-entered data, I can declare many validation rules on the declarations of the fields, and can do validation programmatically in the clean_field_name() methods and the overall clean() method. Or can even use the clean() method of the Model instead of the clean() method of the form. The ORM has similar hooks. I can use it simply, to get() and save() models from and to the DB. Or can do fancier queries. Or can drop down into raw SQL if necessary. And I can use middleware to inject all sorts of useful functionality into the HTTP request/response cycle, to change or add to the default behavior, add caching of DB data, Django templates, and fully assembled Django pages, etc. And I can hook into Django "signals" for more sophisticated needs. Very powerful! And I've found the community to be extraordinarily friendly and helpful also. Enjoy! --Fred -------- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/18/16 3:54 PM, Stanislav Vasko wrote: This is exactly what i was looking for, many thanks! Now i can render form i need and like. Now i will test and i hope it will be same easy to write data back to db. Many thanks, Stanley Dne pátek 18. března 2016 20:50:37 UTC+1 Fred Stluka napsal(a): Stanislav, Try these: {{ form.title.value }} {{ form.title.label }} {{ form.title.errors }} etc. --Fred -------- Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/18/16 2:55 PM, Stanislav Vasko wrote: This is exactly what im trying. But if i enter *{{ form.title }}* i get not the data to use in form, but whole: ** But as i study doc, there is no simple way like Django is providing in other part. So, maybe Fred's way is a good one (but quite strange) and still dont know how i will make Fieldsets and other stuff (i need to work with data and some the result). Maybe there is some better Django Form plugin, but i prefer not
Re: variable to a template
Luca, You can't nest a variable evaluation (via {{}}) inside a tag execution {%%}. But you can put them side by side to achieve the effect you want: '{% static "mysite/scorr" %}'/{{a}}' --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 3/2/16 8:04 AM, Andreas Schosser wrote: Hi Luca, Try {% static "mysite/scorr/"|add:a %} Andreas -- 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/56D722C1.1080103%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: how to deploy python/django application in debian/apache?
On 2/10/16 4:37 AM, James Schneider wrote: ... make sure that the Apache system user has read access to that directory and all subdirectories, and no write access ... James, Won't that prevent Django from creating *.pyc files from the deployed *.py files? Or do you suggest deploying *.pyc files? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/56BB5428.8080405%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Scaling Django
http://www.revsys.com/12days/finding-sources-of-slowness/ Web Server speed Apache httpd server Optimal number of processes, threads, connections, open files nginx instead of Apache Optimal number of processes, threads, connections, open files, WSGI buffers, http://www.revsys.com/12days/nginx-tuning/ App Server (Django/WSGI) speed Optimal number of processes, threads specified for WSGI in Apache httpd.conf file: WSGIDaemonProcess wsgi_apps processes=2 threads=15 http://www.revsys.com/12days/nginx-tuning/ Proxy buffers uWSGI instead of mod_wsgi, to connect Apache to Django https://www.digitalocean.com/community/tutorials/how-to-scale-django-beyond-the-basics Python Profilers http://pymotw.com/2/profile/ http://www.revsys.com/12days/finding-sources-of-slowness/ Python profile modules http://www.newrelic.com/ _javascript_/CSS speed: Not likely to be a big gain, since our JS is fast enough http://www.revsys.com/12days/front-end-performance/ Faster jQuery selectors Faster JS ReactJS (Virtual DOM) http://css-tricks.com/efficiently-rendering-css/ http://learn.jquery.com/performance/optimize-selectors/ Tools: https://github.com/django-debug-toolbar/django-debug-toolbar https://developers.google.com/web-toolkit/speedtracer/get-started http://developer.yahoo.com/yslow/ https://developer.chrome.com/devtools https://developers.google.com/speed/docs/insights/using_chrome https://developers.google.com/speed/pagespeed/insights_extensions http://www.fiddler2.com/fiddler2/ Caching on the phone We may need to consider some caching of data on the phones Have to be prepared for sluggish performance because some phones will be in areas with poor cell phone reception. Especially for repetitive actions like Event Checkout. Re-write specific pages to be faster Cache HTTP sessions, not in the DB: http://www.revsys.com/12days/caching-django-sessions/ Scaling (vertical and horizontal): Prime candidate #5. We really should not need to do this, but it's a cheap and easy way to get a quick fix, if none of the other prime candidates work well enough. Vertically -- larger servers Horizontally -- more servers More links: https://docs.djangoproject.com/en/1.8/faq/general/#does-django-scale http://thebuild.com/presentations/unbreaking-django.pdf Email to Fred w/subject "How to improve web page performance from RevSys" http://us5.campaign-archive1.com/?u=a8d4be66d1927077a9255182d=f0fc046554=c90970e145 http://www.revsys.com/12days/finding-sources-of-slowness/ https://highperformancedjango.com/ http://talks.caktusgroup.com/djangocon/2013/scaling/ Enjoy! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 2/3/16 10:30 AM, Joshua Pokotilow wrote: At the startup where I work, we've written a lot of our server code in Django. So far, we've adopted a "build it fast" mentality, so we invested very little time in optimizing our code. A small amount of load testing has revealed our codebase / infrastructure as it stands today needs to run faster and support more users. We recently hired some new engineers who are extremely skeptical that we should optimize our exis
Re: Does anyone have good results connecting Django to Mysql on localhost and windows 7?, me not.
Carlos, Any advantage of pymysql over MySQLdb (MySQL-python)? - http://sourceforge.net/projects/mysql-python/ --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/25/16 9:30 PM, Carlos Andre wrote: install setuptools. install pymysql and the your python version! 2016-01-25 14:17 GMT-02:00 Gonzalo V <gvm2...@gmail.com <mailto:gvm2...@gmail.com>>: Wich module did you use? please help thanks!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/3abf656f-0d24-4387-869f-310534b84f70%40googlegroups.com <https://groups.google.com/d/msgid/django-users/3abf656f-0d24-4387-869f-310534b84f70%40googlegroups.com?utm_medium=email_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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/CAA8yBMxsUwAYGeY1qCn6%2B-D9-%3D-vdunRvf6g%3Dd6frZXbhHV71w%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAA8yBMxsUwAYGeY1qCn6%2B-D9-%3D-vdunRvf6g%3Dd6frZXbhHV71w%40mail.gmail.com?utm_medium=email_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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56A7E8BE.3050907%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Access denied for MySQL user in Django
Galil, Try this also: mysql> use mysql; mysql> delete from user where host='%' and 'user=''; mysql> flush privileges; --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/18/16 2:38 AM, Sergiy Khohlov wrote: Using password no. Have you set notempty password with creating table permission? 15 січ. 2016 18:20 "Galil" <il...@ajenta.net <mailto:il...@ajenta.net>> пише: Hi Fred, The user cdraccess is not the root user and it does not have the rights to access table 'user'. I deleted the guest user as root but nothing changes. The problem was not fixed. On Thursday, 14 January 2016 17:50:21 UTC, Fred Stluka wrote: Galil, I had a problem like this a couple years ago, and the solution was to delete the anonymous MySQL guest user as: mysql> use mysql; mysql> delete from user where host='localhost' and 'user=''; mysql> flush privileges; I'm not sure why Django 1.4 was trying to connect as the guest user when it had a username and password that it was supposed to be using, but for some reason it was. Deleting the guest user from MySQL fixed it for me, and is a good idea for security reasons anyhow. --Fred ---- Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/14/16 7:11 AM, Galil wrote: I have created a Django app and which uses MySQL. The settings.py file in the database sections is: |DATABASES ={'cdraccess':{'ENGINE':'django.db.backends.mysql','NAME':os.environ.get('CDR_DB_NAME','portal2'),'USER':os.environ.get('CDR_DB_USER','cdraccess'),'HOST':os.environ.get('CDR_DB_HOST','127.0.0.1'),'CONN_MAX_AGE':0,'PASSWORD':os.environ.get('CDR_DB_PASSWORD',''),},'default':{'ENGINE':'django.db.backends.sqlite3','NAME':'db.sqlite3',}}| I run the app like: |CDR_DB_PASSWORD='password'CDR_DB_HOST='host_name'./manage.py runserver| but I get the following error: Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)") I tried to access the database from terminal, like: |$ mysql --host=[host_name]--user=cdraccess -p portal2| and worked fine. What is going wrong in here? And what does this "(using password: NO)" mean? -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1c26a0d-a509-46eb-b496-f7f09161e606%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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/fa3b7acf-e015-4e0c-abbe-49da80b752a9%40googlegroups.com <https://groups.google.com/d/msgid/django-users/fa3b7acf-e015-4e0c-abbe-49da80b752a9%40googlegroups.com?utm_medium=email_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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:djan
Re: Access denied for MySQL user in Django
Galil, I had a problem like this a couple years ago, and the solution was to delete the anonymous MySQL guest user as: mysql> use mysql; mysql> delete from user where host='localhost' and 'user=''; mysql> flush privileges; I'm not sure why Django 1.4 was trying to connect as the guest user when it had a username and password that it was supposed to be using, but for some reason it was. Deleting the guest user from MySQL fixed it for me, and is a good idea for security reasons anyhow. --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/14/16 7:11 AM, Galil wrote: I have created a Django app and which uses MySQL. The settings.py file in the database sections is: |DATABASES ={'cdraccess':{'ENGINE':'django.db.backends.mysql','NAME':os.environ.get('CDR_DB_NAME','portal2'),'USER':os.environ.get('CDR_DB_USER','cdraccess'),'HOST':os.environ.get('CDR_DB_HOST','127.0.0.1'),'CONN_MAX_AGE':0,'PASSWORD':os.environ.get('CDR_DB_PASSWORD',''),},'default':{'ENGINE':'django.db.backends.sqlite3','NAME':'db.sqlite3',}}| I run the app like: |CDR_DB_PASSWORD='password'CDR_DB_HOST='host_name'./manage.py runserver| but I get the following error: Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)") I tried to access the database from terminal, like: |$ mysql --host=[host_name]--user=cdraccess -p portal2| and worked fine. What is going wrong in here? And what does this "(using password: NO)" mean? -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/e1c26a0d-a509-46eb-b496-f7f09161e606%40googlegroups.com <https://groups.google.com/d/msgid/django-users/e1c26a0d-a509-46eb-b496-f7f09161e606%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5697DFA4.20300%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: how do I .............?
python manage.py shell --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/13/16 1:43 PM, Steve Burrus wrote: how do I connmect to the Django server on the command line? -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/bb769cd8-8f1a-41e2-84cb-20e5f026b715%40googlegroups.com <https://groups.google.com/d/msgid/django-users/bb769cd8-8f1a-41e2-84cb-20e5f026b715%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56969BC6.4070603%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: django-admin.py startproject mysite
Muhammad, Use the command ifconfig (Linux, Mac) or ipconfig (Windows) to see your local IP address. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/10/15 10:08 AM, Peter of the Norse wrote: 0.0.0.0 is not an actual IP address. You can’t put it in your browser. Instead, you need to find your computer’s IP address and use that. How you find it depends on your OS, but once you do, then you can visit http://192.168.0.5:8000/ (for example). On Nov 4, 2015, at 5:50 PM, Muhammad Asamov <maila...@gmail.com> wrote: HI I was wodering whether someone can hepl me with startproject The thing is when I am running startproject from the server ip 127.0.0.1:8000 which was created automaticly i can see the result but if i give different address: 0.0.0.0:8000 I can see nothing it is not showing anything Actually I was giving this address cause wanted to see mysite from another computer and don't know why it is not working Peter of the Norse rahmc...@radio1190.org -- 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/5642495E.90603%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: How do I server my app in apache in subdirectory?
frocco, I've done exactly that. No problem. How does it fail? What it should be doing is redirecting any URLs like /mysite to the wsgi.py file so Django will handle them. What error or bad behavior do you see? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/10/15 9:39 AM, frocco wrote: Hello, In httpd.conf this works WSGIScriptAlias / C:/MAMP/htdocs/django/vnatracking/vnatracking/wsgi.py however if I change it to WSGIScriptAlias /mysite C:/MAMP/htdocs/django/vnatracking/vnatracking/wsgi.py it fails Instead of localhost, I want localhost/mysite Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/17150f3f-77e1-4c86-b5b7-939eb3dfde20%40googlegroups.com <https://groups.google.com/d/msgid/django-users/17150f3f-77e1-4c86-b5b7-939eb3dfde20%40googlegroups.com?utm_medium=email_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/564248FA.6050608%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Accessing Django test client in setUpClass
Nicole, If you can't access self.client of TestCase, you can always allocate one yourself as: c = Client() See details in: - http://www.dougalmatthews.com/2010/Jan/20/testing-your-first-django-app/ --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/22/15 4:08 AM, Nicole Harris wrote: I just posted this on Stack Overflow and then realised I might have more luck here. Basically, I'd like to know if I can access self.client inside setUpClass(cls) when setting up a Django test: http://stackoverflow.com/questions/28084683/accessing-django-test-client-in-setupclass If anybody has any insight on this, I'd really appreciate it :) -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/fb4e3cd7-a70a-4a7c-b61f-f6ef73d7e226%40googlegroups.com <https://groups.google.com/d/msgid/django-users/fb4e3cd7-a70a-4a7c-b61f-f6ef73d7e226%40googlegroups.com?utm_medium=email_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/54CAAB89.9020002%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Downloading thumbnails and replacing them with full images
+1 for easy-thumbnails. We use it and it works great. Allows the user to upload images, optionally crop them during the upload, manages the full-size and thumbnail files on the file system with their names in the DB, etc. All automatic and all easy. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/24/15 11:25 AM, Larry Martell wrote: On Fri, Jan 23, 2015 at 7:44 PM, Russell Keith-Magee <russ...@keith-magee.com> wrote: On Sat, Jan 24, 2015 at 12:20 AM, Larry Martell <larry.mart...@gmail.com> wrote: I have a django app that downloads 100's of images. To increase the performance, I want to change it so that it downloads thumbnails, and when the user clicks on one then download the full image. I'm sure I can come up with something on my own (send an ajax request on click, etc.) but I was wondering if anyone has already done something like this and knew of any packages or can give any hints or advice. My suggestion - look into easy-thumbnails: http://easy-thumbnails.readthedocs.org/en/latest/index.html It's an augmentation of Django's ImageField that allows you to store a "single" image in your model, but also specify policies for how thumbnails of any image will be generated (in multiple sizes, if needed). The field will then automatically generate those thumbnails (either on upload, on demand on download, or in a background process, depending on how you configure it), and provide an easy way to find the media URL for each thumbnail (as well as the original). Thanks very much for the reply Russell. Before I got your message I found SuperBox which seems to be working for me. But I will keep easy-thumbnails in mind for the future. -larry -- 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/54C437E8.2000806%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Recommendations for hosting service?
+1 for AWS. Been using it for years. Keeps getting cheaper and better. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 1/6/15 10:46 AM, Mark Phillips wrote: +1 for Linode and Digital Ocean. Also, you can get 2 Virtual Private Servers on AWS EC2 for free for the first year. http://aws.amazon.com/free/ <http://aws.amazon.com/free/> Mark On Tue, Jan 6, 2015 at 7:21 AM, claudiomet <claudio...@gmail.com <mailto:claudio...@gmail.com>> wrote: I have digitalocean and no problems 2015-01-06 11:05 GMT-03:00 Vijay Khemlani <vkhem...@gmail.com <mailto:vkhem...@gmail.com>>: I like Linode, and DigitalOcean is also a great choice. Both require low-level configuration of the server but I prefer that over the pre-packaged solutions. On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice <bradri...@gmail.com <mailto:bradri...@gmail.com>> wrote: I like webfaction, too. I think they would have all the stuff you list as well as more. On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote: Anyone have recommendations for hosting services that can do Django, Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff? I’m also looking to have IMAP email. This would be for several domains, with maybe 100GB of data. -bobby -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com <https://groups.google.com/d/msgid/django-users/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com?utm_medium=email_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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/CALn3ei2Vh-OmGWYd25-fL829cokjKLvcF59EV0nvpk7E%2BQEd5g%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CALn3ei2Vh-OmGWYd25-fL829cokjKLvcF59EV0nvpk7E%2BQEd5g%40mail.gmail.com?utm_medium=email_source=footer>. For more options, visit https://groups.google.com/d/optout. -- Claudio Cortes N. Project Engineer Environmental Area MICOMO S.A. Tel: +56 (2) 22400516 <tel:%2B56%20%282%29%2022400516> Cel: +56 (9) 65871064 <tel:%2B56%20%289%29%2065871064> ccor...@micomo.cl <mailto:ccor...@micomo.cl> www.micomo.cl <http://www.micomo.cl> Antonio Rabat Sur 6165, Vitacura Región Metropolitana, Chile -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/CABWjCh3rsr23aw2LwhJPcO3SkR_FG3_Ct4VPAAUdi9iz97WBfQ%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CABWjCh3rsr23aw2LwhJPcO3SkR_FG3_Ct4VPAAUdi9iz97WBfQ%40mail.gmail.com?utm_mediu
Re: Content using {% include %} not appearing on detailed page Django
Andrew, I'm not sure, but since no one else has answered yet... Maybe you can't pass an object as a keyword argument to include, can only pass strings? I've done it often with strings, but never with an object. Try: {% include "sidebar.html" title=object.title %} and in the included file, use simply: {{title}} It seems odd that there'd be a restriction like this since I'm sure you can pass objects to templates from views, but it's worth trying. May be a good workaround, or may get you a different error message that tips you off to what the real problem is. --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 12/16/14 2:27 PM, Andrew Nguyen wrote: I'm having some problems getting some of my content to appear on my detailed page view, which I have in two separate html files that are being pulled in using |{% include %}|. Inside my two files, |slider.html|and |sidebar.html|, I'm using tags like |{{article.title}}| to grab specific information I need about an article. *TRIED: * - Changing syntax in the two included files to |{{object.title}}| did not work. - I've tried doing|{% include "sidebar.html" article=object %}|in my|detailed.html|and it did not work. Instead, I would get an error|TemplateSyntaxError at /gone-home Unknown argument for u'include' tag: u'article=object'.| - Also tried doing `{% include "sidebar.html" with article=object %} did not work either. *detailed.html* | {% include"sidebar.html" %}
Re: ANN: Django website redesign launched
Jannis, Care to summarize what has changed? At first glance, it looks like mostly the same excellent content and the same sensible organization of info, with the same useful mechanisms like the ability to easily flip between different versions of the docs. Are the changes mostly to do with CSS styles, colors, fonts, presentation of info? Or is there a change to the content or the navigation, as well? Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 12/16/14 11:09 AM, Jannis Leidel wrote: Hi everyone, We're incredibly proud to share with you the new design of the Django website, the documentation and the issue tracker. This is a long time coming and we couldn't be happier to finally ship it :) As you can imagine, there will be bugs, so please bear with us and report issues to the issue tracker at https://github.com/django/djangoproject.com/issues More infos about the redesign and its history can be found in the blog post: https://www.djangoproject.com/weblog/2014/dec/15/announcing-django-website-redesign/ Happy coding, everyone! Jannis -- 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/54905B00.9070908%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Can anyone give me a suggestion or a recommendation as to how I can access the current user's username in the models.py?
Collin and Russell (and anyone else), Do you have any opinion on this? - https://bitbucket.org/aptivate/django-current-user It was offered in an earlier post: - https://groups.google.com/d/msg/django-users/y7aIbN2_CsA/GtmrSjG1nq8J as a solution to exactly this problem. Makes the current user available to the save() method of all models. I read the code and it looks good, but I don't know the details of Apache/WSGI/Django/Python multi-threading well enough to know if it is thread safe. It basically uses django.db.models. signals.pre_save.connect() to get a callback called just before each save(), and that callback was generated by a middleware layer to know what the current user was for a request, so it sets a model field with a name like update_user to the current user just before the save(). If there were 2 concurrent HTTP requests, would this work reliably? Or would there just be 2 registered callbacks, that would overwrite each other's values in the update_user field before the save()? If so, one user would be recorded for saves done by both requests. It seems to me that this would work fine if each HTTP request was handled by a separate process, but not if handled by separate threads that share the same memory, and presumably the same signals and callbacks. Thoughts? --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 12/14/14 2:13 PM, Collin Anderson wrote: Hi, The "admin save handlers" refers to save_model() and there's actually a nice example of accessing the user. https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model If you're using the admin, that's a good place to record this sort of thing. Using a middleware is also helpful for a more general approach, though be careful because connections can now be re-used over multiple requests. Also, if you're deploying using threading, be sure what you are doing is thread-safe. Collin On Friday, December 12, 2014 5:29:35 AM UTC-5, malt...@gmail.com wrote: Thanks Mike and Russell, this is very helpful for starters. Do you have some more verbose code examples I can use as crutches while I hobble along the path of understanding Django? Especially an expansion on something like "All the admin save handlers" would be much appreciated. For me every change needs to be tracked, not just ones from the admin realm, and the audit trail entry is written by a trigger function which gets the current user name from a variable set for the postgres connection. My quest so far was to find the magical place where I have access to the request (for the username) and the db.connection (for setting the database variable), which – if I understand correctly – does not exist. So right now I was about writing my own middleware class with a process_view. Would that be the right place and how would I introduce the username into the data flow? Sincerely, Malte -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/561482b8-a4bf-44fd-9c7d-ef2bbec54726%40googlegroups.com <https://groups.google.com/d/msgid/django-users/561482b8-a4bf-44fd-9c7d-ef2bbec54726%40googlegroups.com?utm_medium=email_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/548E3609.8020509%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: I can't syncdb via django_pyodbc of Django.
on tsql -S my_dns_name -D my_db_name -U my_username Password: locale is "en_US.UTF-8" locale charset is "UTF-8" using default charset "UTF-8" Default database being set to my_db_name 1> ## Install pyodbc for Mac 2014-07-16 - Fred and Jim found new information for Max OS X from: http://stackoverflow.com/questions/20074620/installing-pyodbc-fails-on-osx-10-9-mavericks OSX Mavericks dropped sql headers that are required for pyodbc compilation. Following these steps allowed me to install pyodbc: 1. Install the iODBC library (http://www.iodbc.org/) 1. Download tar file from website, libiodbc-3.52.9.tar 2. Extract iODBC sources from the tar file. We extracted into directory /Users/jim/Downloads/libiodbc-3.52.9 2. Run pip install --allow-external pyodbc --allow-unverified pyodbc --no-install pyodbc 3. cd [VIRTUAL_ENV]/build/pyodbc 4. Run python setup.py build_ext --include-dirs=/Users/jim/Downloads/libiodbc-3.52.9/include/ 5. Run pip install --no-download pyodbc Mac OS X note The `pyodbc` package that _pip_ installs uses iODBC by default. We want it to use `unixODBC`, instead, for a couple reasons. * First, there are numerous sites on the Internet that make claims such as "iODBC is a slightly less desirable ODBC manager than unixODBC" (http://www.cerebralmastication.com/2013/01/installing-debugging-odbc-on-mac-os-x/). More people _seem_ to have better luck with `unixODBC`. * Second, we're using `unixODBC` on Linux, and the configuration is already complicated enough. So, why not just use the same approach on both platforms? To get `pyodbc` to use `unixODBC` on the mac, you have to build it from source, and you have to hack the `setup.py`. Here's how to do it. $ . ~/pythons/hhl/bin/activate $ cd /tmp $ git clone https://code.google.com/p/pyodbc $ cd pyodbc $ patch >> import pyodbc >>> conn = pyodbc.connect('DRIVER=SQL Server;' 'SERVER=my_db_server_name' 'PORT=my_db_server_port_number;' 'DATABASE=my_db_name;' 'UID=my_username;' 'PWD=my_password') >>> conn ### Hope this helps! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 12/10/14 11:58 AM, pythonista wrote: I can actually help you here. I had the same problem and tried 4 different modules. The only module that works with sql server is https://github.com/michiya/django-pyodbc-azure I am running it both on windows and linux, simultaneously. The settings components are displayed on the web site. Works like a charm One dependency is pyodbc to be installed. On Wednesday, December 10, 2014 4:22:44 AM UTC-5, Sugita Shinsuke wrote: Hi there. Could you tell me a good way to use Django with Micro Soft DB SQL server. I tried django_pyodbc. Any suggestion is appreciated. my PC of Environment is below. Database: SQL Server 2014 Express OS: Windows 7 Home Premium SP1 I used the django module, django_pyodbc. And, I tried to run syncdb but I couldn't. My settings.py is below. DATABASES = { 'default': { 'ENGINE': "django_pyodbc", 'HOST': "localhost", 'USER': "djangouser", 'PASSWORD': "x", 'NAME': "db_test", 'OPTIONS': { 'host_is_server': True, 'autocommit': True, 'unicode_results': True, 'extra_params': 'tds_version=8.0' }, } } Things I tried and did not work: 1,change "localhost" to "127.0.0.1,1433" in the HOST property of the code. 2,removed 'OPTIONS'. However, I tried the module pyodbc of pure python like below. It was fine. --- conn = pyodbc.connect('driver={SQL Server};server=localhost;UID=djangouser;PWD=x;DATABASE=shannon_test;Trusted_Connection=yes') --- But, DB connection is not established without "Trusted_Connection=yes". At least I do not know any other way. Anyone who know this matter, please help. The error message is here. pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server Driver][ SQL Server]\x82\xb1\x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\x b3\x82\xea\x82\xbd\x83f\x81[\x83^\x83x\x81[\x83X "shannon_test" \x82\xf0\x8aJ\x8 2\xaf\x82\xd
Python/Django programmers needed (telecommute)...
Django programmers, Interested in a telecommute position for $80-100K/year? I just forwarded this one to my "Job Wanted" and "Consultants" mailing lists. See email appended below. Also, for anyone local to Philadelphia PA, I expect to be recruiting onto my own team in about a month or so. Telecommute with weekly status meetings in Radnor PA, and ad-hoc local co-working sessions with the dev team. Interested in either one, please let me know. --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. Forwarded Message Subject:Python/Django programmer needed (telecommute)... Date: Thu, 4 Dec 2014 18:46:36 -0500 (EST) From: f...@bristle.com To: f...@bristle.com Job seekers and Consultants, I'm hesitant to send this one out because I'm going to be trying to recruit such people onto my own team in another month or so, and I'd hate to lose the best of you to this guy, but... It seems like a good offer. The salary is pretty low, but the rest of the job description sounds really appealing, and maybe the right guy can get them to double the salary to get it up to market rate. So it would be selfish of me to not at least tell you about it. - Senior Python/Django programmer - Educational software product company, start-up, college portal product, successful at one college and rolling it out across the country. - Skills: - Python/Django - FOSS - Agile, demonstrative excellence, code quality, peer code reviews - Proficient and proactive communicator both written and oral - Python MVC frameworks: Django, Pyramid, Flask - Memcached, Celery - TDD, PyLint, Nose, Twill, Mechanize, Selenium - Jenkins, Bamboo - REST, Django-Rest-Framework, Tastypie, Web services - Django's ORM, SQLAlchemy, MySQL, PostgreSQL, MongoDB, DynamoDB - JSON, HTML5 - JavaScript, jQuery, Ajax - RWD (Responsive Web Design), Bootstrap - Cloud, AWS S3, EC2, CloudFront, Route53, CloudFormation - Git - Redis, MongoDB - Salt, Ansible - DevOps - Node.JS - Ember.js, Backbone.js - ElasticSearch, Solr, Haystack - Consultant becoming FTE (right to hire) - 6+ months - $80-100K/year - Telecommute with 1-2 weeks/year onsite in Indianapolis Interested? Let me know. --Fred ----- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. - Fred, Thank you for your detailed response and good luck with your project. I'll attempt to answer your questions and anyone interested can contact me for more details -- thanks! Some questions I always ask (some of which were answered in your attached job description): - Brief description of the company, what it does, what the work environment is like, etc? Educational software product company, start-up, college portal product that was successful at one college and rolling it out across the country. - Brief description of the responsibilities of the position you are trying to fill? See JD, mid-senior level, some mentoring/coaching of junior developers - Technologies used and skills needed? See JD - Consultant or FTE? Consultant at first under my firm, then fulltime with my client - Full time or part time? Fulltime - How long is the initial contract? 6-month contract to hire, more or less based on client preference - How long is the project likely to run? Fulltime position after contract - Approx salary or hourly rate offered? Salary in the $80-100K for fulltime, some leeway higher if needed, salary converted to hourly for contract period - Location (Philly, western suburbs, Wilmington, telecommute, etc.)? Telecommuting, client is located in Indy, occasional travel to Indy required but should not exceed 1-2 weeks annually, 1-2 weeks onsite at start of contract to meet team/etc. Wow! That is a REALLY good match for my skills and interests! I particularly like these aspects (almost everything you described -- my friends would say you wrote the job description for me personally): - Python/Django - Telecommute - Demonstrative excellence - Participation in the open source community - Provides expert knowledge and guides best practice - Fanatically documents all code via docstrings and Sphinx - Increases test coverage via Test Driven Development - Writes unit tests - Actively ensures code quality and conformance -
Re: Upgrading Django (to 1.7)
Andrew, Part 4 looks great! Thanks for the shoutout as a reviewer of Part 4. Like with Part 3, it would be better to link it to my one-man company's corporate site than to just my links page. Use: http://bristle.com I'm re-posting my privately emailed comments on the latest version here so people can find them as part of this thread. Lots of good advice on how to upgrade, including: - Tools/resources to use - Value of having a test suite - Use of DEV/TEST/PROD and virtualenv - Importance of going to 1.5, then 1.6, then 1.7, as separate steps - Upgrading packages you depend on - Upgrading Python itself - Release notes for each version -- Backwards-incompatible changes -- Deprecated features -- New features - Use new Check Framework to enforce coding standards - etc. See also: - http://andrewsforge.com/article/upgrading-django-to-17/checklist Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/25/14 7:16 PM, Andrew Pinkham wrote: Hi, Upgrading Django (to 1.7) Part IV: Upgrade Strategies is now available! For the article: afrg.co/updj17/a4/ For all of the material: afrg.co/updj17/ I've also provided a checklist of upgrade steps, as well as a list of all the links used throughout the series: afrg.co/updj17/cl/ afrg.co/updj17/l/ Any feedback appreciated. I hope you find the material helpful. Andrew -- 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/54762BF5.80503%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
Andrew, Thanks for the shoutout as a reviewer. Would be better to link it to my one-many company's corporate site than to just my links page. Use: http://bristle.com I'm re-posting my privately emailed comments on the latest version here so people can find them as part of this thread. Looks good! You did a great job of explaining the bits that I previously didn't get: - Relationship of INSTALLED_APPS to App Registry - History of the App Registry - AppCache, Apps, AppConfig - apps.py - Custom AppConfig Also: - app registry vs. master registry - label vs. name in AppConfig - Need for renamed imports - Exact sed command to change an app's label - AppConfig.ready() - autodiscover() - Apps restrictions (custom user model) The Check Framework section is now also very clear, and it seems to be very complete as well. I like the iterative approach you use: describing a simple way, then a problem, then an enhancement that solves the problem, then another problem, etc. Nice job! This will be very useful when I start using the Check Framework to enforce coding standards for my team when we move to Django 1.7 or 1.8. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/25/14 3:03 PM, Andrew Pinkham wrote: Hi, I have just updated Upgrading Django (to 1.7) Part III: Django 1.7's New Features. The App Registry and System Check Framework sections have been updated to be more accessible. For the article: afrg.co/updj17/a3/ For all of the material: afrg.co/updj17/ Part IV will be available before the end of the day! Andrew -- 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/54762A82.6060507%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Image input missing from POST request
Abhishek, Good tip about the syntax! I didn't realize you could do that to avoid having to nest the fields inside the . I just looked it up at: - http://www.w3schools.com/tags/att_input_form.asp where it says 2 interesting things: - Not supported in IE - Can specify multiple forms that the same input field is a part of, so presumably, the field would be POSTed with any of the listed forms. Rest of the page does not make it obvious how to do that though. Value is a string of space-separated form ids perhaps? Any comment of either of these 2? Have you tried your app on IE? Have you tried specifying multiple forms? Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/25/14 11:19 PM, Abhishek Batra wrote: Hi Collin, Thanks for taking time out to look at this. It turns out that I somehow I copied the rendered HTML wrong! The real problem was that the form id used in input was incorrect and this was the reason for the file not getting uploaded. Separately, this is not really a trick but a fairly standard technique nowadays, and after correcting my mistake, it works just fine. Thanks, Abhishek On Tuesday, November 25, 2014 7:08:07 AM UTC+5:30, Collin Anderson wrote: Hi, I certainly am learning something new about . However, it may be that that trick simply doesn't work correctly for file fields. My question is: _does_ it work correctly when the is a child of the ? Collin On Saturday, November 22, 2014 1:21:32 PM UTC-5, Abhishek Batra wrote: Hey Donarb, Input fields are not required to be inside form elements, so long as they specify the form attribute as I have done. Check the form attribute here <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#Attributes> for reference. Moreover, I have other input fields as well which are outside the form element, but they get successfully submitted. Any other suggestions anyone? Thanks, Abhishek On Saturday, November 22, 2014 11:03:39 PM UTC+5:30, donarb wrote: On Friday, November 21, 2014 7:56:54 PM UTC-8, Abhishek Batra wrote: Hi, This is probably not a Django issue, but just trying my luck. I have an |input| field corresponding to a Django |ImageField| in a Django template. Rendered, the HTML looks like: | method="post" id="profile_form" enctype="multipart/form-data"> ... (other input fields and elements) | The corresponding |View| is an |UpdateView|. I found |request.FILES| to be empty and |request.cleaned_data| to contain |'profile_pic': None|. I used firebug to track the POST data. It contained other fields but not |profile_pic|. Can anyone say why the file does not get uploaded? I've posted this question to StakOverflow <http://stackoverflow.com/questions/27059357/image-input-missing-from-post-request> as well, in case someone wants reputation points. Thanks, Abhishek Batra The input field is outside the closing tag so would not be uploaded as part of the form. -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/aea0cc13-0b33-4734-b59f-a4f06ae12c14%40googlegroups.com <https://groups.google.com/d/msgid/django-users/aea0cc13-0b33-4734-b59f-a4f06ae12c14%40googlegroups.com?utm_medium=email_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-user
Re: Web and mobile app with Django? Kivy? sth else?
+1 for writing a single RWD (Responsive Web Design) web app using Django, instead of writing separate web, Android and iOS apps. If necessary, wrap the result in PhoneGap to mobile-specific features, uploading images from the camera, capturing the GPS location, showing maps, accessing the local file system and contacts, etc. But only if you need those features. My current project uses RWD techniques to look good on phones, tablets, and full screens. Lots of jQuery, Ajax, HTML5 and CSS3 for a rich user experience. Drag any of the pages wider or narrower to see what I mean: - http://helphopelive.org --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/24/14 8:37 AM, Collin Anderson wrote: Hi, Django can do all of those things except the native android/ios apps. Django specializes in websites and especially helpful for handling things like logging in, querying a database, processing form input, and generating html. Here are some ways Django can help with your situation: You could build native android/ios apps and use Django for the server side of your app, like how Instagram does it. You could handle the desktop side as a website made with Django. If you really wanted low-cost-maintenance, you could have your android and ios apps just be simple wrappers around a webview that's loading content from Django. Collin On Friday, November 21, 2014 9:56:38 AM UTC-5, Mariusz Wilk wrote: I'm new to programming. Eventually, I'd like to make a website and an android/ios app that would work together and display pretty much the same content on a mobile as on the the web. Each client would log in (via mobile or desktop) and continue solving some exercises from the place he previously finished at. I have a potential client for this app, I don't have any deadline and if it works fine I shouldn't have any problems selling it to him and getting some commercial experience! So my question is: *what should I be learning to eventually reach this goal?* I've done a few Python tutorials/courses online, I played around with HTML, CSS and JS, right now I'm learning Kivy. Django scared me a lot, but maybe I should give it another try. -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/e4e4ed98-407b-41c1-841c-0d91eb70de7c%40googlegroups.com <https://groups.google.com/d/msgid/django-users/e4e4ed98-407b-41c1-841c-0d91eb70de7c%40googlegroups.com?utm_medium=email_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/54737893.3080604%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Deploying Django project
Mulianto, You said: Fred way is good, but need time to type and remember all the steps. WIth fabric you will not miss a step and it can be automated. I think you misunderstood my post. The commands I showed are excerpts from my automated script. I provided them so termopro could write such a script of his own. I don't type all of those commands each time. I just type: *pub* --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/20/14 7:50 PM, Phang Mulianto wrote: Hi termopro, TO automate the deployment, look for fabric + cuisie (CHef like fabric) . You will bored with the command line in each deployment, and you will need fast and standard way of deploying to each new machine. Fred way is good, but need time to type and remember all the steps. WIth fabric you will not miss a step and it can be automated. Git is you friend here. You can create a private repo in your prod machine, and make the code pull from the repo for production deployment when you push from dev to prod with hook script (Automate again) BUt make sure the code tested before go production with this way. Regards, Mulianto Blog: http://muliantophang.blogspot.com On Fri, Nov 21, 2014 at 7:37 AM, Fred Stluka <f...@bristle.com <mailto:f...@bristle.com>> wrote: termopro, I have automated my deployments mostly separate from my version control. The other team members and I write, test, commit, and push our code changes to our Git repo. I then pull, review, test, update the version number, commit, tag, and push to Git. Then I use a shell script (on Mac, but would work on Unix/Linux also) to push the tagged commit to TEST and later to PROD. My script does things like: - Get the latest files from Git before, and back to master after: % git checkout mytag ... % git checkout master - Create folder of collected static files before, and delete after: % mkdir -pv collected_static/mytag % python manage.py collectstatic --clear --noinput ... % rm -rfv collected_static - Delete all local *.pyc files: % find . -name \*.pyc -exec rm -v "{}" ";" - Insert PROD password into local settings file (PROD pushes only) before, and remove after: % sed -i .old -e "s/PUT_PROD_PASSWORD_HERE/`cat prod_pw`/g" settings.py ... % mv -v settings.py.old settings.py - Show a warning banner at the Web site to say it is going down briefly, and clear the banner after: % ssh -t myserver.mydomain.com <http://myserver.mydomain.com> cp -v /var/www/django/myapp/templates/myapp/site_alert_maintenance.html site_alert.html % sleep 60 ... % ssh -t myserver.mydomain.com <http://myserver.mydomain.com> cp -v /var/www/django/myapp/templates/myapp/site_alert_none.html site_alert.html - Push the local files to the TEST or PROD server: % rsync -v --progress -i -l --rsh=ssh -r --del myapp myserver.mydomain.com:/var/www/django - Run all migrations on the server % ssh -t myserver.mydomain.com <http://myserver.mydomain.com> python manage.py migrate --all - Stop the Apache server, delete all remote *.pyc files, and restart the server: % ssh -t myserver.mydomain.com <http://myserver.mydomain.com> sudo /etc/init.d/httpd stop % ssh -t myserver.mydomain.com <http://myserver.mydomain.com> sudo find /var/www/django/myapp -name \*.pyc -exec rm -v "{}" ";" % ssh -t myserver.mydomain.com <http://myserver.mydomain.com> sudo /etc/init.d/httpd start Plus a few other actions that are specific to our app, and lots or informational messages, prompts, confirmations, etc. Also, some of these steps are combined into a remote script that runs on the server to reduce the number of "ssh -t sudo" commands I would otherwise have to do. But, that's the gist of it. Hope this helps! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/19/14 5:22 AM, termopro wrote: I have created a Django 1.7 project and would like to deploy it. I am reading about how to do it right and i have some questions
Re: Advice needed: Adaptive/Responsive Images in Django?
Right. Very good article. The gist is to use the new HTML5 "" and "" elements along with the "sizes" and "srcset" attributes of "", and perhaps the CSS3 "calc()" function to specify multiple sizes of the same image, so the browser only downloads the right one for the current screen size, all in a way that falls back to slower but acceptable for older browsers. BTW, if you're willing to throw a little JavaScript into the mix, and not limit yourself to just CSS, you can do truly amazing things with RWD (Responsive Web Design). I've been doing it for about 14 years. See, for example: - http://bristle.com/RWD/BrightPanelsDemo/ Drag the window wider and narrower and watch the panels completely re-configure themselves, nesting/un-nesting, stacking/un-stacking, hiding/showing, etc. Anything is possible. --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/20/14 8:55 AM, Patrick Beeson wrote: AListApart recently published a great article on responsive images: http://alistapart.com/article/responsive-images-in-practice On Thursday, November 20, 2014 1:05:45 AM UTC-5, ThomasTheDjangoFan wrote: Hi guys, do you have a tip for implementing adaptive (responsive) images in django? Basically I want to server smaller images to mobile-users and bigger images to desktop users. I don't really now about best practices for SEO and Siteload-Performance. Are there any apps that you can recon for this? Thanks a lot for your tips! Kind regards Thomas -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/0ea0a557-8043-4bfa-bc2f-23c2561e2245%40googlegroups.com <https://groups.google.com/d/msgid/django-users/0ea0a557-8043-4bfa-bc2f-23c2561e2245%40googlegroups.com?utm_medium=email_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/546E80DB.1010503%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Deploying Django project
termopro, I have automated my deployments mostly separate from my version control. The other team members and I write, test, commit, and push our code changes to our Git repo. I then pull, review, test, update the version number, commit, tag, and push to Git. Then I use a shell script (on Mac, but would work on Unix/Linux also) to push the tagged commit to TEST and later to PROD. My script does things like: - Get the latest files from Git before, and back to master after: % git checkout mytag ... % git checkout master - Create folder of collected static files before, and delete after: % mkdir -pv collected_static/mytag % python manage.py collectstatic --clear --noinput ... % rm -rfv collected_static - Delete all local *.pyc files: % find . -name \*.pyc -exec rm -v "{}" ";" - Insert PROD password into local settings file (PROD pushes only) before, and remove after: % sed -i .old -e "s/PUT_PROD_PASSWORD_HERE/`cat prod_pw`/g" settings.py ... % mv -v settings.py.old settings.py - Show a warning banner at the Web site to say it is going down briefly, and clear the banner after: % ssh -t myserver.mydomain.com cp -v /var/www/django/myapp/templates/myapp/site_alert_maintenance.html site_alert.html % sleep 60 ... % ssh -t myserver.mydomain.com cp -v /var/www/django/myapp/templates/myapp/site_alert_none.html site_alert.html - Push the local files to the TEST or PROD server: % rsync -v --progress -i -l --rsh=ssh -r --del myapp myserver.mydomain.com:/var/www/django - Run all migrations on the server % ssh -t myserver.mydomain.com python manage.py migrate --all - Stop the Apache server, delete all remote *.pyc files, and restart the server: % ssh -t myserver.mydomain.com sudo /etc/init.d/httpd stop % ssh -t myserver.mydomain.com sudo find /var/www/django/myapp -name \*.pyc -exec rm -v "{}" ";" % ssh -t myserver.mydomain.com sudo /etc/init.d/httpd start Plus a few other actions that are specific to our app, and lots or informational messages, prompts, confirmations, etc. Also, some of these steps are combined into a remote script that runs on the server to reduce the number of "ssh -t sudo" commands I would otherwise have to do. But, that's the gist of it. Hope this helps! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/19/14 5:22 AM, termopro wrote: I have created a Django 1.7 project and would like to deploy it. I am reading about how to do it right and i have some questions. If i understand correctly deployment should contain the following steps: 1) Initial remote machine set up: * a) install os / server / database / cache ... * b) install Django and required modules * c) update database with real data 2) Upload code/ database changes to remote machine: * a) upload changed Django project * b) upload changes in Database tables (model migrations) Most tutorials/articles about deployment do not cover 1.c and 2.b. Also the tasks 1.b. and 2.a. are solved using revision control tools (Git/Mercurial) So i'd like to know: * 1) How do i install Django project or it's updates without revision control tools ? Should i simply upload my project using FTP/SSH ? Is there a good way to automate it ? * 2) How do i automate the task of uploading required database changes (like model migrations) ? -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/e9fb8f5a-2bd9-47d5-80c7-07a3aa82bd25%40googlegroups.com <https://groups.google.com/d/msgid/django-users/e9fb8f5a-2bd9-47d5-80c7-07a3aa82bd25%40googlegroups.com?utm_medium=email_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 http
Re: HStoreField can't adapt type 'dict'
Collin, Your answers to so many questions lately have been very helpful. Thanks! Any reason you don't include the original question with your reply? Either by top-posting, or by quoting an excerpt? Would provide context to your answers, making them more useful, especially to those of us reading them as email, not at the Google Groups Web site. Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/12/14 3:36 PM, Collin Anderson wrote: If anyone runs into this later, here's the ticket with the solution: https://code.djangoproject.com/ticket/23776 -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/fa827df7-abc4-41f6-b0b7-b947b2638396%40googlegroups.com <https://groups.google.com/d/msgid/django-users/fa827df7-abc4-41f6-b0b7-b947b2638396%40googlegroups.com?utm_medium=email_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/5464DC53.2070706%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: how to test an application that's using a legacy database
David, No. You can use it unchanged. With Django 1.4 at least, and I assume also with 1.7. I have a legacy MS SQL Server DB where I have rights to modify data but not tables. I also cannot create new DBs in MS SQL Server. I used *inspectdb* to create models from the existing DB. I generally have them marked as *managed=False*, but when running tests, I have them *managed=True*, and I override the *DATABASES* settings to point to SQLite, instead of MS SQL Server. Thus, when I run the tests, the test DB is created in SQLite, and the real DB server is untouched. Here's how I do it: *settings.py:* DATABASES = { ... the usual stuff ... } # Decide whether we're running unit tests RUNNING_UNIT_TESTS = 'test' in sys.argv if RUNNING_UNIT_TESTS: DATABASES['default'] = { 'ENGINE': 'django.db.backends.sqlite3', } *models.py:* class Meta: managed = True if settings.RUNNING_UNIT_TESTS else False --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/10/14 9:43 AM, dpalao.pyt...@gmail.com wrote: Hi, I'm writing a Django application that uses an existing database. If I understood it well, in such a case one must create non-managed models for the legacy tables to avoid Django creating already existing tables, right? For instance, this is how one of my models looks like: | classJobInfo(models.Model): job_db_inx =models.IntegerField(primary_key=True) id_job =models.IntegerField() id_user =models.IntegerField() id_group =models.IntegerField() account =models.TextField(blank=True) cpus_req =models.IntegerField() cpus_alloc =models.IntegerField() nodelist =models.TextField() nodes_alloc =models.IntegerField() partition =models.TextField() time_start =models.IntegerField() time_end =models.IntegerField() was_updated =models.IntegerField() jobmondatacleared =models.IntegerField(db_column='jobMonDataCleared')# Field name made lowercase. endupcount =models.IntegerField(db_column='endUpCount')# Field name made lowercase. approved =models.IntegerField() classMeta: managed =False db_table ='job_info' | The problem, of course happens when the unit tests are run. The test database must be created when the tests start. But because "managed = False", the tables are not created. First round. Googling a bit I found a recipe to by-pass this problem: modify the DiscoverRunner class (I found it in here <http://www.caktusgroup.com/blog/2010/09/24/simplifying-the-testing-of-unmanaged-database-models-in-django/>, and tailor it trvially to remove the deprecation warning): | classManagedModelDiscoverRunner(DiscoverRunner): defsetup_test_environment(self,*args,**kwargs): fromdjango.db.models.loading importget_models self.unmanaged_models =[m form inget_models() ifnotm._meta.managed] form inself.unmanaged_models: m._meta.managed =True print("setting %s._meta.managed to True"%(m.__name__,)) super(ManagedModelDiscoverRunner,self).setup_test_environment(*args,**kwargs) defteardown_test_environment(self,*args,**kwargs): super(ManagedModelDiscoverRunner,self).teardown_test_environment(*args,**kwargs) # reset unmanaged models form inself.unmanaged_models: m._meta.managed =False | So I created a directory in my project called "tests" and put the above code in a file called "managed_runner.py" in there. To be more explicit, the tree looks like: | |--myapp ||--admin.py ||--__init__.py ||--models.py ||--templates ||`-- myapp | | `--home.html ||--tests.py |`-- views.py |-- myproj | |-- __init__.py | |-- settings.py | |-- urls.py | `--wsgi.py |--manage.py `-- tests |-- __init__.py `--managed_runner.py | Then I modified my "settings.py" file adding | TEST_RUNNER="tests.managed_runner.ManagedModelDiscoverRunner" | to it. And I ran the tests. Still, it fails: | django.db.utils.ProgrammingError:Table'test_db.job_info'doesn't exist | But I see the output of print in the screen saying that the models' ._meta.managed attributes are set to True. Second round. Reading the Django docs, I see that DiscoverRunner has a couple of interesting methods: setup_databases and teardown_databases. I tried to subclass the DiscoverRunner again, this time it looks like: | classManagedModelDiscoverRunner(DiscoverRunner): defsetup_databases(self,**kwargs): fromdjango.db.models.loading importget_models self.unmanaged_models =[m form inget_models()ifnotm._meta.managed] form inself.unmanaged_models: m._meta.managed =True print("setting %s._meta.managed to True"%(m.__name__,)) returnsuper(ManagedMod
Re: Loading fixtures in Django 1.7
Leonard, In Django 1.4, you would add this code to the forwards() method of the migration: from django.core.management import call_command call_command("loaddata", "") --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 11/9/14 5:46 PM, Leonard Wayne wrote: I am in the process of upgrading from Django 1.6 to 1.7. I have three fixtures. I am trying to figure out how I should load them. One fixture is `initial_data.json`, and I know that starting with Django 1.7 this special fixture no longer gets automatically loaded as it did when we used to run `syncdb` (i.e., prior to deprecation in Django 1.7). So I know all three fixtures should be loaded the same way as each other, whatever way that may be. My main question is: Should I keep using `loaddata`, as in: python manage.py loaddata .json Reading the documentation I get the sense (though I am not sure) that now the preferred approach to load fixtures is to create a migration to perform the loading. But I don't see an example of how to do this process from beginning to end. It looks like the process starts with creating an empty migration, then manually editing the migration file to define a function like: def load_data(apps, schema_editor): But I don't know how to write this function (`load_data`), and I can't find an example. -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/e39e44eb-66c5-4e23-89a5-c2abfae9a6ea%40googlegroups.com <https://groups.google.com/d/msgid/django-users/e39e44eb-66c5-4e23-89a5-c2abfae9a6ea%40googlegroups.com?utm_medium=email_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/546052D0.70604%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: createsuperuser tells me its been skipped due to not running in a tty and then tells me i can do it manually by running createsuperuser. Very confused
On 11/8/14 6:54 PM, James Schneider wrote: If you are running them directly via one-time SSH commands (ie $ ssh host 'command'), note that SSH does not request a full TTY and runs everything inside of a channel, which may also pose problems. In which case, you can resolve the issue by using ssh -t as I've often had to do when running sudo via ssh. See: - http://bristle.com/Tips/Unix.htm#sudo_via_ssh --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -James On Nov 8, 2014 2:47 PM, "Andri Sigurðsson" <faustu...@gmail.com <mailto:faustu...@gmail.com>> wrote: Ok i'm running this on a cygwin zsh shell. with python 3.4.1 and Django 1.7.1 I've been running the first app Tutorial on the Django site and its all been going perfectly right up to this moment and i'm absolutely stumped. When i try to run "./manage.py createsuperuser" it gives me this error. "Superuser creation skipped due to not running in a TTY. You can run `manage.py createsuperuser` in your project to create one manually." I havn't been able to find any posts on this particular issue, any ideas? :( -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/448a6acf-6497-4708-9f28-26d7abad043e%40googlegroups.com <https://groups.google.com/d/msgid/django-users/448a6acf-6497-4708-9f28-26d7abad043e%40googlegroups.com?utm_medium=email_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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/CA%2Be%2BciXdEatKM2MgY11OC57TS%3Do8Am4SrfGrdtomj191%3DGsg3Q%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXdEatKM2MgY11OC57TS%3Do8Am4SrfGrdtomj191%3DGsg3Q%40mail.gmail.com?utm_medium=email_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/545F88BF.6070507%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
Sounds good! Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 10/15/14 8:17 PM, Andrew Pinkham wrote: Hi, Thanks to feedback from Fred and a few others, I've started editing Part III to make it more accessible. Part IV was originally set to be published today. Unfortunately, it is not ready to be published. As soon as the new Part III and Part IV are available, I will let you know. Thanks, Andrew -- 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/5440CDDD.6030307%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
Andrew, Yes, that explains a lot. I'd recommend including this explanation in one of the articles of your current series. BTW, one other thing to keep in mind is that we 1.4 users don't know what an apps.py file is, so we don't appreciate not having to create one, since we never did before. Thanks again! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 10/9/14 10:09 PM, Andrew Pinkham wrote: Hi Fred, Thanks again for the positive feedback! I'm sorry I lost you at the App Registry section. I'm afraid I can't recommend an article to help with the topic, either. Given your questions, I can see I missed the mark. Let me give it another go (warning: this is neither technically reviewed nor copy edited). Django uses the `INSTALLED_APPS` setting to find all of the apps in a project, and to build a list of apps to run and use, called an app registry. The way Django builds the app registry has changed radically from Django 1.6 to Django 1.7. Django 1.6 (and before, but I admit I don't know how far back) used the `AppCache` class to maintain a list of these apps. The system was problematic because each `AppCache` instance shared state - any change to one `AppCache` object lead to a change in all `AppCache` objects. Because of migrations (and the need for historical/frozen models), the `AppCache` had to change in Django 1.7. Django 1.7 now provides an `Apps` class to be the app registry. Each instance is separate from others, allowing the migration system to build historical apps and models. You can fetch the `Apps` object (not class!) for your own project with: from django.apps import apps as django_apps Referred to as the master registry (the app registry for your project as it runs), `django_apps` is an instance of `Apps`, which contains a list of `AppConfig` objects. Starting in Django 1.7 all apps now have an `AppConfig` object attached to them. These are built automatically by Django, meaning many developers will be able to get away without ever creating an `/app_name/apps.py` file for their projects. The ability to override `AppConfig`, however, is quite useful. It allows for the implementation of a `ready()` method (seen in the admin `AppConfig` subclass) as well as the ability to explicitly set the app label, allowing developers to easily rectify namespace conflicts. Note that we avoid a namespace error thanks to `as django_apps` with `AppConfig`. I recommend you do this even if there is no namespace error. from django.apps import apps as django_apps from . import apps To deal with this list of `AppConfig` objects (and the models within), all `Apps` instances sport a brand new API. We saw it throughout Part II and Part III of the article, using it to help us with data migrations and to build our checks. The only trick with `Apps` is that it must be fully built and configured before Django can take certain actions, including loading the custom user model, or using parts of the translation system. I touched a little bit on it in Part III, but plan to expand on it in Part IV. The bottom line is that the app registry works mostly in the background by building a master registry and performing many of its key functions without developers ever knowing (just as many developers never knew about Django 1.6's `AppCache`). However, understanding the system even a little allows for the developer to better edit migrations and create checks, and I suspect that interacting with apps via this API will become commonplace. Fred: Is the above helpful? Feel free to ask more questions. On Oct 9, 2014, at 4:53 PM, Fred Stluka <f...@bristle.com> wrote: Otherwise, can you suggest where I can find an article similar to yours that gets me from 1.4 to 1.5 and on to 1.6 before I use yours to get me from 1.6 to 1.7? No, but I hope the process I lay out in Part IV will help you indirectly. Andrew -- 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/5437445F.6000500%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
On 10/8/14 11:30 PM, Andrew Pinkham wrote: Hi, Upgrading Django (to 1.7) Part III: Django 1.7's New Features is now available! For the article: afrg.co/updj17/a3/ For all of the material: afrg.co/updj17/ Any feedback appreciated. I hope you find the material helpful. Andrew Andrew, Excellent 3rd article. Thanks again! I've recommended it to my team, summarizing it as: - South vs Django 1.7 Native Migrations - Upgrading from South to Django 1.7 Native Migrations - New "App Registry" - New "System Check Framework" -- Invoke via: % python manage.py check -- Also runs implicitly as part of most manage.py commands. -- Has hooks to add your own checks to enforce project standards, like: --- All Models must have a __str__ method. - New "Custom Querysets" -- Often better than writing a custom manager - Improved prefetch_related() - New "Custom Lookups" - Improved form error handling The App Registry section is not entirely clear to me, probably because I'm coming from 1.4, not from 1.6. It might help if you explained how the App Registry relates to 1.4 concepts. Like, I assume it replaces INSTALLED_APPS, plus a whole lot more, right? Otherwise, can you suggest where I can find an article similar to yours that gets me from 1.4 to 1.5 and on to 1.6 before I use yours to get me from 1.6 to 1.7? Thanks! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/543703BF.3040706%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
On 10/1/14 11:36 PM, Andrew Pinkham wrote: Any feedback appreciated. I hope you find the material helpful. Andrew, Excellent 2nd article. Thanks! I especially liked the clear explanation of how South migrations interact badly with initial_data fixtures. OK to use fixtures, but load them explicitly via "loaddata" from data migrations. Don't put them in "initial_data" fixtures. Also, good explanations of: - South in general - The reason why there's a models dictionary (the "frozen model") in each migration file, and why to use orm.ModelName - Differences from Django 1.7 migrations - How to get started with Django 1.7 migrations - Unicode vs ASCII issues - Use of objects.bulk_create() Thanks! --Fred -------- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- 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/5431D129.60909%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: templates: if and static tags incompatible?
The problem is that static is not being recognized as a valid Django tag. Add this line to the top of the template file to define it. {% load staticfiles %} --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/29/14 12:41 PM, chansonsyiddish wrote: Hello, I've got a small problem: here is the code in my template: {% if p.fleches %} {% endif %} and the django development server tells me: Django Version: 1.4.5 Exception Type: TemplateSyntaxError Exception Value: Invalid block tag: 'static', expected 'elif', 'else' or 'endif' Is it a bug, or is it really impossible to put a static tag inside an if tag? 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/54298BAD.6030606%40gmail.com <https://groups.google.com/d/msgid/django-users/54298BAD.6030606%40gmail.com?utm_medium=email_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/54298F84.40103%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Fwd: Re: Upgrading Django (to 1.7)
Bob, Are you referring directly to the models by name in the data migrations? That could be the problem, because yes, the migration would be using the latest models at the time that the migration is executed, not the models as they stood at the time that the migration was written. There's a warning in a comment in the boilerplate code generated for each data migration by the command: % manage datamigration It says: def forwards(self, orm): "Write your forwards methods here." # Note: Don't use "from appname.models import ModelName". # Use orm.ModelName to refer to models in this application, # and orm['appname.ModelName'] for models in other applications. and there is a dictionary of the models as they existed at that time shown later in the same file. If you always follow this advice and manipulate orm.ModelName instead of appname.models.ModelName, it should solve exactly the problem you are describing. Hope this helps, --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/27/14 10:00 AM, bobhaugen wrote: The problem we ran into was not with the order of migrations, it was that all of the migrations were running with the latest models.py code. The data migration was trying to move data from one model field to another model field, and the "from" field had been deleted from models.py. This was awhile ago, and my memory might be faulty. Do the latest migrations give you any way to deal with that situation? I mean, do they migrate the models in models.py in sync with the the database schema migrations? I can see where a data migration might work in a schema migration sequence if you expressed it all in SQL, just dealing with the database alone, but we of course wrote in Python using the Django ORM. On Friday, September 26, 2014 10:04:49 AM UTC-5, Fred Stluka wrote: Bob, You can control the order in which migrations run. For South, see "depends_on" and "needed_by": - http://south.readthedocs.org/en/latest/dependencies.html <http://south.readthedocs.org/en/latest/dependencies.html> For Django 1.7 migrations, see "dependencies": - https://docs.djangoproject.com/en/dev/topics/migrations/#dependencies <https://docs.djangoproject.com/en/dev/topics/migrations/#dependencies> --Fred -- 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/5426C996.4050001%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
Bob, You can control the order in which migrations run. For South, see "depends_on" and "needed_by": - http://south.readthedocs.org/en/latest/dependencies.html For Django 1.7 migrations, see "dependencies": - https://docs.djangoproject.com/en/dev/topics/migrations/#dependencies --Fred -------- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/26/14 9:58 AM, bobhaugen wrote: Andrew, thanks for the article, and the more-to-come. When you get to data migrations, you might want to cover a problem I ran into with them: when I had a data migration in the middle of a sequence of other migrations, and then later wanted to set up a new environment, which meant running all of the migrations in sequence from the beginning, the data migration was now running in the latest models.py code, not the code in which it initially worked. So it did not work any more. In particular, the data migration was a precursor to another schema migration were a field would be removed. The data migration was to move the existing data in the field-to-be-removed to a different field. So when the data migration ran in the longer sequence, the field it was trying to move data from was now gone from the code. I suspect there are a lot of other ways to shoot yourself in the foot with data migrations, so we have stopped using them and just use our own data migration scripts outside of the sequence of schema migrations. -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/9f4e1b6a-4051-478d-9a09-43318266ed7f%40googlegroups.com <https://groups.google.com/d/msgid/django-users/9f4e1b6a-4051-478d-9a09-43318266ed7f%40googlegroups.com?utm_medium=email_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/54258067.1080405%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
Sabine, I'm not sure about the new 1.7 Migrations, but with South, restarting your migrations is easy. I'm currently doing it on my project, because we have a long convoluted history of changes before and after we started using South, and have made some mistakes along the way (like editing migrations and fixtures that they use after running them -- bad idea!). Since we're at a nice stable point now, and are certain we'll never need to migrate back to an earlier version, I'm currently deleting all the old migrations and creating new clean ones that get us to our current state. Steps: - Delete all rows from south_migrationhistory table. - For each app - Delete old migration files from migrations folders - Run: python manage.py convert_to_south /appname/ to create and fake the 0001_initial.py migration. This creates a file in the migrations folder and adds row to the south_migrationhistory claiming that the migration has already been run. - For each app with models mapped to DB tables that contain data you would want to pre-load into a newly created DB (lookup values like countries, states, statuses, etc.): - Run: python manage.py datamigration /appname/ /migration_name/ to create a new migration named 0002_/migration_name/.py with empty forwards() and backwards() methods. - For each such DB table: - Run: python manage.py dumpdata --indent=4 /appname.ModelName/ > .//appname//fixtures//table_name/.default.json - Add to forwards() method: call_command("loaddata", "/table_name/") --Fred -------- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/25/14 1:11 AM, Sabine Maennel wrote: Dear Andrew, I read your article and it is great. I am really looking forward to your followups. I was hoping for something like this went I attended Django Con Europe. I struggle with the understanding the migrations the most. Usually in the early phases of development I do not want migrations to bother me since my database design just still changes too often for keeping track. I find the django admin a very useful tool to test your database design with real data and detect flaws early on. So will your followups contain advise on that? How can I restart migrations all over once my project is ready for deployment? Thanks so much for writing these very useful articles! Do you mind if I post about them in the Django user facebook user group, or do you want to do that, since I think these articles will be very helpful to most Django developers. with kind regards and keep going! Sabine Am Donnerstag, 25. September 2014 04:09:20 UTC+2 schrieb Andrew Pinkham: Hi, I am writing a series of articles based on the presentation I gave at DjangoCon US 2014. I put the first article online earlier today, and figured members of this list might be interested in the material. For all of the material: afrg.co/updj17/ <http://afrg.co/updj17/> For the article: afrg.co/updj17/a1/ <http://afrg.co/updj17/a1/> I plan to post the next three in the series on each of the coming Wednesdays. Any feedback appreciated. I hope you find the material helpful. Andrew -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/934a13d6-d5fd-4684-9bb1-e6d323778cda%40googlegroups.com <https://groups.google.com/d/msgid/django-users/934a13d6-d5fd-4684-9bb1-e6d323778cda%40googlegroups.com?utm_medium=email_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/542453B6.2070305%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Upgrading Django (to 1.7)
Andrew, Good stuff! Thanks! We're still on 1.4, but planning a move soon to 1.7. Very helpful. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/24/14 10:08 PM, Andrew Pinkham wrote: Hi, I am writing a series of articles based on the presentation I gave at DjangoCon US 2014. I put the first article online earlier today, and figured members of this list might be interested in the material. For all of the material: afrg.co/updj17/ For the article: afrg.co/updj17/a1/ I plan to post the next three in the series on each of the coming Wednesdays. Any feedback appreciated. I hope you find the material helpful. Andrew -- 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/54244DAE.9020900%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Open Django template in dialog box (not in window)
Excellent! Thanks! Now I can just point my team at it, instead of writing out the details myself. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/24/14 5:27 PM, Collin Anderson wrote: Here's the blog post, by popular demand :) http://collincode.wordpress.com/2014/09/24/jquery-ui-popup-with-django-backend/ -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/dd66d8cb-e5bc-44d9-bae4-7e6383508bc0%40googlegroups.com <https://groups.google.com/d/msgid/django-users/dd66d8cb-e5bc-44d9-bae4-7e6383508bc0%40googlegroups.com?utm_medium=email_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/542350E1.2040406%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Lightening talk ideas for a (relative) beginner?
nd check there is now one vote. choice = Choice.objects.get(pk=1) self.assertEqual(choice.votes, 1) - No. Per: - https://docs.djangoproject.com/en/1.4/topics/testing /#default-test-client it is even easier. Just: response = self.client.get('/customer/details/') - How to mock an Ajax HTTP request: def test_ajax_vote(self): c = Client() # Extra parameters to make this a Ajax style request. kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'} # A valid vote response = c.post('/polls/1/vote/', {'choice': '1',}, **kwargs) self.assertEqual(response.status_code, 200) self.assertEqual(response.content, '1') # A invalid vote - choice doesn't exist response = c.post('/polls/1/vote/', {'choice': '10',}, **kwargs) self.assertEqual(response.status_code, 200) self.assertEqual(response.content, '0') # An invalid vote - poll doesn't exist response = c.post('/polls/2/vote/', {'choice': '1',}, **kwargs) self.assertEqual(response.status_code, 404) - Selenium test cases with "LiveServerTestCase": https://docs.djangoproject.com/en/1.4/topics/testing/#live-test-server - Python Nose - Django Nose - Coverage Hope this helps! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/24/14 2:04 PM, James Brewer wrote: I want to attend a Django BarCamp in SF next weekend and BarCamp tradition is that everyone contribute in some way. Of course I will help out with set up/break down if that is needed, but I would also like to give a lightening talk. I'm fairly unfamiliar with Django at this point and I've never spoken publicly, so I am not sure what I would talk about. If anyone has any ideas that would be accessible for someone who is relatively new to Django, I would love to hear them. It doesn't have to be something I already know as I have a week to familiarize myself, but given the short timeline it should be something accessible. Happy hacking! James -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/fa483337-d783-46cb-b140-d15e986a2498%40googlegroups.com <https://groups.google.com/d/msgid/django-users/fa483337-d783-46cb-b140-d15e986a2498%40googlegroups.com?utm_medium=email_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/54230EAC.90009%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Can not include jquery in django template
Change it to: </tt><tt> --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/23/14 2:15 PM, Артём Мутерко wrote: When I try to include jQuery to my template index.html, I get an blank page. Html source code is loading but I get just white page -- 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/793a14fb-c435-4737-92b8-dcd277fb9abb%40googlegroups.com <https://groups.google.com/d/msgid/django-users/793a14fb-c435-4737-92b8-dcd277fb9abb%40googlegroups.com?utm_medium=email_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/5421C08A.3020809%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Open Django template in dialog box (not in window)
Collin, Excellent sample. Thanks! That's a nice standalone summary of how to do a popup dialog via jQuery and Ajax. Worth posting to a tips page or blog if you have such, so other people can Google it. Kamal, does this fill in the gaps for you? If not, let us know. --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/23/14 8:44 AM, Collin Anderson wrote: # popupadvance.html | Here's the worker object: {{ worker }} | # views.py | defpopupadvance(request): worker =Worker.objects.get(id=request.GET.get('worker_id') returnrender(request,'popupadvance.html',{'worker':worker}) | # urls.py | from.importviews urlpatterns =[ url('popupadvance/$',views.popupadvance) ] | |
Re: Is there anything similar to phpmyadmin
There's some really nice DB admin functionality in PyCharm. It's not open source, or even free, and it's not written in Python, but it's part of an IDE that I use (and many others here?) for developing our Python/Django code. Hope this helps! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/20/14 9:38 PM, Yuan-Liang Tang wrote: I'd like to know if there is anything/anyway similar to phpmyadmin for managing MySQL DBs in a Django project or in the Python environment. Any suggestions? django-mysql-manage seems to be dead. https://pypi.python.org/pypi/django-mysql-manager/0.1.2 -- 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/5420960C.509%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Open Django template in dialog box (not in window)
Kamal, I do this via the jQueryUI "dialog" widget. Works fine with Django or any other back end code. Just make an Ajax call to the URL to get the HTML, instead of passing the URL to window.open(), and pass the HTML to the jQuery dialog widget. See: http://jqueryui.com/dialog/ --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/21/14 5:16 AM, Kamal Kaur wrote: I'm trying to open a Django template using JS as a popup. Actually I've done this. But it opens a separate window but I want a clean dialog box or simply a division instead of that window. Using window.open method, clicking on the "Advance", "popitup" function runs. Here's the code: http://pastie.org/9580729 The popitup function takes the passed url and opens a window containing template sent by the view. But how to open a dialog box instead? I've tried using AJAX, like told in the link below but yet unable to do: http://stackoverflow.com/questions/19267531/how-to-open-jquery-ui-dialog-with-ajax-request -- 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/5420958B.3090905%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: What't the best way to track created by and modified by in Django 1.7?
Russ, Thanks for another classic Russ Magee answer! As usual, you are succinct, accurate, relevant, prompt, specific, and very helpful. There are an amazing number of helpful people on this list, so the bar is already pretty high, but you continue to raise it. Keep up the good work! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/16/14 7:29 PM, Russell Keith-Magee wrote: Hi Michael, There's nothing built into Django 1.7, or any previous version; however, it's also not hard to implement yourself. All you have to do is override the save method on your model, and in that method, and store whatever audit information you want to record. So, for example, if you want to just keep a track of the person who most recently edited a record, you could do something like: class MyModel(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL) ... (other fields here) def save(self, user, *args, **kwargs): return super(MyModel, self).save(*args, **kwargs) Then, every time you save an instance of MyModel, you need to pass in the user who saved the record; e.g.: MyModel.objects.save(request.user) If you want to record a full audit record of every edit, you could do that too; you just create a secondary model type, and every time you save your base model, you create an instance of the secondary type as well. If you don't want to roll it yourself (or your use case is fairly generic), you might find some pre-rolled django apps that can help: https://www.djangopackages.com/grids/g/versioning/ I can't speak from experience on any of them, but they exist, and you might find that one of them meets your needs. Yours, Russ Magee %-) On Tue, Sep 16, 2014 at 10:55 AM, Michael Martin <mikemartin...@gmail.com <mailto:mikemartin...@gmail.com>> wrote: Hello, I am sure that I am not the first person to ask this question, but I want to know the best way to track who created or modified a record in my settings defined within models.py. Is there something new and great added to 1.7 or something that already exists in older versions? Thank you 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/CAD0urK3rTvDdkRnTZcsv_b45pV734JApGFAiY3%2BqFO_%3D1vWkzA%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAD0urK3rTvDdkRnTZcsv_b45pV734JApGFAiY3%2BqFO_%3D1vWkzA%40mail.gmail.com?utm_medium=email_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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/CAJxq849xiO%2B51BirpKCWv1EiMKDeuTo1-t26MVWnM1vmvmh7zg%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAJxq849xiO%2B51BirpKCWv1EiMKDeuTo1-t26MVWnM1vmvmh7zg%40mail.gmail.com?utm_medium=email_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/541987B7.60801%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: Django 1.5.1 - Mysql - Setting
Ahmed, For connecting Django to MySQL, I use MySQL-python, installed via pip as: pip install MySQL-python My settings file contains: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME' : 'name of our database', 'USER' : 'username to access the database', 'PASSWORD' : 'password to access the database', # Required for Windows; Harmless (same as default) for Linux 'HOST' : '127.0.0.1', # Required for Windows; Harmless (same as default) for Linux 'PORT' : '3306', }, --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/11/14 9:34 AM, Muhammad Ahmed wrote: Hi, I have been trying to launch my Django Model using a tutorial. but unfortunately the tutorial is about Django 1.1. Kindly guide me that what configuration (in setting.py) will be required if I use Python27 / Django 1.5.1 with Mysql. please also guide towards the appropriate "MySql Adoptor" for Django 1.5.1. Thanks in advance :) 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 <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/881464cf-d4aa-4934-9915-3830ebafd4e6%40googlegroups.com <https://groups.google.com/d/msgid/django-users/881464cf-d4aa-4934-9915-3830ebafd4e6%40googlegroups.com?utm_medium=email_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/5411CEF6.7090702%40bristle.com. For more options, visit https://groups.google.com/d/optout.
Re: How quickly do Django unit tests run?...
Benjamin, Thanks for the followup! I've been using MySQL. For normal (non-testing) use, it seems fast enough on our development machines (Mac laptop) and in our TEST and PROD environments (Linux on AWS). Page loads are typically sub-second. It was only when I used the command: % python manage.py test that I saw the long delays. I assume the delays are related to the default stuff happening in setUp() and tearDown() for each test. Still happens with SQLite, I assume. Just much faster. I may step through in the debugger sometime to confirm this. I read the slides at the URL you gave me. Good info! For now, our site is fast enough and is not expected to scale dramatically, but we do have a JIRA ticket for improving performance if/when we need it. So far, I've tossed a bunch of idea in there, but not needed to do any of them: profiling, caching, file minimization and packaging, tuning mix of Ajax vs full page loads, etc. I've added this URL to the JIRA ticket for further consideration if/when we need it. Is there a more current version of the slides? This copy was presented to OSCON in 2011, and refers to Django 1.3 as new. Here are some notes I added to our JIRA ticket along with this URL for if/when we need it: - Beware ManyToManyField - Beware over-indexing - Look into pg_stat_activity (PostgreSQL), or MySQL equivalent - Prefer NULL to DEFAULT when migrating a large table - Or do it 3 steps shown to avoid long lock on DB table - Consider direct SQL sometimes instead of Django ORM - Beware iterating over large querysets - Beware filters with "__in" that match more than 10-15 items - Beware OFFSET - Use replication or a backup DB copy for large reporting operations - Don't use DB as Celery job queue - Use @commit_on_success or TransactionMiddleware - Leave autocommit on (even thought it seems wrong) - Modify tables in a fixed order. Same for rows of a table. - Pass QuerySets directly to templates (to allow lazy evaluation) - Cache templates and fragments - Cache expensive query results - Pool DB connections if over 100 concurrent users - Use db_routers.py to write primary DB, read replica DB Thanks again! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 9/2/14 5:37 AM, Benjamin Scherrey wrote: What DB were you testing on before? Unless you're going to launch this thing into production with SQLite I would recommend you switch back to whatever DB you're planning for production and test with it as you probably have some serious performance considerations to work out asap. If they're architectural rather than configuration-based issues then the sooner you recognize and repair them the better. If you happen to be using Postgres out of the box with no changes from your distro's base install then it's going to be real slow because Postgres' default config is to use as few resources as possible which necessarily makes performance less than optimal. It's not hard to make Postgres a very fast DB but you better start using it right to make things go well when you launch. See this article for some good advice: http://thebuild.com/presentations/unbreaking-django.pdf It's a bit dated and newer versions of Django improve on the old implementation of the ORM but it's recommendations and things to look out for are sound. You need to measure your actual performance and act accordingly. Good luck, -- Ben On Sat, Aug 30, 2014 at 2:05 AM, Fred Stluka <f...@bristle.com <mailto:f...@bristle.com>> wrote: Benjamin, I solved my problem. I switched to SQLite for testing and now run 500+ tests in 30 secs instead of 75 minutes. Much better! Thanks for your help! --Fred -------- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/27/14 5:22 PM, Benjamin Scherrey wrote: Postgres. best of luck. On Thu, Aug 28, 2014 at 4:16 AM, Fred Stluka <f...@bristle.com <mailto:f...@bristle.com>> wrote: Ben, Thanks! That's exactly the kind of ballpark figure I wanted. Sounds like I should be expecting roughly 5-10 tests/sec, plus maybe 10-20 secs DB setup/migration. I'm currently seeing 1 test per 7-9 secs, plus 50-60 secs DB setup time (syncdb, not South, since I'm setting SOUTH_TESTS_MIGRATE = False).
Re: How quickly do Django unit tests run?...
Benjamin, I solved my problem. I switched to SQLite for testing and now run 500+ tests in 30 secs instead of 75 minutes. Much better! Thanks for your help! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/27/14 5:22 PM, Benjamin Scherrey wrote: Postgres. best of luck. On Thu, Aug 28, 2014 at 4:16 AM, Fred Stluka <f...@bristle.com <mailto:f...@bristle.com>> wrote: Ben, Thanks! That's exactly the kind of ballpark figure I wanted. Sounds like I should be expecting roughly 5-10 tests/sec, plus maybe 10-20 secs DB setup/migration. I'm currently seeing 1 test per 7-9 secs, plus 50-60 secs DB setup time (syncdb, not South, since I'm setting SOUTH_TESTS_MIGRATE = False). Yeah, something must be wrong here. I'm running 100X slower than expected. BTW, are those numbers using SQLite, MySQL, PostgreSQL, other? So far, I'm using MySQL, running locally on a pretty fast Mac laptop. I'm planning to switch to SQLite for testing, to make it run faster, but haven't gotten that to work yet. My next steps will be try again with SQLite, and perhaps get the test suite to run in the PyCharm debugger so I can step through the code and see where all the time is going. Thanks again! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/27/14 4:21 PM, Benjamin Scherrey wrote: Clearly that depends on what your tests do. One of our projects runs ~400 tests in about a minute. If your tests do much database access or have complex setUp/tearDown then that's not going to be as fast of course. The Django 1.7 project I'm working on at the moment takes a total of 12.7 seconds to complete but most of that time is the setup and migrations execution for the test db. Once it starts the 36 tests I have now complete in 3.58 seconds in verbose mode with full branch coverage turned on. coverage run --branch --source="partner,item,utils,importing,channel" manage.py test --verbosity=2 && coverage report --show-missing -- Ben On Thu, Aug 28, 2014 at 3:13 AM, Fred Stluka <f...@bristle.com <mailto:f...@bristle.com>> wrote: Benjamin, OK, Thanks! So roughly how fast would you expect? Hundreds of trivial tests per minute? Thousands per minute? Thanks! --Fred ---- Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 8/27/14 3:57 PM, Benjamin Scherrey wrote: Something's definitely wrong. Except for the initial setup for the test run (in 1.7 migrations run each time for example), the individual tests should execute as fast as any normal python unit test. On Wed, Aug 27, 2014 at 9:06 PM, Fred Stluka <f...@bristle.com <mailto:f...@bristle.com>> wrote: How quickly do Django unit tests run? Mine are taking 7-9 seconds each, even for trivial tests like: self.assertEqual(1 + 1, 2) that are all in the same test class of the same app. Is this typical? Or do I have something misconfigured. Thanks! --Fred -- 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 <mailto:django-users%2bunsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://gro