class view with filter on form input

2019-02-11 Thread Bob Bobsled
Hi,
I have form on a search page  called SearchForm where the user selects
items to search.
The rest part creates a URI which appears as below from the selected items
to search.

http://archive/ephemera/searchresult/?choose_collection=Macmillan_input=GuitarBuilder_item=title

I'm trying to write a classview in views.py to get the URI parameters, then
fashion a query to place those in an object_list for viewing in a search
results template.

views.py
class SearchResultsView(django.views.generic.ListView):
template_name = 'ephemera/searchresults.html'
model = Item  #my model class

def get_queryset(self, **kwargs):

form = SearchForm()
choose_collection = self.request.GET.get('choose_collection')
user_input = self.request.GET.get('user_input')
choose_item = self.request.GET.get('choose_item')

object_list =
self.model.objects.filter(collection__icontains =
choose_collection).filter(choose_item__icontains = user_input)   #XXX

return object_list

I can't seem to figure out how to pass the choose_item get variable to the
filter.  Django complains cannot resolve keyword 'choose_item' into field.
The correct field is 'title' but I won't know that until the user selects
one of the choices from the form pull down menu.

The following query works fine directly on sqlite, but I can't seem to
figure out how to do it in the class view.

select * from ephemera_item where collection = 'MACMILLAN' AND title =
'Guitar Builder';

Could be my basic approach is bad too, because I'm only just starting out
with this.

Thank you for any advice.

Regards,
Bob

-- 
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/CALWZDaPAr0VYra-HazcwCXcvmh%3DYY9O9m1e6oKBTrxF9ouRz6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django admin widget

2018-10-15 Thread Bob Bobsled
Hi,
The idea for a separate model for author with a foreign key back to book is
interesting.  I hadn't thought of that.  Thanks for the ideas about how to
approach this problem.

On Sat, Oct 13, 2018 at 12:10 PM Ryan Nowakowski 
wrote:

> I've done something similar in the past but I use a separate model for
> author that has a foreign key back to book. You can limit the number of
> authors to 3 in the author save method.
>
> Then you can use an inline form for author in the admin. That will give
> you the + functionality you're looking for.
>
> If you want to keep you current book model the same with authors as
> fields, take a look at admin fieldsets.
>
> On October 12, 2018 8:43:26 PM CDT, thebobbobs...@gmail.com wrote:
>>
>> Hi,
>> I'm still a bit new to django, but making slow progress.
>>
>> I'm wondering how to move forward with a book class as model which has an
>> author field which
>> allows adding additional authors.
>>
>> I have three fields allocated in the SQLite db for up to three different
>> authors.
>>
>> What I'm trying to do is only expose the additional author text entry box
>> for the book class in admin
>> when say for example a plus or other widget is clicked.
>>
>> ex.  Author [  ]  +
>> ...then
>>   Additional Author1 [ ]  +
>> ...and finally
>>   Additional Author2 [ ]
>>
>> So if you click the plus the additional author1 text entry shows up, then
>> click again the last or third
>> author entry shows up, but no more plus we're out of db fields at that
>> point.
>>
>> Not trying to dynamically add fields to the db.  Just expose when needed
>> for up to three authors.
>>
>> Prefer to not use jquery and/or javascript, but stick to pure python
>> django if possible.
>>
>> I've been reading alot about admin but still confused as to best way to
>> proceed.
>>
>> Thank You,
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/96rMeBTLgOY/unsubscribe.
> To unsubscribe from this group and all its topics, 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/38283332-0AB7-4F6B-93E2-F4BD347CAFD6%40fattuba.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/CALWZDaM7V4EXSHTJUtnemJr0LQxeHykyhR4nxmnCVx0N1KUh%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django wamp

2018-07-08 Thread Bob Bobsled
Hi,
Thanks for the direction.  It seems that running mod_wsgi on a different
port thru a virutal host conf for apache is the way to move forward.  I'll
see if I can figure out how to do that.
Regards,


On Sat, Jul 7, 2018 at 9:39 PM, Avraham Serour  wrote:

