Sunday, January 31, 2016

Re: help with ManyToMany

I hope you forgive me skipping all of that getattr nonsense.

others = Studio.objects.filter(studio_group__in = choice.studio_group_set.all()).exclude(pk=choice.pk)

On Jan 28, 2016, at 2:16 AM, dave.l <mail.dave.lawrence@gmail.com> wrote:

Hi,

I am happy with my models, and I'm fine inserting data, what I would like help with is retrieval.

given a single instance of a Studio() I can get studio.studiogroup_set.all() which I can then iterate to find the individual studios and build my resulting list ensuring no duplicates and not 'studio' itself. All this is working in Python:

choice = self.get_object()
others = []
for set in getattr(choice, "%s_set" % choice.groupname.lower()).all():
    for other in getattr(set, choice.view_name()).exclude(pk=choice.pk):
        if other not in others:
            others.append(other)
for other in others:
    print other

but this doesn't seem very elegant and I'm wondering if there's a more 'django' way of doing this.

On Wednesday, January 27, 2016 at 8:36:26 PM UTC, Xristos Xristoou wrote:
your code is correct,where are the problem ?in the admin first add Studio and sfter this select on the field studio from class studiogroup one or more entries from the class studio so simple,

christos

Τη Τετάρτη, 27 Ιανουαρίου 2016 - 5:50:21 μ.μ. UTC+2, ο χρήστης dave.l έγραψε:
Hi,

I have recently returned to a Django project after a few years and I'm a little rusty on ManyToMany fields.

Here's my very simple models:


class Studio(models.Model):
    name 
= models.CharField(max_length=255, unique=True)

class StudioGroup(models.Model):
    description 
= models.CharField(max_length=255, unique=True)
    studio 
= models.ManyToManyField(Studio)


So a bunch of Studio(), which can be in multiple StudioGroups()

Given a single instance of a Studio(), I would like a single list of all other studios in all other groups.

so if Group1 is A,B,C and Group2 is A,D,E

I would like to return B,C,D,E for A.

My current solution is entirely in Python (which works), but I'd like a more Django-esque solultion of possible!

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+unsubscribe@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/7512817d-d348-48b2-abf1-f3f584650cce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter of the Norse



Re: Kind'a TL, but please DR - Need your thoughts

if a process takes too long to complete it won't be able to process new requests, so you will be limited to the number of workers you told uwsgi to use.

http requests should be short lived, if you have some heavy processing  to do the http request should return with something like 'accepted' and send the job to a queue (you can use celery)

On Mon, Feb 1, 2016 at 6:51 AM, Mario R. Osorio <nimbiotics@gmail.com> wrote:

I need comments on an application I have been recently proposed. The way it is being envisioned at this moment is this:


One python daemon will be listening for different communications media such as email, web and SMS (web also). IMHO, it is necessary to have a daemon per each media. This daemon(s) will only make sure the messages are received from a validated source and put such messages in a DB


A second(?) python daemon would be waiting for those messages to be in the DB, process them, act accordingly to the objective of the application, and update the DB as expected. This process(es) might included complicated and numerous mathematical calculations, which might take seconds and even minutes to process.


A third(?) python daemon would be in charge of replying to the original message with the obtained results, but there might be other media channels involved, eg the message was received from a given email or SMS user, but the results have to be sent to multiple other email/SMS users.


The reason I want to do the application using Django is that all this HAS to have multiple web interfaces and, at the end of the day most media will come through web, and have to be processed as http requests. Also, Django gives me a frame to make this work better organized and clean and I can make the application(s) DB agnostic.


Wanting the application to be DB agnostic does not mean that I don't have a choice: I know I have many options to communicate among different python processes, but I prefer to leave that to the DBMS. Of the open source DBMS I know of, only Firebird and PostgreSQL have event that can provide the communication between all the processes involved. I was able to create a very similar application in 2012 with Firebird, but this time I am being restricted to PostgreSQL, which I don't to oppose at all. That application did not involve http requests.


My biggest concern at this point is this:

