Re: Automating deployments
I've got SaltStack setup to deploy Ubuntu+Nginx+uWSGI+Postgresql+memcache pretty easily. Pulls Django projects from Git, pip installs from requirements file. It is a lot less complicated than Puppet/Chef in my opinion. Just my $.03 cents On Friday, February 1, 2013 4:28:45 PM UTC-8, Marc Aymerich wrote: > > Hi, > I'm thinking about the best way to provide automatic deployment for > the Django project I'm working on. Its a pretty big one and has lots > of dependencies, lots of SO packages, Celeryd and other daemons, SO > tweaks... and also several people will need to have installed it on > their servers (they are sysadmins, not Django developers), Therefore I > want to automate as much as possible the installation and updating > processes, to minimize their pain and also because of having > homogeneity. > > As I've been a sysadmin myself for many years I've already written > some bash scripts that automates all the deployment. But in order to > make it more 'natural' I'm planning to integrate those scripts within > the Django project as management commands. > > To illustrate my ultimate goal this is how I imagine the workflow: > > sudo pip install django-my_project > my_project-admin.sh clone project_name path > > sudo python manage.py installrequirements > sudo python manage.py setuppostgres > python manage.py syncdb > python manage.py migrate > python manage.py createsuperuser > > sudo python manage.py setupapache > python manage.py collectstatic > sudo python manage.py setupceleryd > sudo python manage.py createtincserver > python manage.py updatetincd > sudo python manage.py setupfirmware > python manage.py loaddata firmwareconfig > > sudo python manage.py restartservices > > > Any thought on this? How do you automate your deployments? I heard > about fabric lots of times but never used it. Will fabric be helpful > in my case? Does it has any advantage for writing my own scripts? Or > maybe there are already some existing tools for automating deployment > of most common services like Apache, celeryd ..,? > > Many thanks! > br > -- > Marc > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Upload multiple files using Ajax
I created this https://github.com/esacteksab/django-jquery-file-upload which is just jQuery-File-Upload ported to Django. It was a fork of someone elses' project that addressed my needs (support for models) On Wednesday, January 23, 2013 2:18:01 AM UTC-8, psjinx wrote: > > You can use https://github.com/blueimp/jQuery-File-Upload. > > You can use a view function similar to following. Here I have 3 models > - Project, Album and Flat > > A Project can have multiple albums. > An Album can have multiple Flats > A Flat has an ImageField, caption as TextField and a ForeignKey to Album. > > def upload_flat(request, project_slug, album_pk): > project = get_object_or_404(Project, slug=project_slug) > album = get_object_or_404(Album, pk=album_pk) > if request.method == 'GET': > flats = album.flat_set.all() > return render(request, "upload.html", {"project": project, > "album": album, "flats": flats}) > > if request.method == "POST": > form = FlatForm(request.POST, request.FILES) > if form.is_valid(): > flat = form.save(commit=False) > flat.user = request.user > flat.album = album > flat.save() > > data = { > "files": > [{ > "url": flat.image.url, > "thumbnail_url": flat.thumbnail.url, > "name": flat.image.name, > "type": "image/jpeg", > "size": flat.image.size, > "delete_url": reverse("delete_flat", args=[flat.pk]), > "delete_type": "DELETE", > "description": flat.description > }] > } > return HttpResponse(simplejson.dumps(data)) > return render(request, "upload.html", {}) > > -- > Pankaj Singh > http://about.me/psjinx > > > On Wed, Jan 23, 2013 at 1:22 AM, Mengu > > wrote: > > i used jquery.form plugin back in the day. it worked great but it had > > issues with large files. > > > > check out http://malsup.com/jquery/form/progress3.html and > > http://malsup.com/jquery/form/ > > > > On Jan 22, 6:05 pm, Andre Lopes wrote: > >> Hi, > >> > >> I need to develop a form to upload multiple files. > >> > >> I was thinking in using an Ajax uploader. I have google some options > >> but there are to many and I don't know which one to choose. > >> > >> Any recommendations about this subject? > >> > >> Best Regards, > >> André. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Django users" group. > > To post to this group, send email to > > django...@googlegroups.com. > > > To unsubscribe from this group, send email to > django-users...@googlegroups.com . > > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ud8ZRVWjE4AJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Postgresql Index & expensive queries [n00bie alert]
Looking further at Postgresql, what's interesting. Is it creates an 'id' column and appends '_id' to what is assumed to be the id field (if none is specified). Also, it appears the magic may have already created the indexes: django_db=# \d press_page Table "public.press_page" Column | Type | Modifiers ++- id | integer| not null default nextval('press_page_id_seq'::regclass) article_id | character varying(255) | not null page | character varying(100) | pgnumber | smallint | not null Indexes: "press_page_pkey" PRIMARY KEY, btree (id) "press_page_article_id" btree (article_id) "press_page_article_id_like" btree (article_id varchar_pattern_ops) Check constraints: "press_page_pgnumber_check" CHECK (pgnumber >= 0) Foreign-key constraints: "press_page_article_id_fkey" FOREIGN KEY (article_id) REFERENCES press_article(publication) DEFERRABLE INITIALLY DEFERRED On Friday, October 19, 2012 8:16:25 PM UTC-7, Barry Morrison wrote: > > I've got a pretty expensive query...Wondering if I can't speed things up > in regards to Postgresql. > > Here is the model: [1] http://dpaste.org/JmEeQ/ > > Here is the sql statement: [2] http://dpaste.org/GbfAJ/ > > Here is the template: [3] http://dpaste.org/vxRs4/ > > Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/ > > Total Postgresql/SQL n00b, so this may be a stupid statement. I'm > wondering if an index on '"press_page"."article_id"' wouldn't speed things > up a bit? > > In dev, I don't have the amount of data that exists in production, so I > can't easily/realistically recreate this scenario. > > FWIW, I'm running: > >- Django 12.04 >- Postgresql 9.1.5 >- Django 1.4.1 > > I'm using memcache on the view to cache it, it helped take page load down > significantly, but I was wondering if there wasn't something I could do > from the DB side of things since I know it's this query that is taking the > page so long to load. > > Thanks! > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_3B-jlev3KsJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Postgresql Index & expensive queries [n00bie alert]
Here is what exists in Dev re: Query Plan from debug toolbar: QUERY PLAN Sort (cost=8.28..8.28 rows=1 width=740)Sort Key: pgnumber -> Index Scan using press_page_article_id_like on press_page (cost=0.00..8.27 rows=1 width=740)Index Cond: ((article_id)::text = 'Test'::text) On Friday, October 19, 2012 10:26:01 PM UTC-7, Sam Lai wrote: > > On 20 October 2012 14:16, Barry Morrison > > wrote: > > I've got a pretty expensive query...Wondering if I can't speed things up > in > > regards to Postgresql. > > > > Here is the model: [1] http://dpaste.org/JmEeQ/ > > > > Here is the sql statement: [2] http://dpaste.org/GbfAJ/ > > > > Here is the template: [3] http://dpaste.org/vxRs4/ > > > > Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/ > > > > Total Postgresql/SQL n00b, so this may be a stupid statement. I'm > wondering > > if an index on '"press_page"."article_id"' wouldn't speed things up a > bit? > > Are you using the django-debug-toolbar? If not, consider using it - > once installed, visit that page in your browser, open up the toolbar, > select SQL queries, find the offending query (processing times are > shown), and click the Explain link. That will tell you what PostgreSQL > is doing, and how performance can be improved. > > Alternately, fire up a terminal and launch the psql database shell. > Type in the query ([2]) but prefix it with the word EXPLAIN. This will > tell you what PostgreSQL is doing to process that query. If you see > Seq Scan in there, consider adding the index. Remember to run the SQL > statement - ANALYZE press_page - after you create the index so it can > update the internal statistics that it uses to decide how to process a > query. > > You can also do this within the PGadmin application if that makes things > easier. > > > In dev, I don't have the amount of data that exists in production, so I > > can't easily/realistically recreate this scenario. > > You really need to have a good subset (considering both the number of > records, and the distribution of values within each record) if it is > not possible to have a copy of the production database. PostgreSQL > performs analysis on the data itself and uses those statistics to > decide how to process the query (whether to use an index, scan > sequentially etc.). If you dev database is not a good representation, > then the results you'll see with your dev database, and hence your > improvements, may have no effect or a negative effect in production. > > I do believe having an index on press_page.article_id is a good idea > though. Also, are you really showing every article in that view? > Consider using a limit so you're not retrieving all the records, only > to use the first 10. The pagination features in Django may be useful > here. Finally, an index on press_page.pgnumber may also be worth > considering so PostgreSQL may be able to avoid the sorting step (an > index of the default type is sorted by the field in ascending order). > > > FWIW, I'm running: > > > > Django 12.04 > > Postgresql 9.1.5 > > Django 1.4.1 > > > > I'm using memcache on the view to cache it, it helped take page load > down > > significantly, but I was wondering if there wasn't something I could do > from > > the DB side of things since I know it's this query that is taking the > page > > so long to load. > > > > Thanks! > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Django users" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/django-users/-/U92OjnMgEggJ. > > To post to this group, send email to > > django...@googlegroups.com. > > > To unsubscribe from this group, send email to > > django-users...@googlegroups.com . > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/vAyxjov5qK8J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Postgresql Index & expensive queries [n00bie alert]
prefetch-related is awesome! Thank you for that. Thanks! Barry On Fri, Oct 19, 2012 at 11:54 PM, Xavier Ordoquy wrote: > Hi, > > As Samuel said, the first step is to install Django Debug Toolbar to see > what's going on with your queries. > Then you'll probably be interested in > https://docs.djangoproject.com/en/1.4/ref/models/querysets/#prefetch-related > > Regards, > Xavier Ordoquy, > Linovia. > > Le 20 oct. 2012 à 05:16, Barry Morrison a écrit : > > I've got a pretty expensive query...Wondering if I can't speed things up > in regards to Postgresql. > > Here is the model: [1] http://dpaste.org/JmEeQ/ > > Here is the sql statement: [2] http://dpaste.org/GbfAJ/ > > Here is the template: [3] http://dpaste.org/vxRs4/ > > Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/ > > Total Postgresql/SQL n00b, so this may be a stupid statement. I'm > wondering if an index on '"press_page"."article_id"' wouldn't speed things > up a bit? > > In dev, I don't have the amount of data that exists in production, so I > can't easily/realistically recreate this scenario. > > FWIW, I'm running: > >- Django 12.04 >- Postgresql 9.1.5 >- Django 1.4.1 > > I'm using memcache on the view to cache it, it helped take page load down > significantly, but I was wondering if there wasn't something I could do > from the DB side of things since I know it's this query that is taking the > page so long to load. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/U92OjnMgEggJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Postgresql Index & expensive queries [n00bie alert]
I am using Django Debug Toolbar locally for development. That is where I copied & pasted the SQL from. Even if I had a complete set of data for postgresql, my local machine is an 8-core, 16GB of RAM, with solid state hard drives. A LOT different than my 2CPU/1GB RAM/spindle disk VPS. I guess what I need to do is clone my VPS off, firewall the crap out of it and run Django Debug Toolbar on that...giving me a more accurate idea of what's going on. Thanks for the response. On Fri, Oct 19, 2012 at 10:25 PM, Sam Lai wrote: > On 20 October 2012 14:16, Barry Morrison wrote: > > I've got a pretty expensive query...Wondering if I can't speed things up > in > > regards to Postgresql. > > > > Here is the model: [1] http://dpaste.org/JmEeQ/ > > > > Here is the sql statement: [2] http://dpaste.org/GbfAJ/ > > > > Here is the template: [3] http://dpaste.org/vxRs4/ > > > > Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/ > > > > Total Postgresql/SQL n00b, so this may be a stupid statement. I'm > wondering > > if an index on '"press_page"."article_id"' wouldn't speed things up a > bit? > > Are you using the django-debug-toolbar? If not, consider using it - > once installed, visit that page in your browser, open up the toolbar, > select SQL queries, find the offending query (processing times are > shown), and click the Explain link. That will tell you what PostgreSQL > is doing, and how performance can be improved. > > Alternately, fire up a terminal and launch the psql database shell. > Type in the query ([2]) but prefix it with the word EXPLAIN. This will > tell you what PostgreSQL is doing to process that query. If you see > Seq Scan in there, consider adding the index. Remember to run the SQL > statement - ANALYZE press_page - after you create the index so it can > update the internal statistics that it uses to decide how to process a > query. > > You can also do this within the PGadmin application if that makes things > easier. > > > In dev, I don't have the amount of data that exists in production, so I > > can't easily/realistically recreate this scenario. > > You really need to have a good subset (considering both the number of > records, and the distribution of values within each record) if it is > not possible to have a copy of the production database. PostgreSQL > performs analysis on the data itself and uses those statistics to > decide how to process the query (whether to use an index, scan > sequentially etc.). If you dev database is not a good representation, > then the results you'll see with your dev database, and hence your > improvements, may have no effect or a negative effect in production. > > I do believe having an index on press_page.article_id is a good idea > though. Also, are you really showing every article in that view? > Consider using a limit so you're not retrieving all the records, only > to use the first 10. The pagination features in Django may be useful > here. Finally, an index on press_page.pgnumber may also be worth > considering so PostgreSQL may be able to avoid the sorting step (an > index of the default type is sorted by the field in ascending order). > > > FWIW, I'm running: > > > > Django 12.04 > > Postgresql 9.1.5 > > Django 1.4.1 > > > > I'm using memcache on the view to cache it, it helped take page load down > > significantly, but I was wondering if there wasn't something I could do > from > > the DB side of things since I know it's this query that is taking the > page > > so long to load. > > > > Thanks! > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/django-users/-/U92OjnMgEggJ. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Postgresql Index & expensive queries [n00bie alert]
I've got a pretty expensive query...Wondering if I can't speed things up in regards to Postgresql. Here is the model: [1] http://dpaste.org/JmEeQ/ Here is the sql statement: [2] http://dpaste.org/GbfAJ/ Here is the template: [3] http://dpaste.org/vxRs4/ Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/ Total Postgresql/SQL n00b, so this may be a stupid statement. I'm wondering if an index on '"press_page"."article_id"' wouldn't speed things up a bit? In dev, I don't have the amount of data that exists in production, so I can't easily/realistically recreate this scenario. FWIW, I'm running: - Django 12.04 - Postgresql 9.1.5 - Django 1.4.1 I'm using memcache on the view to cache it, it helped take page load down significantly, but I was wondering if there wasn't something I could do from the DB side of things since I know it's this query that is taking the page so long to load. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/U92OjnMgEggJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is the logic in my model correct? Best-case?
I added this instead to the forms: class ShopProductDistributionForm(ModelForm): """A partial form to allow the association to distributors""" class Meta: model = ProductDistribution fields = ['productID', 'distributorID'] def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.layout = Layout( Field('productID'), Field('distributorID', type='radio'),) super(ShopProductDistributionForm, self).__init__(*args, **kwargs) The problem is, it creates drop-down/select fields instead of allowing me to create radio buttons. I guess I need to figure out how to parse through the distributors. On Thursday, September 6, 2012 11:59:13 AM UTC-7, Barry Morrison wrote: > > So I created models: http://dpaste.org/D4r7L/ forms: > http://dpaste.org/KMShj/ the output of the form generates: > http://dpaste.org/ua41K/ > > The form creates text areas to enter distributor name/url. What I'd like > on this form is a set of radio buttons to allow a true/false if the product > is distributed by a specific distributor. > > Do I need to create another field on the Distributor model and set a > boolean field/widget? > > Thanks, > Barry > > On Monday, September 3, 2012 8:45:07 PM UTC-7, Dennis Lee Bieber wrote: >> >> On Mon, 3 Sep 2012 18:51:45 -0700 (PDT), Barry Morrison >> declaimed the following in >> gmane.comp.python.django.user: >> >> > Model: http://dpaste.org/dqwmc/ >> > >> > There can be many products. >> >> Okay, a table of products... >> >> > There can be many distributors. >> >> and a table of distributors >> >> > A product could have none or more distributors. >> >> Normal intersect table behavior >> >> > A distributor could only distribute a single product once. >> >> This clause is unclear... >> >> > A distributor could distribute all products. >> > >> >> This clause is irrelevant -- it doesn't restrict the data (vs if >> you >> had some requirement that a distributor carrying products a..m is not >> allowed to carry product n) >> >> > I imagine a form (admin side): >> > >> > Product Name: >> > Product Description: >> > Product Image: >> > >> > Distributor 1: Radio Field/Boolean >> > Distributor 2: Radio Field/Boolean >> > Etc. etc. >> > >> > For some reason I can't wrap my head around this. >> >> Your model (per the linked web page) current ties a product >> instance >> to ONE DISTRIBUTOR ONLY. >> >> In pseudo-SQL, you have defined >> >> create table Distributor >> ( >> IDinteger autoincrement primary key,#django adds >> this >> Namevarchar(255) not null,#it is redundant to >> preface fields >> >> #with >> "distributor" when they are >> #IN >> the table Distributor >> URLvarchar(255) null,#URL type is django >> operation >> Productboolean#this field is >> meaningless as >> >> #there >> is no product referenced >> >> #here >> >> ); >> >> create table Product >> ( >> IDinteger autoincrement primary key, >> Namevarchar(255) not null, >> Descriptionblob,#or some such large text field >> Imagevarchar(255) null,#image type is django >> usage >> Distributorinteger foreign key references Distributor >> (ID), >> #this basically says that this product can have >> #only ONE distributor >> ); >> >> What you really need is not a one-to-many link (one distributor >> can >> have many products, but each product can only have one distributor) but >> a many-to-many linkage. >> >> create table Distributor >> ( >> ID
Re: Is the logic in my model correct? Best-case?
So I created models: http://dpaste.org/D4r7L/ forms: http://dpaste.org/KMShj/ the output of the form generates: http://dpaste.org/ua41K/ The form creates text areas to enter distributor name/url. What I'd like on this form is a set of radio buttons to allow a true/false if the product is distributed by a specific distributor. Do I need to create another field on the Distributor model and set a boolean field/widget? Thanks, Barry On Monday, September 3, 2012 8:45:07 PM UTC-7, Dennis Lee Bieber wrote: > > On Mon, 3 Sep 2012 18:51:45 -0700 (PDT), Barry Morrison > > declaimed the following in > gmane.comp.python.django.user: > > > Model: http://dpaste.org/dqwmc/ > > > > There can be many products. > > Okay, a table of products... > > > There can be many distributors. > > and a table of distributors > > > A product could have none or more distributors. > > Normal intersect table behavior > > > A distributor could only distribute a single product once. > > This clause is unclear... > > > A distributor could distribute all products. > > > > This clause is irrelevant -- it doesn't restrict the data (vs if > you > had some requirement that a distributor carrying products a..m is not > allowed to carry product n) > > > I imagine a form (admin side): > > > > Product Name: > > Product Description: > > Product Image: > > > > Distributor 1: Radio Field/Boolean > > Distributor 2: Radio Field/Boolean > > Etc. etc. > > > > For some reason I can't wrap my head around this. > > Your model (per the linked web page) current ties a product > instance > to ONE DISTRIBUTOR ONLY. > > In pseudo-SQL, you have defined > > create table Distributor > ( > IDinteger autoincrement primary key,#django adds > this > Namevarchar(255) not null,#it is redundant to > preface fields > #with > "distributor" when they are > #IN > the table Distributor > URLvarchar(255) null,#URL type is django > operation > Productboolean#this field is > meaningless as > > #there > is no product referenced > #here > > ); > > create table Product > ( > IDinteger autoincrement primary key, > Namevarchar(255) not null, > Descriptionblob,#or some such large text field > Imagevarchar(255) null,#image type is django usage > Distributorinteger foreign key references Distributor > (ID), > #this basically says that this product can have > #only ONE distributor > ); > > What you really need is not a one-to-many link (one distributor > can > have many products, but each product can only have one distributor) but > a many-to-many linkage. > > create table Distributor > ( > IDinteger autoincrement primary key,#django adds > this > Namevarchar(255) not null, > URLvarchar(255) null, > ); > > create table Product > ( > IDinteger autoincrement primary key, > Namevarchar(255) not null, > Descriptionblob,#or some such large text field > Imagevarchar(255) null,#image type is django usage > ); > > create table ProductDistribution > ( > IDinteger autoincrement primary key, > ProductIDinteger foreign key references Product(ID), > DistributorIDinteger foreign key references > Distributor(I), > unique (ProductID, DistributorID) > ); > > As I understand it, Django will create the equivalent of > ProductDistribution when you declare a many-to-many relationship in one > of the parent tables. > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlf...@ix.netcom.com > HTTP://wlfraed.home.netcom.com/ > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/g6qoFbbFggIJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is the logic in my model correct? Best-case?
That's exactly what I needed. Thank you *very* much! On Mon, Sep 3, 2012 at 8:44 PM, Dennis Lee Bieber wrote: > On Mon, 3 Sep 2012 18:51:45 -0700 (PDT), Barry Morrison > declaimed the following in > gmane.comp.python.django.user: > > > Model: http://dpaste.org/dqwmc/ > > > > There can be many products. > > Okay, a table of products... > > > There can be many distributors. > > and a table of distributors > > > A product could have none or more distributors. > > Normal intersect table behavior > > > A distributor could only distribute a single product once. > > This clause is unclear... > > > A distributor could distribute all products. > > > > This clause is irrelevant -- it doesn't restrict the data (vs if > you > had some requirement that a distributor carrying products a..m is not > allowed to carry product n) > > > I imagine a form (admin side): > > > > Product Name: > > Product Description: > > Product Image: > > > > Distributor 1: Radio Field/Boolean > > Distributor 2: Radio Field/Boolean > > Etc. etc. > > > > For some reason I can't wrap my head around this. > > Your model (per the linked web page) current ties a product > instance > to ONE DISTRIBUTOR ONLY. > > In pseudo-SQL, you have defined > > create table Distributor > ( > ID integer autoincrement primary key, #django adds this > Namevarchar(255) not null, #it is redundant to preface fields > > #with "distributor" when they are > > #IN the table Distributor > URL varchar(255) null, #URL type is django > operation > Product boolean #this field is meaningless as > > #there is no product referenced > > #here > ); > > create table Product > ( > ID integer autoincrement primary key, > Namevarchar(255) not null, > Description blob, #or some such large text field > Image varchar(255) null, #image type is django usage > Distributor integer foreign key references Distributor (ID), > #this basically says that this product can have > #only ONE distributor > ); > > What you really need is not a one-to-many link (one distributor can > have many products, but each product can only have one distributor) but > a many-to-many linkage. > > create table Distributor > ( > ID integer autoincrement primary key, #django adds this > Namevarchar(255) not null, > URL varchar(255) null, > ); > > create table Product > ( > ID integer autoincrement primary key, > Namevarchar(255) not null, > Description blob, #or some such large text field > Image varchar(255) null, #image type is django usage > ); > > create table ProductDistribution > ( > ID integer autoincrement primary key, > ProductID integer foreign key references Product(ID), > DistributorID integer foreign key references Distributor(I), > unique (ProductID, DistributorID) > ); > > As I understand it, Django will create the equivalent of > ProductDistribution when you declare a many-to-many relationship in one > of the parent tables. > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Is the logic in my model correct? Best-case?
Model: http://dpaste.org/dqwmc/ There can be many products. There can be many distributors. A product could have none or more distributors. A distributor could only distribute a single product once. A distributor could distribute all products. I imagine a form (admin side): Product Name: Product Description: Product Image: Distributor 1: Radio Field/Boolean Distributor 2: Radio Field/Boolean Etc. etc. For some reason I can't wrap my head around this. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/HZpGeOzwSvEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: To Use or Not to Use the admin backend
My $.02 cents. It's great to have around while you're working, but my n00b experience taught me it left a lot to be desired so I rolled my own for the last two projects I built. FWIW, a local dev gave this quick presentation, and they did an incredible job on hacking the default admin https://speakerdeck.com/u/pamelafox/p/django-admin-widgetry-and-witcherybut she has also said that she's working on a custom admin So my advice. Use it as the tool that it is. Build what it can't do, don't spend more time on it than you have to. On Monday, September 3, 2012 8:38:24 AM UTC-7, Frankline wrote: > > Hi, > > I'm creating a site in Python/Django and feel that the admin backend, as > good as it is, may not be a one-fit-for-all situations. > > My question is this: > > Have any of you ever had a need to have a custom admin backend? > > In what example situations would one create his/her own admin backend > rather than using the default admin panel that ships with Django? > > What are the disadvantages of rewriting your own backend? > > Regards, > Frank > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/edKRzxuuHaIJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Not sure how to describe issue/behavior with Form -- so here's code & YouTube video
Serge, Thank you. #92 is for the crispy form. The crispy-form is the actual form, but the form is using a WYSIWYG editor http://redactorjs.com/ and when I go to browse for an image it calls url 'photo-uploads' which calls the function 'upload_photos' in the view. That view is necessary for redactor.js to get the image(s) from it's API via json, so I understand why the view creates the object, but doing so, it creates an empty field in the database. I had separated the models, so I had an Article model and an ArticleImage model, but then redactor.js failed to work (unsure how to create the relationship in the crispy form or any form for that matter). Thanks, Barry On Fri, Aug 24, 2012 at 3:00 PM, Sergiy Khohlov wrote: > Hello Barry ! > I would like to say that your are not novice. now and your code is > really clear. > Could you please move string #92 up ? super should be called before > other field initialization. > look like your prev activity is stored after init process and those > data is saved at the save operation. > try to print form to log after pressing cancel button > > thanks , serge > > 2012/8/25 Barry Morrison : > > For ease of use, let's take the cancel out of the equation perhaps. > > > > Url to create a new News Event: > > ### Create News Article > > url(r'^account/news/add/$', login_required(CreateView.as_view( > > model=NewsArticle, > > form_class=NewsForm, > > success_url=("/account/news"), > > template_name="account/news_admin.html")), > > name="admin-add-news"), > > > > > > Url that gets called when I chose to insert an image into the WYSIWYG > editor > > (and calls 'upload_photos' that has the NewsArticle.objects.create()) > > > > ### Redactor.js WYSIWYG Editor > > ### > > url(r"^uploads/$", "web_site.News.views.upload_photos", > > name="upload_photos"), > > url(r"^recent/$", "web_site.News.views.recent_photos", > > name="recent_photos"), > > > > and the views themselves: > > > > @csrf_exempt > > @require_POST > > @login_required > > def upload_photos(request): > > images = [] > > for f in request.FILES.getlist("file"): > > obj = NewsArticle.objects.create(upload=f, is_image=True) > > > > images.append({"filelink": obj.upload.url}) > > return HttpResponse(json.dumps(images), mimetype="application/json") > > > > > > @login_required > > def recent_photos(request): > > images = [ > > {"thumb": obj.upload.url, "image": obj.upload.url} > > for obj in > > NewsArticle.objects.filter(is_image=True).order_by("-date_created")[:20] > > ] > > return HttpResponse(json.dumps(images), mimetype="application/json") > > > > > > I've tried to set a .save(commit=False) on obj -- that doesn't work. > > > > I realize the behavior is call 'upload_photos' and it'll create the > object > > in the database, but on any other event other than submission of the > form, I > > want that object to no longer exist. I guess I want it to ONLY get > created > > upon form submission. > > > > > > > > On Friday, August 24, 2012 3:01:32 AM UTC-7, Tom Evans wrote: > >> > >> On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison > >> wrote: > >> > Code: http://dpaste.org/az8Nb/ > >> > Video http://www.youtube.com/watch?v=XFSb044UkPs&feature=youtu.be > >> > > >> > so first action, I click + which adds new, hitting cancel, takes me > back > >> > to > >> > the view displaying all the news events > >> > next action, I hit + again, adds new news event...this time I browse > for > >> > an > >> > image, again, I click cancel, takes me back to the view of all news > >> > events, > >> > but you see now an empty news event has been created > >> > next action, I hit + again, add a new image, hit submit. success_url > >> > takes > >> > me go the view of all events, this time it created the form I > submitted > >> > and > >> > created another empty one > >> > > >> > The function in views.py "add_news_item" is not set up in the URL, but > >> > it > >> > does support the cancel on the form action. The video posted is usin
Re: Not sure how to describe issue/behavior with Form -- so here's code & YouTube video
For ease of use, let's take the cancel out of the equation perhaps. Url to create a new News Event: ### Create News Article url(r'^account/news/add/$', login_required(CreateView.as_view( model=NewsArticle, form_class=NewsForm, success_url=("/account/news"), template_name="account/news_admin.html")), name="admin-add-news"), Url that gets called when I chose to insert an image into the WYSIWYG editor (and calls 'upload_photos' that has the NewsArticle.objects.create()) ### Redactor.js WYSIWYG Editor ### url(r"^uploads/$", "web_site.News.views.upload_photos", name="upload_photos"), url(r"^recent/$", "web_site.News.views.recent_photos", name="recent_photos"), and the views themselves: @csrf_exempt @require_POST @login_required def upload_photos(request): images = [] for f in request.FILES.getlist("file"): obj = NewsArticle.objects.create(upload=f, is_image=True) images.append({"filelink": obj.upload.url}) return HttpResponse(json.dumps(images), mimetype="application/json") @login_required def recent_photos(request): images = [ {"thumb": obj.upload.url, "image": obj.upload.url} for obj in NewsArticle.objects.filter(is_image=True).order_by("-date_created")[:20] ] return HttpResponse(json.dumps(images), mimetype="application/json") I've tried to set a .save(commit=False) on obj -- that doesn't work. I realize the behavior is call 'upload_photos' and it'll create the object in the database, but on any other event other than submission of the form, I want that object to no longer exist. I guess I want it to ONLY get created upon form submission. On Friday, August 24, 2012 3:01:32 AM UTC-7, Tom Evans wrote: > > On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison > > > wrote: > > Code: http://dpaste.org/az8Nb/ > > Video http://www.youtube.com/watch?v=XFSb044UkPs&feature=youtu.be > > > > so first action, I click + which adds new, hitting cancel, takes me back > to > > the view displaying all the news events > > next action, I hit + again, adds new news event...this time I browse for > an > > image, again, I click cancel, takes me back to the view of all news > events, > > but you see now an empty news event has been created > > next action, I hit + again, add a new image, hit submit. success_url > takes > > me go the view of all events, this time it created the form I submitted > and > > created another empty one > > > > The function in views.py "add_news_item" is not set up in the URL, but > it > > does support the cancel on the form action. The video posted is using > that > > view for the URL. With the 'CreateView' in the URL, canceling the form > will > > create an empty field in the database. > > > > Any help/guidance would be greatly appreciated!! > > > > Thanks! > > I've not watched your video. I also have no idea what crispy forms > are, or what django form attributes are created using that syntax. > However… > > Your model definition allows an empty form to be valid - none of those > fields are required AFAICT. Therefore, submitting an empty form using > the cancel button is being allowed to proceed. Therefore your check on > whether "cancel" was submitted is not working. > > Put some debug here: > > http://dpaste.org/az8Nb/#l28 > > Output what "submit" is, and all values in request.POST. > > Cheers > > Tom > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/cf1oUHRglAcJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Not sure how to describe issue/behavior with Form -- so here's code & YouTube video
Code: http://dpaste.org/az8Nb/ Video http://www.youtube.com/watch?v=XFSb044UkPs&feature=youtu.be so first action, I click + which adds new, hitting cancel, takes me back to the view displaying all the news events next action, I hit + again, adds new news event...this time I browse for an image, again, I click cancel, takes me back to the view of all news events, but you see now an empty news event has been created next action, I hit + again, add a new image, hit submit. success_url takes me go the view of all events, this time it created the form I submitted and created another empty one The function in views.py "add_news_item" is not set up in the URL, but it does support the cancel on the form action. The video posted is using that view for the URL. With the 'CreateView' in the URL, canceling the form will create an empty field in the database. Any help/guidance would be greatly appreciated!! Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bFlAdN00t0sJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Redirect to page with query string
This actually ended up working: http://dpaste.org/U0uY4/ On Saturday, August 18, 2012 5:46:28 PM UTC-7, Melvyn Sopacua wrote: > > On 19-8-2012 2:26, Barry Morrison wrote: > > I have a view that displays images and gives me the ability to delete > the > > images. > > > > View url == /account/community/images/1 (1 == event_id) > > Change to: > href="images/{{event.pk}}?return_to=/account/community/images/{{event.pk}}">. > > Keep passing this return_to parameter around. It helps to use the > request context processor so you can just grab it from the request > context in a template. > > > I'd like the success_url to be /account/community/images{{ event.id }} > the > > page I came from > > Subclass the Deleteview and implement get_success_url(), using > request.GET['return_to'] or if you decide to put a hidden input in the > delete form with the return_to value then obviously it's in request.POST. > -- > Melvyn Sopacua > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ylPWZtCUBB0J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Redirect to page with query string
I apologize, I'm new to Django and Python...I've tried every which way I know how based on what you described, and I can't find success. Here is what I'm at right now: http://dpaste.org/7JcGT/ I get this error: 'DeleteCommunityImages' object has no attribute 'GET' Full traceback: http://dpaste.org/QZ6uB/ Thanks, Barry On Sat, Aug 18, 2012 at 5:46 PM, Melvyn Sopacua wrote: > On 19-8-2012 2:26, Barry Morrison wrote: > > I have a view that displays images and gives me the ability to delete the > > images. > > > > View url == /account/community/images/1 (1 == event_id) > > Change to: > href="images/{{event.pk}}?return_to=/account/community/images/{{event.pk > }}">. > Keep passing this return_to parameter around. It helps to use the > request context processor so you can just grab it from the request > context in a template. > > > I'd like the success_url to be /account/community/images{{ event.id }} > the > > page I came from > > Subclass the Deleteview and implement get_success_url(), using > request.GET['return_to'] or if you decide to put a hidden input in the > delete form with the return_to value then obviously it's in request.POST. > -- > Melvyn Sopacua > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Redirect to page with query string
I have a view that displays images and gives me the ability to delete the images. View url == /account/community/images/1 (1 == event_id) That url will display all images associated with event_id=1 Each image displays a 'delete' url that calls /account/press/page/delete/{{ image.pk }} -- the success_url for this view is /account/press/page I'd like the success_url to be /account/community/images{{ event.id }} the page I came from Code and lengthier explanation exists here: http://dpaste.org/7SGf8/ Thanks!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/3Hzx9g-iCdMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django-tagging | Filtering results
Total brain block. code: https://gist.github.com/2c70c0992ba14ded1593 The desired result is something like this /favs/ will show all favorites (no tag cloud) /favs/Source1 Will display tag cloud associated with only Source1 /favs/Source2 will display tag cloud associated with only Source2 I'm struggling to figure out how to filter on source to only display the tags associated with the source. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/M8W0Ub1u8SQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: DetailView - invalid literal for int() with base 10:
Apologies, here is the error output if it helps. ValueError at /favs/Reddit/sysadmin/ invalid literal for int() with base 10: 'sysadmin' Request Method: GET Request URL: http://127.0.0.1:8000/favs/Reddit/sysadmin/ Django Version: 1.4 Exception Type: ValueError Exception Value: invalid literal for int() with base 10: 'sysadmin' Exception Location: /home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py in get_prep_value, line 537 Python Executable: /home/bmorriso/LocalRepository/Myosotis/venv/bin/python Python Version: 2.7.3 Python Path: ['/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-packages/requests/packages', '/home/bmorriso/LocalRepository/Myosotis', '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/plat-linux2', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-tk', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-old', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-packages', '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages'] Server time: Thu, 5 Jul 2012 02:03:21 -0700 On Thursday, July 5, 2012 2:13:59 AM UTC-7, Jon Black wrote: > > I'm not sure without running it, which I can't do now. I have noticed > that your slug is not and id, but the field PostSubReddit is a foerignkey > which might expect an id. > > Unrelated, I think your models shouldn't be pluralised (e.g. Post instead > of Posts). If you want the table name to be plural, use the Meta class. > > -- > Jon Black > www.jonblack.org > > > On Thu, Jul 5, 2012, at 02:07, Barry Morrison wrote: > > I've been beating my head against this all night and now into the > morning...I have NO idea what I'm doing wrong and Google and Stack Overflow > haven't been as helpful as I had hoped. > > https://gist.github.com/7dc0b98a2fe056379ae8 > > Any help or guidance would be greatly appreciated! > > Thanks!! > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
DetailView - invalid literal for int() with base 10:
I've been beating my head against this all night and now into the morning...I have NO idea what I'm doing wrong and Google and Stack Overflow haven't been as helpful as I had hoped. https://gist.github.com/7dc0b98a2fe056379ae8 Any help or guidance would be greatly appreciated! Thanks!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Article Viewer / Better way to do this? / Suggestions Please
I built the model as I imagined how it should be. Looks like I can rework it to not need the pages model. Thanks for that! The .url is also fantastic! Much appreciated! Thanks. On Wednesday, July 4, 2012 5:22:10 PM UTC-7, Nikolas Stevenson-Molnar wrote: > > Yes, pagination should get you what you want here. Using Django's > built-in pagination, you can drop your Page model completely (unless you > have a compelling reason to persist the page structure rather than > letting Django determine it for you on the fly). One additional note, > your Page.thumbnail_ method looks like something that would be better > suited in the template. Also, ImageField (and FileField) gives you a > handy "url" attribute. E.g: instead of constructing the path to the > image using thumbnail.name, you can do this (in a template): {{ > article.thumbnail.url }} > > _Nik > > On 7/4/2012 5:13 PM, Barry Morrison wrote: > > I have a bunch of press articles, these articles are basically > > thumbnails that open up to the pages of the articles. > > > > Here's what I've got so far. > > > > https://gist.github.com/0951804f4592c970b18b > > > > My thoughts are to use something like Django's pagination [1] > > https://docs.djangoproject.com/en/1.4/topics/pagination/ > > > > Is there a better way to do this??? > > > > Thanks! > > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/RK1gaPYF5qkJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Article Viewer / Better way to do this? / Suggestions Please
I have a bunch of press articles, these articles are basically thumbnails that open up to the pages of the articles. Here's what I've got so far. https://gist.github.com/0951804f4592c970b18b My thoughts are to use something like Django's pagination [1] https://docs.djangoproject.com/en/1.4/topics/pagination/ Is there a better way to do this??? Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-crispy-forms not displaying button
forms.py = http://dpaste.org/POItz/ html = http://dpaste.org/VsIjL/ Django 1.3.1 crispy-forms 1.1 Not sure why this isn't working. It's simply not generating the necessary for the button to exist. Any help would be GREATLY appreciated! Thanks, Barry -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/s8ZJMvKOp4cJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form.Forms + POST + forms.ChoiceField
If you could point me to a more recent tutorial, I'm more than willing to go through it. Basically what I have now, is a list of links. I want to sort those links based on source (Reddit) then subreddit (Python). The source and subreddits are fed from my DB and I want to select them from a drop-down menu. On Monday, April 2, 2012 1:34:58 PM UTC-7, skhohlov wrote: > > Ok. > I'm not definitely sure what you want to have but I'm proposing > to do simple project with next functionality: > > 1) prepare list of the links > 2) ability to click at the link and receive some additional > information about link > 3) button for deleting of the link > 4) button for creating new one > > Which are be covered : > class based view > generic view > passing values from view to form or template > > If you are interested we can start. Also if you would like to add > some other areas let me know > > Thanks, > Serge > > 2012/4/2 Barry Morrison : > > Too much code? I'd rather too much than not enough, but if it'd help, I > can > > cut down on future posts. > > > > Thanks for the information/guidance. I'll try your suggestions and post > my > > findings. > > > > Much appreciated! > > > > On Monday, April 2, 2012 2:18:29 AM UTC-7, skhohlov wrote: > >> > >> So much code ;-) > >> at first I'm proposing to add some code for form.is_valid block > >> for example : > >> if form.is_valid(): > >> source = Sources.objects.get(name=source) > >> allPosts = Posts.objects.filter(PostSource=source) > >> subreddits = SubReddits.objects.all() > >> source = form.cleaned_data['foo'] > >> return render_to_response('feeds.html', > >> {'allPosts': allPosts, > >> 'subreddits': subreddits}, > >> context_instance=RequestContext(request)) > >> else: > >> print form.error > >> > >> This will help to catch error with form . > >> > >> Also it is not correct to use this construction: > >> > >> class SourceSelection(forms.Form): > >> sources = Sources.objects.all() > >> foo = forms.ChoiceField(choices=sources) > >> > >> This mean that you never add any sources. or sources object are add > >> before starting application. For dynamic loading objects in the form > >> use form constructor. > >> and last one point : > >> > >> Please separate views and form in the different files : views.py > forms.py > >> > >> 2012/4/2 Barry Morrison : > >> > Full Disclosure: I've been using Python for 5-6 months. Django for > maybe > >> > 3 > >> > > >> > I have this: https://gist.github.com/a934fe08643e0c3ee017 > >> > > >> > In an effort to teach myself, I'm simply building a Django app. For > >> > teaching > >> > purposes only. It's an aggregator of favorites across multiple sites. > >> > Right > >> > now, I'm simply dealing with saved items from Reddit. > >> > > >> > The problem I'm having is the drop-down selector POST'ing and > creating a > >> > the > >> > new URL. > >> > > >> > http://imgur.com/a/FL32I << Screen shots > >> > > >> > 1) root or /feeds/ > >> > 2) Select Reddit from drop-down > >> > 3) Displays Reddit items only /feeds/Reddit/ > >> > 4) Select 'Python' from drop-down, displays items from r/Python with > URL > >> > /feeds/Reddit/Python > >> > > >> > This works (manually entering URL's), the drop down does not. > >> > > >> > I currently get "Error 1" from the gist. > >> > > >> > On views.py, if I uncomment lines 16 - 19, and comment the lines 21 - > >> > 23, I > >> > get a different error: "Error2" from the gist. What I don't > understand > >> > regarding the 2nd error, is that it is in fact returning: source: > >> > u'Reddit' > >> > and that exists in the Model, so it makes me think it's expecting > >> > something > >> > other than u'Reddit'. > >> > > >> > I'm at a loss, so this is me asking for help. Sorry for the long post > >> > and >
Re: form.Forms + POST + forms.ChoiceField
Too much code? I'd rather too much than not enough, but if it'd help, I can cut down on future posts. Thanks for the information/guidance. I'll try your suggestions and post my findings. Much appreciated! On Monday, April 2, 2012 2:18:29 AM UTC-7, skhohlov wrote: > > So much code ;-) > at first I'm proposing to add some code for form.is_valid block > for example : > if form.is_valid(): > source = Sources.objects.get(name=source) > allPosts = Posts.objects.filter(PostSource=source) > subreddits = SubReddits.objects.all() > source = form.cleaned_data['foo'] > return render_to_response('feeds.html', > {'allPosts': allPosts, > 'subreddits': subreddits}, > context_instance=RequestContext(request)) > else: > print form.error > > This will help to catch error with form . > > Also it is not correct to use this construction: > > class SourceSelection(forms.Form): > sources = Sources.objects.all() > foo = forms.ChoiceField(choices=sources) > > This mean that you never add any sources. or sources object are add > before starting application. For dynamic loading objects in the form > use form constructor. > and last one point : > > Please separate views and form in the different files : views.py forms.py > > 2012/4/2 Barry Morrison : > > Full Disclosure: I've been using Python for 5-6 months. Django for maybe > 3 > > > > I have this: https://gist.github.com/a934fe08643e0c3ee017 > > > > In an effort to teach myself, I'm simply building a Django app. For > teaching > > purposes only. It's an aggregator of favorites across multiple sites. > Right > > now, I'm simply dealing with saved items from Reddit. > > > > The problem I'm having is the drop-down selector POST'ing and creating a > the > > new URL. > > > > http://imgur.com/a/FL32I << Screen shots > > > > 1) root or /feeds/ > > 2) Select Reddit from drop-down > > 3) Displays Reddit items only /feeds/Reddit/ > > 4) Select 'Python' from drop-down, displays items from r/Python with URL > > /feeds/Reddit/Python > > > > This works (manually entering URL's), the drop down does not. > > > > I currently get "Error 1" from the gist. > > > > On views.py, if I uncomment lines 16 - 19, and comment the lines 21 - > 23, I > > get a different error: "Error2" from the gist. What I don't understand > > regarding the 2nd error, is that it is in fact returning: source: > u'Reddit' > > and that exists in the Model, so it makes me think it's expecting > something > > other than u'Reddit'. > > > > I'm at a loss, so this is me asking for help. Sorry for the long post > and > > crazy amounts of information. > > > > Any help is GREATLY APPRECIATED! > > > > Thanks! > > > > POST > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/django-users/-/zXNmsoqAfdMJ. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/S3mhDHD8nu4J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
form.Forms + POST + forms.ChoiceField
Full Disclosure: I've been using Python for 5-6 months. Django for maybe 3 I have this: https://gist.github.com/a934fe08643e0c3ee017 In an effort to teach myself, I'm simply building a Django app. For teaching purposes only. It's an aggregator of favorites across multiple sites. Right now, I'm simply dealing with saved items from Reddit. The problem I'm having is the drop-down selector POST'ing and creating a the new URL. http://imgur.com/a/FL32I << Screen shots 1) root or /feeds/ 2) Select Reddit from drop-down 3) Displays Reddit items only /feeds/Reddit/ 4) Select 'Python' from drop-down, displays items from r/Python with URL /feeds/Reddit/Python This works (manually entering URL's), the drop down does not. I currently get "Error 1" from the gist. On views.py, if I uncomment lines 16 - 19, and comment the lines 21 - 23, I get a different error: "Error2" from the gist. What I don't understand regarding the 2nd error, is that it is in fact returning: source: u'Reddit' and that exists in the Model, so it makes me think it's expecting something other than u'Reddit'. I'm at a loss, so this is me asking for help. Sorry for the long post and crazy amounts of information. Any help is GREATLY APPRECIATED! Thanks! POST -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zXNmsoqAfdMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.