> yes, it is possible.
>
> You are correct, they need to listen to a different port
>
> On Sun, Jul 8, 2018 at 9:24 AM Gerald Brown  wrote:
>
>> Is it possible to run 2 servers (Apache & Nginx) on the same system?
>>
>> Maybe if they listen on different ports i.e. 80 & 81
>>
>> On Sunday, 08 July, 2018 01:09 PM, m1chael wrote:
>>
>> best not to fight Apache and just use nginx for django
>>
>> On Sat, Jul 7, 2018, 11:07 PM  wrote:
>>
>>>
>>> Hi,
>>> I'm a novice with django but have been setting up django on a Win7 Wamp
>>> stack.  We have several small non-django websites running on wamp.
>>> Those projects are in c:/wamp/www/myproject for ex. and are accessed as
>>> localhost/myproject or myipxxx/myproject.
>>>
>>> Under wamp I have tried putting the django project in c:/wamp/apps, in
>>> c:/wamp/www, and just in c:/wamp too.  They all work fine with apache and
>>> mod_wsgi.
>>> At least I get a sample "helloworld" message in the webpage when I
>>> access the django site as localhost/mydjangosite or myipxxx/mydjangosite.
>>> This is basically the simple tut01 or polls app kindof django project.
>>>
>>> But the django project, wherever I put it in wamp, buggers our other
>>> non-django websites.  I get a message back from urls.py saying it's been
>>> thru all the urls listed and it cannot access our regular (non django
>>> sites) in c:/wamp/www when I try to access one as localhost/myproject or
>>> myipxxx/myproject from the browser.
>>>
>>> I'm a bit stuck on how to get these two to play together nicely.  I'm
>>> not sure if it's a django project configuration, an apache httpd.conf
>>> problem, or a wamp issue.  I'm wondering if someone has experience with
>>> this issue and could point me in the right direction for how to use django,
>>> but continue to use localhost or myipxxx/ to access our non-django wamp
>>> sites.
>>>
>>> Thank you,
>>> Bob
>>> --
>>> 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/f9e69bf3-5192-41b9-9b80-d80617c9f5d9%
>>> 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/CAAuoY6Nan7vxHE%3DLXAMYnMhh58%
>> 3DiV6DwFxQnt0FPBd7vvS6J_w%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/c1af585f-19c4-5cd0-7697-e167726ae65e%40gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/irthcNB1_-E/unsubscribe.
> To unsubscribe from this group and all its topics, 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/
> 

Re: django windows apache tell if apache is working

2018-07-03 Thread Bob Bobsled
Hi,
I think I see the problem now.

WAMP is a special case for aliases, and it's root directory default setup
in c:wamp\www for ex..  I need to do some more work on, say for ex. using
Django Tut 01, setting up mysite as an alias in wamp, and then putting the
polls app in it.  I believe apache might start to work then with django if
the wamp alias is setup correctly.

I also found this vid tut:  really good, but for XAMPP, not WAMP...but it
shows how to get the mod_wsgi.so from a renamed and extracted .whl file.
And using the mod_wsgi.so with apache simplifies things a bit, so this is
good too.

XAMPP
This shows how to create a mod_wsgi.so from the .pyd extracted from the
.whl file
https://www.youtube.com/watch?v=VnR5O4IjmOs

Regards


On Sat, Jun 30, 2018 at 10:08 AM, Jason  wrote:

> I meant the tutorial at https://docs.djangoproject.
> com/en/2.0/intro/tutorial01/
>
> That said, there's a few different ways you can actually deploy, but
> digitalocean has some good resources for starting out.
>
> https://www.digitalocean.com/community/tutorials/how-to-
> serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
>
> This one shows how to use apache on ubuntu, and you should be able to
> extrapolate to use wamp.
>
> what I would do is just set up a simple view to return a http response
> saying "working", and map that to the root.  Something like
>
> app/views
>
> def index(request):
> return HttpResponse("Working!")
>
> app/urls
>
> from app.views import index
> urlpatterns = [
> path('', index),
> ]
>
> and hit localhost.  That'll be all you need.
>
> Hi,
>> Thanks.
>> Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
>> the point where I realized I needed to do more with the last mile, so to
>> speak working on setup of the production server part on Windows and wamp.
>> Seems most tuts end at manage.py runserver, or start into deployment from
>> dev to production.  I can't seem to locate a good uptodate tut for wamp
>> that shows how to test everything is working properly in a simple manner
>> for the wsgi part.
>>
>> I'm just trying to verify the plumbing (httpd.conf, settings.py wsgi.py)
>> is working with apache, before spending too much more time building a site.
>>
>>
>> On Sat, Jun 30, 2018 at 2:54 AM, Jason  wrote:
>>
>>> appreciate the detailed report :-)
>>>
>>> so, have you set up the django tutorial project?  that application
>>> method in wsgi doesn't make any sense.  you should have urls and views set
>>> up in your project
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/django-users/-eJaLuJ85KE/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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/ms
>>> gid/django-users/6d241c04-55be-4524-959e-09630a7bc21f%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/-eJaLuJ85KE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/6f5e5996-a85e-4eb6-b5e4-804f7379a2b4%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/CALWZDaNY4miqCqxy%3DLvH4417%3DP4XGOuHAOepCBT2tPpg0wqkrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django windows apache tell if apache is working

2018-07-02 Thread Bob Bobsled
Hi,
I'm still stuck on getting Apache to verify as working with wsgi.
Wondering what I might be doing incorrectly.
I'm reading lots of tuts, but it's a jungle out there.

I changed the folder hierarchy for the project and app so
venv, django_project, and  django_app are all on the same level as manage.py
thus:
c:/wamp/www-src/django_project
c:/wamp/www-src/django_app
c:/wamp/www-src/venev
c:/wamp/www-src/manage.py

In wamp create folder named www-src alongside the www folder.
cd into www-src.

created a virtual environment:
Inside www-src run > virtualenv venv

ACTIVATE and DEACTIVATE:

then activate by
> venv\Scripts\activate

if that works see (venv) as a prefix to the command line.  To deactivate
type:
>venv\Scripts\deactivate.bat.
...or can also just use
(venv) c:\wamp\www-src >deactivate
-

DJANGO PROJECT, APP, and VENV:
Then with the virtual environment active, install Django with the local
instance of pip by typing: >pip install django

then created a new django project >python django-admin.py startproject
django_project

and on the same level as manage.py type
>django-admin.py startapp django_app

Should have django_app folder, django_project folder, venv folder, and
manage.py all on the same level.

SETUP SQLITE DATABASE:

in the top level folder (the one with manage.py in it), type this in:
> python manage.py migrate


START RUNSERVER:
> python manage.py runserver

see success...so far.
-
Trying to get Apache production server working...

SETUP STATIC files location:

in settings.py

SETTINGS.PY:

in settings.py change STATIC_URL to:

STATIC_URL = os.path.join(BASE_DIR, "static/")

...also set
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

then run
>(venv) c:\wamp\www-src>manage.py collectstatic

(should see new static dir under www-src)
---

MIGRATIONS:

then from c:\wamp\www-src run
(venv) c:\wamp\www-src >manage.py makemigrations
then
(venv) c:\wamp\www-src >manage.py migrate

SETTINGS.PY

in settings.py change STATIC_URL to:

STATIC_URL = os.path.join(BASE_DIR, "static/")

...also set
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

then run
>(venv) c:\wamp\www-src>manage.py collectstatic

(should see new static dir under www-src)
--
...per Jason's suggestion for simple view and url...

in DJANGO_APP/VIEWS.PY

def index(request):
return HttpResponse("Working!")

--
in DJANGO_APP/URLS.PY

from django_app.views import index
urlpatterns = [
path('', index),
]

-
APACHE HTTPD.CONF

#---mod_wgi-express config for location in python ---
LoadFile
"c:/users/administrator/appdata/local/programs/python/python36-32/python36.dll"
LoadModule wsgi_module
"c:/users/administrator/appdata/local/programs/python/python36-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win32.pyd"

WSGIPythonHome
"c:/users/administrator/appdata/local/programs/python/python36-32"
WSGIScriptAlias /django-project "C:/wamp/www-src/django_project/wsgi.py"
#WSGIPythonPath
"C:/wamp/www-src/django_project/:C:/wamp/www-src/venv/Lib/site-packages"
WSGIPythonPath "C:/wamp/www-src:C:/wamp/www-src/venv/Lib/site-packages"



Order deny,allow
Require all granted




APACHE HTTPD-VHOSTS.CONF


ServerName localhost
ServerAlias localhost
DocumentRoot c:/wamp/www

Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
#Require local
Require all granted




Alias /static c:/wamp/www-src/static

Require all granted



---

restart APACHE

...but what is the correct URL to test here?

tried localhost:8000 all pointing to various folders but nothing connects
so far.



On Sat, Jun 30, 2018 at 10:08 AM, Jason  wrote:

> I meant the tutorial at https://docs.djangoproject.
> com/en/2.0/intro/tutorial01/
>
> That said, there's a few different ways you can actually deploy, but
> digitalocean has some good resources for starting out.
>
> https://www.digitalocean.com/community/tutorials/how-to-
> serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
>
> This one shows how to use apache on ubuntu, and you should be able to
> extrapolate to use wamp.
>
> what I would do is just set up a simple view to return a http response
> saying "working", and map that to the root.  Something like
>
> app/views
>
> def index(request):
> return HttpResponse("Working!")
>
> app/urls
>
> from app.views import index
> urlpatterns = [
> path('', index),
> ]
>
> and hit localhost.  That'll be all you need.
>
> Hi,
>> Thanks.
>> Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
>> the point where I realized I needed to do more with the last mile, so to
>> speak working on setup of the production server part on Windows and wamp.
>> Seems most tuts end at manage.py runserver, or start into deployment from
>> dev to production.  I can't seem to locate a good uptodate tut 

Re: django windows apache tell if apache is working

2018-06-30 Thread Bob Bobsled
Hi,
Thanks.
Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
the point where I realized I needed to do more with the last mile, so to
speak working on setup of the production server part on Windows and wamp.
Seems most tuts end at manage.py runserver, or start into deployment from
dev to production.  I can't seem to locate a good uptodate tut for wamp
that shows how to test everything is working properly in a simple manner
for the wsgi part.

I'm just trying to verify the plumbing (httpd.conf, settings.py wsgi.py) is
working with apache, before spending too much more time building a site.

On Sat, Jun 30, 2018 at 2:54 AM, Jason  wrote:

> appreciate the detailed report :-)
>
> so, have you set up the django tutorial project?  that application method
> in wsgi doesn't make any sense.  you should have urls and views set up in
> your project
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/-eJaLuJ85KE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/6d241c04-55be-4524-959e-09630a7bc21f%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/CALWZDaPoCygU8hSSYcsEpQnHGE%2B52EUxAyOko3kPRhR12t6HCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.