If most (if not all) requests to the application are going to be processed as http requests, what will happen to pending requests when one of them takes too long to reply? Is this something to be solved at the application level or at the server level?



This is as simple as I can put it. Any thoughts, comments, criticism or recommendations are welcome.


Thanks a lot in advanced!

--
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+unsubscribe@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/802693b7-c00c-46bf-9902-688b27e21bbd%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+unsubscribe@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/CAFWa6tKZcKySJdG4YcnHh38oTuTTVEfaz6WBTOyKDmDiV0_sFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Kind'a TL, but please DR - Need your thoughts

I need comments on an application I have been recently proposed. The way it is being envisioned at this moment is this:


One python daemon will be listening for different communications media such as email, web and SMS (web also). IMHO, it is necessary to have a daemon per each media. This daemon(s) will only make sure the messages are received from a validated source and put such messages in a DB


A second(?) python daemon would be waiting for those messages to be in the DB, process them, act accordingly to the objective of the application, and update the DB as expected. This process(es) might included complicated and numerous mathematical calculations, which might take seconds and even minutes to process.


A third(?) python daemon would be in charge of replying to the original message with the obtained results, but there might be other media channels involved, eg the message was received from a given email or SMS user, but the results have to be sent to multiple other email/SMS users.


The reason I want to do the application using Django is that all this HAS to have multiple web interfaces and, at the end of the day most media will come through web, and have to be processed as http requests. Also, Django gives me a frame to make this work better organized and clean and I can make the application(s) DB agnostic.


Wanting the application to be DB agnostic does not mean that I don't have a choice: I know I have many options to communicate among different python processes, but I prefer to leave that to the DBMS. Of the open source DBMS I know of, only Firebird and PostgreSQL have event that can provide the communication between all the processes involved. I was able to create a very similar application in 2012 with Firebird, but this time I am being restricted to PostgreSQL, which I don't to oppose at all. That application did not involve http requests.


My biggest concern at this point is this:

If most (if not all) requests to the application are going to be processed as http requests, what will happen to pending requests when one of them takes too long to reply? Is this something to be solved at the application level or at the server level?



This is as simple as I can put it. Any thoughts, comments, criticism or recommendations are welcome.


Thanks a lot in advanced!

--
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+unsubscribe@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/802693b7-c00c-46bf-9902-688b27e21bbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

What is your app name? are you sure the name is polls??. The solution i mention works.

On Mon, Feb 1, 2016 at 9:32 AM, jfragos via Django users <django-users@googlegroups.com> wrote:
I tried your solution and had the same results

from django.conf.urls import include, url
from django.contrib import admin
from polls import views

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

RESULTS
Traceback (most recent call last):
  File "urls.py", line 18, in <module>
    from polls import views
ImportError: No module named 'polls'
Press any key to continue . . .



On Sunday, January 31, 2016 at 10:07:21 AM UTC-5, jfr...@yahoo.com wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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+unsubscribe@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/71ee26a4-3d68-46c2-97d4-16cf19976aa6%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+unsubscribe@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/CAPCf-y5-vu-_OfyLtO0Kyzny29_1xFGhWqPDqeiWP3OAAdX_NA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

I tried your solution and had the same results

from django.conf.urls import include, url
from django.contrib import admin
from polls import views

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

RESULTS
Traceback (most recent call last):
  File "urls.py", line 18, in <module>
    from polls import views
ImportError: No module named 'polls'
Press any key to continue . . .



On Sunday, January 31, 2016 at 10:07:21 AM UTC-5, jfr...@yahoo.com wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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+unsubscribe@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/71ee26a4-3d68-46c2-97d4-16cf19976aa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django formtools wizard produces blank page (No error returned)

Hi, James,

I'm trying with the django-debug-toolbar. I can't see anything because the message "500: INTERNAL SERVER ERROR" appears. I tried in all the options and keeps showing this 500 code message.

But it comes to my attention that, for example, the tooltip for "templates" shows "3 templates rendered". Anyway, I can't get the headers, the request or anything using the django-debug-toolbar. :-(

I will keep on with testing this.

On 30 January 2016 at 17:23, Martín Torre Castro <martin.torre.castro@gmail.com> wrote:

I can't see the initial load, which is the same as saying that the first step does not load.

El 30 ene. 2016 1:56 p. m., "James Schneider" <jrschneider83@gmail.com> escribió:

Your view is returning a 200 code, so it thinks it is finishing correctly with no errors, probably the reason you don't see any errors.

At what point do you get a blank page? Initial load? Final step? Does the template in your done() step exist? Have you installed the Django-debug-toolbar to examine the context of your blank page?

-James

On Jan 30, 2016 2:18 AM, "Martin Torre Castro" <madtyn@gmail.com> wrote:
I'm trying to use the formwizard in formtools package with no success (I was able to do it when the package was inside Django in earlier versions). 

The only response I got is:

    [23/Jan/2016 11:06:50]"GET /registration/wizard HTTP/1.1" 200 13729

and a blank page. No errors in browser or Eclipse console.

There's no way of googling without errors. Please help.

Thanks in advance

(If you guys find more comfortable stackoverflow, you can go to http://stackoverflow.com/q/34962499/1241715)


What did I do?

Firstly, I installed the formtools package with pip:

    django-formtools==1.0
    Django==1.8.3


Following the instructions of the official docs:

  1. Define form classes

    registration/forms.py

    class StepForm1(forms.Form):
        first_field = forms.CharField(max_length=100)
        second_field = forms.CharField()

    class StepForm2(forms.Form):
        message = forms.CharField(widget=forms.Textarea)

  2. Create WizardView

    registration/views.py

    TEST_TEMPLATES = {"test_step_1": "registration/test_step1.html", "test_step_2": "registration/test_step2.html", }

    from formtools.wizard.views import SessionWizardView

    class WizardTest(SessionWizardView):
        template_name = 'registration/test_wizard.html'

        # Return templates for each step
        def get_templates_name(self):
            return [TEST_TEMPLATES[self.steps.current]]

        # Method called when all is done
        def done(self, form_list, **kwargs):
            # return HttpResponseRedirect('/url-to-redirect-to/') 

            # We return the final template with the info
            return render_to_response('test_done.html', {
                                                                                   'form_data':[form.cleaned_data for form in form_list],
                                                                                   })
        # THESE METHODS BELOW ARE NOT NEEDED, BUT COMMENTED FOR FUTURE USE

        # Not strictly needed. Returns data for a step
        # or None if form is not valid

        # def get_cleaned_data_for_step(self, step):
            #return None

        # Form data postprocessing in a concrete wizard step
        # def process_step(self, form):
            #return self.get_form_step_data(form)

        # Handles value from a step before storing them into wizard
        # def get_form_step_data(self, form):
            #return form.data

  3. Create the templates

    registration/test_step1.html

    <h1>Two fields form</h1>
    <input id="first_field" name="first_field">
    <input id="second_field" name="second_field">

    registration/test_step2.html

    <h1>Message form</h1>
    <input id="message" name="message">

    registration/test_wizard.html

    {% extends "person/alumnos.html" %}
    {% load i18n %}

    {% block head %}
        {{ wizard.form.media }}
    {% endblock head %}

    {% block content %}
        <p>{% trans "Step {{wizard.steps.step1}} of {{wizard.steps.count}}" %}</p>
        <form action="" method="post">
            {% csrf_token %}

            {{ wizard.management_form }}
            {% if wizard.form.forms  %}
                {{ wizard.form.management_form }}
                {% for form in wizard.form.forms %}
                    {{form}}
                {% endfor %}
            {% else %}
                {{ wizard.form }}
            {% endif %}

            {% if wizard.steps.prev %}
                <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "Beginning" %}</button>
                <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "Previous step" %}</button>
            {% endif %}

            <input type="submit" value="submit"/>
        </form>
    {% endblock %}

  4. Add 'formtools' to my INSTALLED_APPS

    settings.py

    DJANGO_APPS = (
        # Default Django apps:
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
       
        'formtools',                 # <===== HERE
       
        # Useful template tags:
        # 'django.contrib.humanize',
        # Admin panel and documentation:
        'django.contrib.admin',
        # 'django.contrib.admindocs',
    )

    # Apps specific for this project go here.
    LOCAL_APPS = (
        'person',
        'registration',
        'teaching',
        'utils',
    )

    # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
    INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS

  5. Point my URLconf at your WizardView as_view() method.

    registration/urls.py

    from registration.forms import StepForm1, StepForm2

    TEST_FORMS = [("test_step_1", StepForm1), ("test_step_2", StepForm2), ]

    from registration.views import WizardTest

    # I tried in two ways, none of them worked

    urlpatterns = patterns('',
        url(r'^wizard$', WizardTest.as_view(TEST_FORMS), name='wizard_test'),
        url(r'^wizard2$', views.wizard, name='wizard_test'),
    )

    For the second way...

    registration/views.py

    def wizard(request):
        return WizardTest.as_view(TEST_FORMS)(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+unsubscribe@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/333f094e-3b3f-4235-b3df-1b5d76c3004f%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/mAi_fB_MTwo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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/CA%2Be%2BciXR%3DgaO142Q4mLVrtw4hEtVnbV7L2N49zeNOhp9Y1Fd4A%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+unsubscribe@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/CAKijOkxOOrk6VWm_2D%3DFWT%3Dz%2BqANZCX08LJqxY9b2bf1aX3LJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

The problem is how you import your views form your urls.py

you have to import also your poll views from mysite urls.py

you should try this:

mysite--->mysite--->urls.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
from poll import views

urlpatterns = patterns('',
    url(r'^poll/', include('poll.urls')),

    url(r'^admin/', include(admin.site.urls)),
)




Hope this helps.

Cheers



mysite--->polls--->urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]


mysite--->mysite--->urls.py

from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]




On Mon, Feb 1, 2016 at 5:09 AM, jfragos via Django users <django-users@googlegroups.com> wrote:
That is something I have tried. When I do it that way and run the program there is no error.  However, when I attempt to start the server from the command prompt I am presented with the following meesages which ends with 'Import error: No module named views'

c:\djangoprojects\mysite>python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03A418A0>
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Python35\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
    self.check(display_num_errors=True)
  File "C:\Python35\lib\site-packages\django\core\management\base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Python35\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Python35\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
    return check_resolver(resolver)
  File "C:\Python35\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "C:\Python35\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python35\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Python35\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python35\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "c:\djangoprojects\mysite\mysite\urls.py", line 20, in <module>
    url(r'^polls/', include('polls.urls')),
  File "C:\Python35\lib\site-packages\django\conf\urls\__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "c:\djangoprojects\mysite\polls\urls.py", line 3, in <module>
    import views
ImportError: No module named 'views'

 

On Sunday, January 31, 2016 at 12:03:39 PM UTC-5, Avraham Serour wrote:
please try:
from polls import views
or
import views

On Sun, Jan 31, 2016 at 6:59 PM, jfragos via Django users <django...@googlegroups.com> wrote:
Thank you for the response.  Since there are 2 of them I have posted both.  I have highlighted in yellow the places where they reside.  I have also attached the outer directory structure showing c:\djangoprojects and also a shot of the mysite structure.  I set this up as per the tutorial instructions or so I think I did.

mysite--->polls--->urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]


mysite--->mysite--->urls.py

from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]


On Sunday, January 31, 2016 at 10:07:21 AM UTC-5, jfr...@yahoo.com wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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...@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/1a0609f9-b163-4af7-b331-5cb1464407ff%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+unsubscribe@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/d6939308-e56e-49c7-82df-4b802f48be25%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+unsubscribe@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/CAPCf-y7vxQ%3DTVuwUCrNp6U-E9-Gubq%3DTEzi5A4x9w90wZjv%2B%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

That is something I have tried. When I do it that way and run the program there is no error.  However, when I attempt to start the server from the command prompt I am presented with the following meesages which ends with 'Import error: No module named views'

c:\djangoprojects\mysite>python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03A418A0>
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Python35\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
    self.check(display_num_errors=True)
  File "C:\Python35\lib\site-packages\django\core\management\base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Python35\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Python35\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
    return check_resolver(resolver)
  File "C:\Python35\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "C:\Python35\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python35\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Python35\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python35\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "c:\djangoprojects\mysite\mysite\urls.py", line 20, in <module>
    url(r'^polls/', include('polls.urls')),
  File "C:\Python35\lib\site-packages\django\conf\urls\__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "c:\djangoprojects\mysite\polls\urls.py", line 3, in <module>
    import views
ImportError: No module named 'views'

 

On Sunday, January 31, 2016 at 12:03:39 PM UTC-5, Avraham Serour wrote:
please try:
from polls import views
or
import views

On Sun, Jan 31, 2016 at 6:59 PM, jfragos via Django users <django...@googlegroups.com> wrote:
Thank you for the response.  Since there are 2 of them I have posted both.  I have highlighted in yellow the places where they reside.  I have also attached the outer directory structure showing c:\djangoprojects and also a shot of the mysite structure.  I set this up as per the tutorial instructions or so I think I did.

mysite--->polls--->urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]


mysite--->mysite--->urls.py

from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]


On Sunday, January 31, 2016 at 10:07:21 AM UTC-5, jfr...@yahoo.com wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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...@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/1a0609f9-b163-4af7-b331-5cb1464407ff%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+unsubscribe@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/d6939308-e56e-49c7-82df-4b802f48be25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

please try:
from polls import views
or
import views

On Sun, Jan 31, 2016 at 6:59 PM, jfragos via Django users <django-users@googlegroups.com> wrote:
Thank you for the response.  Since there are 2 of them I have posted both.  I have highlighted in yellow the places where they reside.  I have also attached the outer directory structure showing c:\djangoprojects and also a shot of the mysite structure.  I set this up as per the tutorial instructions or so I think I did.

mysite--->polls--->urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]


mysite--->mysite--->urls.py

from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]


On Sunday, January 31, 2016 at 10:07:21 AM UTC-5, jfr...@yahoo.com wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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+unsubscribe@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/1a0609f9-b163-4af7-b331-5cb1464407ff%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+unsubscribe@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/CAFWa6tK6VfxVnzTNmGO%2BfHKazz-wXA7_k_kgFE8P0ymWcSZxcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

Thank you for the response.  Since there are 2 of them I have posted both.  I have highlighted in yellow the places where they reside.  I have also attached the outer directory structure showing c:\djangoprojects and also a shot of the mysite structure.  I set this up as per the tutorial instructions or so I think I did.

mysite--->polls--->urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]


mysite--->mysite--->urls.py

from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]


On Sunday, January 31, 2016 at 10:07:21 AM UTC-5, jfr...@yahoo.com wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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+unsubscribe@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/1a0609f9-b163-4af7-b331-5cb1464407ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Tutorial part 1 Parent module not loaded

can you post your urls.py

On Sun, Jan 31, 2016 at 5:04 PM, jfragos via Django users <django-users@googlegroups.com> wrote:
Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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+unsubscribe@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/73123987-7654-41b7-b01b-a3d54194ec0b%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+unsubscribe@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/CAFWa6tKiOrESNhPbgVz1xcEaCKz5PWevvUNZ_G9K3n4a5jza%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Tutorial part 1 Parent module not loaded

Hi,
I am very new to Python and Django but not to programming. I have been programming for 30 years. That said I am trying to work my way thru the Django tutorial part 1 and I am confronted with the following error I can't get past:
Traceback (most recent call last):
  File "urls.py", line 3, in <module>
    from . import views
SystemError: Parent module '' not loaded, cannot perform relative import
Press any key to continue . . .

I'm sure you will request additional information but at this point I'm not sure what you will want to see.  I will post whatever you require.I have started over 3 times with the same results.  I believe I have followed the steps faithfully and I have setup the directory structures as you direct.  I didn't change anything. I'm running python 3.5.1 and Django 1.9.1. 

I would appreciate any help getting thru this as its becoming very frustrating

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+unsubscribe@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/73123987-7654-41b7-b01b-a3d54194ec0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re:Re: self.publish.strftime('%m')

 it works well .thanks .




--
林攀

在 2016-01-31 02:57:19,"Peter of the Norse" <RahmCoff@Radio1190.org> 写道:
You could use self.public.strftime('%Y') without any problems here.  If fact, it might be a bit safer if the year is ever less then four digits.  Since month and day are exactly two digits in the URL, reverse has to make sure they match exactly.  That means making sure there is a leading zero.  With the year, you don't have to worry about that, so it gets skipped.

On Jan 26, 2016, at 6:30 AM, 林攀 <18610710105@163.com> wrote:

return reverse('blog:post_detail', args=[self.publish.year,
self.publish.strftime('%m'),
self.publish.strftime('%d'),
self.slug])
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post>[-\w]+)/$',
views.post_detail, name='post_detail'),

i feel confused why publish.year(type int) don't use strftime method .


Peter of the Norse



--
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+unsubscribe@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/9C959670-19AE-48A3-97E7-A8C99E4A8A6B%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


新的一年,让我陪你奋斗,让我陪你辛苦!-2016携手前行>>

--
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+unsubscribe@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/4689fd21.1e8a.15297af94bb.Coremail.18610710105%40163.com.
For more options, visit https://groups.google.com/d/optout.

Saturday, January 30, 2016

Re: Reverse Foriegnkey filtering

> On Jan 27, 2016, at 5:15 AM, Michal Petrucha <michal.petrucha@koniiiik.org> wrote:
>
> On Wed, Jan 27, 2016 at 11:58:23AM +0000, Jonty Needham wrote:
>> I've found a need to do this and I'm struggling. Some info seems to
>> indicate that django doesn't support this. How is it meant to be done?
>>
>> Basically to be clear, I need to filter one queryset on a reverse
>> foriegnkey relation to another set of objects defined by a particualr
>> filter.
>>
>> model1(Models.model):
>> stuff = charfield
>>
>> model2(Models.model):
>> cow = Foreignkey(model1)
>> country = charfield
>>
>>
>> Problem: filter set of model1's by a particular country that's related to
>> model1 through model2
>
> If I read the problem correctly, the following should solve it::
>
> model1.objects.filter(model2__country=my_country)
>
> Cheers,
>
> Michal

You also might need to follow up with .distinct() https://docs.djangoproject.com/en/1.8/ref/models/querysets/#django.db.models.query.QuerySet.distinct

Peter of the Norse
RahmCoff@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+unsubscribe@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/C8D0965D-3FEB-44CB-95ED-B913C1497244%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.

Re: self.publish.strftime('%m')

You could use self.public.strftime('%Y') without any problems here.  If fact, it might be a bit safer if the year is ever less then four digits.  Since month and day are exactly two digits in the URL, reverse has to make sure they match exactly.  That means making sure there is a leading zero.  With the year, you don't have to worry about that, so it gets skipped.

On Jan 26, 2016, at 6:30 AM, 林攀 <18610710105@163.com> wrote:

return reverse('blog:post_detail', args=[self.publish.year,
self.publish.strftime('%m'),
self.publish.strftime('%d'),
self.slug])
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post>[-\w]+)/$',
views.post_detail, name='post_detail'),

i feel confused why publish.year(type int) don't use strftime method .


Peter of the Norse



Re: How should it make django test create a default_test database that is using 5 shemas ?


show us your settings.py file.
http://dpaste.de

On Saturday, January 30, 2016 at 1:31:17 AM UTC+2, JAMES DAMILD ETIENNE wrote:
I have a possgres database with 5 shemas , it connects very well to it , but when truing to do unit test on my models or view , the default table created in sqllite3 is saysing  that on of my table is not there :

 return Database.Cursor.execute(self, query, params)
OperationalError: no such table: jamestable

any help please  ?
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+unsubscribe@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/71f7b93c-0544-44bb-9da3-4c28105fbc47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.